Skip to Content Skip to Search
Methods
A
B
C
D
F
H
M
P
S
T
W

Instance Public methods

add_plan_to_section(plan, index)

# File engines/admin/app/helpers/admin/application_helper.rb, line 120
def add_plan_to_section(plan, index)
  plan_html = "<span class='active mr-2.5 last:mr-0'>[#{plan}]</span>"

  if add_visible_plan?(plan, index)
    @text += plan_html
  else
    @hidden_plans += plan_html
  end
end

add_visible_plan?(_plan, index)

# File engines/admin/app/helpers/admin/application_helper.rb, line 130
def add_visible_plan?(_plan, index)
  threshold_exceded = @char_count > char_threshold
  return true unless threshold_exceded

  items_left = @plans_amount - index
  items_left == 1 && @hidden_plans.empty?
end

blackout_page_instruction()

# File engines/admin/app/helpers/admin/application_helper.rb, line 104
def blackout_page_instruction
  cms_info_provider.blackout_page_instructions_url
end

char_threshold()

# File engines/admin/app/helpers/admin/application_helper.rb, line 116
def char_threshold
  150
end

cms_info_provider()

# File engines/admin/app/helpers/admin/application_helper.rb, line 108
def cms_info_provider
  @cms_info_provider ||= SiteCmsInfoProvider.new(@site.cms)
end

coupon_description(coupon)

# File engines/admin/app/helpers/admin/application_helper.rb, line 47
def coupon_description(coupon)
  text = ""
  if coupon.amount_off
    money = Service::Money.new(coupon.amount_off, coupon.currency)
    text += "#{money.format} off"
  else
    text += "#{coupon.percent_off}% off"
  end

  text += " #{coupon_duration(duration: coupon.duration, duration_in_months: coupon.duration_in_months)}."

  text += " #{coupon.max_redemptions} redemptions (maximum)." if coupon.max_redemptions
  if coupon.redeem_start
    text += " Can be redeemed on #{coupon.redeem_start.strftime("%m/%d/%Y at %I:%M%p")}."
  end
  if coupon.redeem_end
    text += " Can't be redeemed after #{coupon.redeem_end.strftime("%m/%d/%Y at %I:%M%p")}."
  end
  text
end

coupon_redemptions(coupon)

# File engines/admin/app/helpers/admin/application_helper.rb, line 68
def coupon_redemptions(coupon)
  count = coupon.redemption_count

  content_tag(:span, class: "active") do
    if coupon.max_redemptions
      "[#{count}/#{coupon.max_redemptions} redemptions so far]"
    else
      "[#{pluralize(count, "redemption")} so far]"
    end
  end
end

custom_field_types(field)

# File engines/admin/app/helpers/admin/application_helper.rb, line 11
def custom_field_types(field)
  fields = {"text" => "Single line of text",
            "textarea" => "Paragraph of text",
            "select" => "Dropdown",
            "radio" => "Multiple choice",
            "checkbox" => "Checkbox"}
  fields = fields.merge(custom_field_type_mailchimp) if mailchimp_field?(field)
  fields
end

designer_font_styles(request)

# File engines/admin/app/helpers/admin/application_helper.rb, line 142
def designer_font_styles(request)
  Service::BrowserInfoManager.new(request.user_agent).font_styles
end

format_amount(num, currency)

# File engines/admin/app/helpers/admin/application_helper.rb, line 7
def format_amount(num, currency)
  num ? Service::Money.new(num, currency).amount_value : nil
end

formated_time_zone(time_zone)

# File engines/admin/app/helpers/admin/application_helper.rb, line 88
def formated_time_zone(time_zone)
  "(GMT#{Time.at(Time.now).in_time_zone(time_zone.name).formatted_offset(true)}) #{time_zone.name}"
end

formated_tz_info(time_zone)

# File engines/admin/app/helpers/admin/application_helper.rb, line 92
def formated_tz_info(time_zone)
  time_zone.tzinfo.to_s.gsub(" - ", "/").gsub(", ", "/").tr(" ", "_").to_s
end

help_scout_beacon_signature()

# File engines/admin/app/helpers/admin/application_helper.rb, line 3
def help_scout_beacon_signature
  OpenSSL::HMAC.hexdigest("sha256", Rails.application.secrets.helpscout["chat_beacon_key"], current_member.email)
end

member_custom_fields(member)

# File engines/admin/app/helpers/admin/application_helper.rb, line 138
def member_custom_fields(member)
  @site.custom_fields.select { |f| f.display? && member.has_plan_from_field?(f) }
end

plans_selection_label()

# File engines/admin/app/helpers/admin/application_helper.rb, line 84
def plans_selection_label
  "Which Member Plans can have access?"
end

plans_selection_label_custom_fields()

# File engines/admin/app/helpers/admin/application_helper.rb, line 80
def plans_selection_label_custom_fields
  "Only show field for these plans:"
end

protected_page_plan_section(page)

# File engines/admin/app/helpers/admin/application_helper.rb, line 26
def protected_page_plan_section(page)
  @text = ""
  @hidden_plans = ""
  @char_count = 0
  @plans_amount = page.plan_names.count

  page.plan_names.each_with_index do |plan, index|
    @char_count += plan.length
    add_plan_to_section(plan, index)
  end

  unless @hidden_plans.empty?
    # TODO: Replace with reveal stimulus
    @text += "<div id='view-more-#{page.id}'><a href='' class='link-toggle'><i class='fal fa-plus-circle'></i> <span>View more</span></a></div><div id='hidden-plans-#{page.id}' style='display: none'>"
    @text += @hidden_plans
    @text += "</div><div id='view-less-#{page.id}' style='display: none'><a href='' class='link-toggle' ><i class='fal fa-minus-circle'></i> <span>View less</span></a></div>"
  end

  @text.html_safe
end

time_to_minutes(time)

# File engines/admin/app/helpers/admin/application_helper.rb, line 96
def time_to_minutes(time)
  sign = time[0]
  time_splited = time.split(":")
  hours_to_minutes = time_splited[0].slice!(1, 3).to_i * 60
  minutes = time_splited[1].to_i
  "#{sign}#{hours_to_minutes + minutes}".to_i
end

with_site_cms()

# File engines/admin/app/helpers/admin/application_helper.rb, line 112
def with_site_cms
  yield ActiveSupport::StringInquirer.new(@site.cms)
end