Class: SolidusPromotions::PromotionCategories::Index::Component

Inherits:
SolidusAdmin::UI::Pages::Index::Component
  • Object
show all
Defined in:
lib/components/admin/solidus_promotions/promotion_categories/index/component.rb

Instance Method Summary collapse

Instance Method Details

#batch_actionsObject



30
31
32
33
34
35
36
37
38
39
# File 'lib/components/admin/solidus_promotions/promotion_categories/index/component.rb', line 30

def batch_actions
  [
    {
      label: t(".batch_actions.delete"),
      action: solidus_promotions.promotion_categories_path(**search_filter_params),
      method: :delete,
      icon: "delete-bin-7-line"
    }
  ]
end

#code_columnObject



59
60
61
62
63
64
65
66
67
68
# File 'lib/components/admin/solidus_promotions/promotion_categories/index/component.rb', line 59

def code_column
  {
    header: :code,
    data: ->(record) do
      link_to record.code, edit_path(record),
        data: { turbo_frame: :resource_modal },
        class: 'body-link'
    end
  }
end

#columnsObject



41
42
43
44
45
46
# File 'lib/components/admin/solidus_promotions/promotion_categories/index/component.rb', line 41

def columns
  [
    name_column,
    code_column
  ]
end

#edit_path(record) ⇒ Object



12
13
14
# File 'lib/components/admin/solidus_promotions/promotion_categories/index/component.rb', line 12

def edit_path(record)
  solidus_promotions.edit_promotion_category_path(record, **search_filter_params)
end

#model_classObject



4
5
6
# File 'lib/components/admin/solidus_promotions/promotion_categories/index/component.rb', line 4

def model_class
  SolidusPromotions::PromotionCategory
end

#name_columnObject



48
49
50
51
52
53
54
55
56
57
# File 'lib/components/admin/solidus_promotions/promotion_categories/index/component.rb', line 48

def name_column
  {
    header: :name,
    data: ->(record) do
      link_to record.name, edit_path(record),
        data: { turbo_frame: :resource_modal },
        class: 'body-link'
    end
  }
end

#page_actionsObject



20
21
22
23
24
25
26
27
28
# File 'lib/components/admin/solidus_promotions/promotion_categories/index/component.rb', line 20

def page_actions
  render component("ui/button").new(
    tag: :a,
    text: t(".add"),
    href: solidus_promotions.new_promotion_category_path(**search_filter_params),
    data: { turbo_frame: :resource_modal },
    icon: "add-line"
  )
end

#solidus_promotionsObject



70
71
72
# File 'lib/components/admin/solidus_promotions/promotion_categories/index/component.rb', line 70

def solidus_promotions
  @solidus_promotions ||= SolidusPromotions::Engine.routes.url_helpers
end

#titleObject



8
9
10
# File 'lib/components/admin/solidus_promotions/promotion_categories/index/component.rb', line 8

def title
  t('solidus_promotions.promotion_categories.title')
end

#turbo_framesObject



16
17
18
# File 'lib/components/admin/solidus_promotions/promotion_categories/index/component.rb', line 16

def turbo_frames
  %w[resource_modal]
end