Module: CampaignsHelper
- Defined in:
- app/helpers/campaigns_helper.rb
Overview
View helper: campaigns.
Instance Method Summary collapse
-
#audience_for_select ⇒ Array<Array(String, Integer)>
Builds sorted select options for every audience, labeled with the audience's first campaign name and member count.
-
#campaign_closed_activities_link(campaign) ⇒ String
Renders a link to the closed activities search for the campaign.
-
#campaign_command_options(campaign) ⇒ Array<String>
Builds the list of action links for a campaign row (state, transitions, edit, email-marketing actions, and delete when permitted).
-
#campaign_customer_link(campaign) ⇒ String
Renders a link to the customers search for the campaign.
-
#campaign_lead_link(campaign) ⇒ String
Renders a link to the leads search for the campaign's source.
-
#campaign_open_activities_link(campaign) ⇒ String
Renders a link to the open activities search for the campaign.
-
#campaign_opp_link(campaign) ⇒ String
Renders a link to the opportunities search for the campaign's source.
-
#campaign_order_link(campaign) ⇒ String
Renders a link to the orders search for the campaign's source.
-
#campaign_profit_link(campaign) ⇒ String
Renders a link showing total invoiced profit for the campaign's source.
-
#campaign_revenue_link(campaign) ⇒ String
Renders a link showing total invoiced revenue for the campaign's source.
Instance Method Details
#audience_for_select ⇒ Array<Array(String, Integer)>
Builds sorted select options for every audience, labeled with the
audience's first campaign name and member count.
98 99 100 |
# File 'app/helpers/campaigns_helper.rb', line 98 def audience_for_select Audience.all.map { |sl| ["#{sl.campaigns.first.try(:name) || 'No Campaign'} > List: #{sl.name} (#{sl.audience_members.size})", sl.id] }.sort end |
#campaign_closed_activities_link(campaign) ⇒ String
Renders a link to the closed activities search for the campaign.
89 90 91 92 |
# File 'app/helpers/campaigns_helper.rb', line 89 def campaign_closed_activities_link(campaign) closed_link, = query_template_link(ActivitySearch, nil, query_params: { campaign_id_in: campaign.id, activity_result_type_id: ['Any'] }, show_zero: true, counter_class: '') closed_link end |
#campaign_command_options(campaign) ⇒ Array<String>
Builds the list of action links for a campaign row (state, transitions,
edit, email-marketing actions, and delete when permitted).
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/helpers/campaigns_helper.rb', line 9 def (campaign) actions = [] actions << campaign.human_state_name.titleize actions += available_events_links(campaign) actions << link_to(fa_icon('wrench', text: 'Edit'), edit_campaign_path(campaign)) if campaign.campaign_type == "email_marketing" actions << link_to(fa_icon('bullhorn', text: "New Campaign Email"), new_campaign_campaign_email_path(campaign)) actions << link_to(fa_icon('link', text: "Link Existing Email Template"), link_template_campaign_campaign_emails_path(campaign)) end actions << link_to(fa_icon('trash', text: 'Delete'), campaign_path(campaign), data: { turbo_confirm: "Are you sure?", turbo_method: :delete }) if can?(:destroy, campaign) actions.compact end |
#campaign_customer_link(campaign) ⇒ String
Renders a link to the customers search for the campaign.
44 45 46 47 |
# File 'app/helpers/campaigns_helper.rb', line 44 def campaign_customer_link(campaign) customer_link, = query_template_link(CustomerSearch, nil, query_params: { campaign_id_in: [campaign.id] }, show_zero: true, counter_class: '') customer_link end |
#campaign_lead_link(campaign) ⇒ String
Renders a link to the leads search for the campaign's source.
35 36 37 38 |
# File 'app/helpers/campaigns_helper.rb', line 35 def campaign_lead_link(campaign) lead_link, = query_template_link(CustomerSearch, nil, query_params: { source_id: [campaign.source_id] }, show_zero: true, counter_class: '') lead_link end |
#campaign_open_activities_link(campaign) ⇒ String
Renders a link to the open activities search for the campaign.
80 81 82 83 |
# File 'app/helpers/campaigns_helper.rb', line 80 def campaign_open_activities_link(campaign) open_link, = query_template_link(ActivitySearch, nil, query_params: { campaign_id_in: campaign.id, activity_result_type_id: ['Open'] }, show_zero: true, counter_class: '') open_link end |
#campaign_opp_link(campaign) ⇒ String
Renders a link to the opportunities search for the campaign's source.
26 27 28 29 |
# File 'app/helpers/campaigns_helper.rb', line 26 def campaign_opp_link(campaign) opp_link, = query_template_link(OpportunitySearch, nil, query_params: { source_id: [campaign.source_id] }, show_zero: true, counter_class: '') opp_link end |
#campaign_order_link(campaign) ⇒ String
Renders a link to the orders search for the campaign's source.
53 54 55 56 |
# File 'app/helpers/campaigns_helper.rb', line 53 def campaign_order_link(campaign) order_link, = query_template_link(OrderSearch, nil, query_params: { source_id: [campaign.source_id] }, show_zero: true, counter_class: '') order_link end |
#campaign_profit_link(campaign) ⇒ String
Renders a link showing total invoiced profit for the campaign's source.
71 72 73 74 |
# File 'app/helpers/campaigns_helper.rb', line 71 def campaign_profit_link(campaign) profit_link, = query_template_link(InvoiceSearch, nil, query_params: { source_id: [campaign.source_id] }, show_zero: true, aggregate_method: :sum, aggregate_column: :profit_consolidated, format: :currency, counter_class: '') profit_link end |
#campaign_revenue_link(campaign) ⇒ String
Renders a link showing total invoiced revenue for the campaign's source.
62 63 64 65 |
# File 'app/helpers/campaigns_helper.rb', line 62 def campaign_revenue_link(campaign) revenue_link, = query_template_link(InvoiceSearch, nil, query_params: { source_id: [campaign.source_id] }, show_zero: true, aggregate_method: :sum, aggregate_column: :revenue_consolidated, format: :currency, counter_class: '') revenue_link end |