Class: SolidusAdmin::TaxRates::Index::Component

Inherits:
SolidusAdmin::Taxes::Component
  • Object
show all
Defined in:
app/components/solidus_admin/tax_rates/index/component.rb

Instance Method Summary collapse

Instance Method Details

#actionsObject



16
17
18
19
20
21
22
23
24
# File 'app/components/solidus_admin/tax_rates/index/component.rb', line 16

def actions
  render component("ui/button").new(
    tag: :a,
    text: t('.add'),
    href: spree.new_admin_tax_rate_path,
    icon: "add-line",
    class: "align-self-end w-full",
  )
end

#batch_actionsObject



30
31
32
33
34
35
36
37
38
39
# File 'app/components/solidus_admin/tax_rates/index/component.rb', line 30

def batch_actions
  [
    {
      label: t('.batch_actions.delete'),
      action: solidus_admin.tax_rates_path,
      method: :delete,
      icon: 'delete-bin-7-line',
    },
  ]
end

#columnsObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'app/components/solidus_admin/tax_rates/index/component.rb', line 58

def columns
  [
    {
      header: :zone,
      data: -> { _1.zone&.name },
    },
    :name,
    {
      header: :tax_categories,
      data: -> { _1.tax_categories.map(&:name).join(', ') },
    },
    {
      header: :amount,
      data: -> { _1.display_amount },
    },
    {
      header: :included_in_price,
      data: -> { _1.included_in_price? ? component('ui/badge').yes : component('ui/badge').no },
    },
    {
      header: :show_rate_in_label,
      data: -> { _1.show_rate_in_label? ? component('ui/badge').yes : component('ui/badge').no },
    },
    :expires_at,
    {
      header: Spree::Calculator.model_name.human,
      data: -> { _1.calculator&.class&.model_name&.human }
    },
  ]
end

#filtersObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'app/components/solidus_admin/tax_rates/index/component.rb', line 41

def filters
  [
    {
      label: Spree::Zone.model_name.human,
      attribute: :zone_id,
      predicate: :eq,
      options: Spree::Zone.pluck(:name, :id),
    },
    {
      label: Spree::TaxCategory.model_name.human,
      attribute: :tax_categories_id,
      predicate: :in,
      options: Spree::TaxCategory.pluck(:name, :id),
    }
  ]
end

#model_classObject



8
9
10
# File 'app/components/solidus_admin/tax_rates/index/component.rb', line 8

def model_class
  Spree::TaxRate
end

#row_url(tax_rate) ⇒ Object



4
5
6
# File 'app/components/solidus_admin/tax_rates/index/component.rb', line 4

def row_url(tax_rate)
  spree.edit_admin_tax_rate_path(tax_rate)
end

#search_keyObject



26
27
28
# File 'app/components/solidus_admin/tax_rates/index/component.rb', line 26

def search_key
  :name_or_description_cont
end

#search_urlObject



12
13
14
# File 'app/components/solidus_admin/tax_rates/index/component.rb', line 12

def search_url
  solidus_admin.tax_rates_path
end