Module: CouponsHelper
- Defined in:
- app/helpers/coupons_helper.rb
Overview
View helper: coupons.
Builds the tab definitions and action links used on the CRM coupon
show and edit pages.
Instance Method Summary collapse
-
#coupon_commands(coupon = @coupon) ⇒ Array<String>
Action links (Edit, Clone, Destroy, promo synchronization) for the coupon page.
-
#coupon_edit_tab_options(f) ⇒ Hash{Symbol => Hash}
Tab definitions for the coupon edit form, keyed by tab name.
-
#coupon_show_tab_options(coupon = @coupon) ⇒ Hash{Symbol => Hash}
Tab definitions for the coupon show page, keyed by tab name.
Instance Method Details
#coupon_commands(coupon = @coupon) ⇒ Array<String>
Action links (Edit, Clone, Destroy, promo synchronization) for the coupon page.
Returns no commands unless the current user can update the coupon.
The promo-item synchronization link is included only for
promo-tracking coupons.
58 59 60 61 62 63 64 65 66 67 68 |
# File 'app/helpers/coupons_helper.rb', line 58 def coupon_commands(coupon = @coupon) return [] unless can?(:update, coupon) cmds = [ link_to('Edit', edit_coupon_path(coupon)), link_to('Clone', clone_coupon_path(coupon)), link_to('Destroy', coupon_path(coupon), data: { turbo_method: :delete }) ] cmds << link_to('Publish/Synchronize Promo Items', synchronize_promo_items_coupon_path(coupon), data: { turbo_method: :post }) if coupon.promo_tracking cmds end |
#coupon_edit_tab_options(f) ⇒ Hash{Symbol => Hash}
Tab definitions for the coupon edit form, keyed by tab name.
Each value names the partial rendered for that tab plus the locals
(the form builder) passed to it.
39 40 41 42 43 44 45 46 47 48 |
# File 'app/helpers/coupons_helper.rb', line 39 def (f) { basic_attributes: { partial: 'edit_basic_attributes', locals: { f: f } }, calculations: { partial: 'edit_calculations', locals: { f: f } }, restrictions: { partial: 'edit_restrictions', locals: { f: f } }, serial_numbers: { partial: 'edit_serial_numbers', locals: { f: f } }, product_filters: { partial: 'edit_product_filters', locals: { f: f } }, special_actions: { partial: 'edit_special_actions', locals: { f: f } } } end |
#coupon_show_tab_options(coupon = @coupon) ⇒ Hash{Symbol => Hash}
Tab definitions for the coupon show page, keyed by tab name.
Each value carries the remote_href the tab lazily loads its
contents from. The :promotional_items tab is included only for
promo-tracking coupons.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/helpers/coupons_helper.rb', line 17 def (coupon = @coupon) hsh = { basic_attributes: { remote_href: tab_basic_attributes_coupon_path(coupon) }, calculations: { remote_href: tab_calculations_coupon_path(coupon) }, restrictions: { remote_href: tab_restrictions_coupon_path(coupon) }, serial_numbers: { remote_href: tab_serial_numbers_coupon_path(coupon) }, product_filters: { remote_href: tab_product_filters_coupon_path(coupon) }, promotional_items: { remote_href: tab_promotional_items_coupon_path(coupon) }, special_actions: { remote_href: tab_special_actions_coupon_path(coupon) }, statistics: { remote_href: tab_statistics_coupon_path(coupon) } } hsh.delete(:promotional_items) unless coupon.promo_tracking hsh end |