solidus_admin 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/app/components/solidus_admin/adjustment_reasons/index/component.rb +9 -19
  4. data/app/components/solidus_admin/base_component.rb +29 -1
  5. data/app/components/solidus_admin/option_types/index/component.rb +20 -6
  6. data/app/components/solidus_admin/orders/index/component.rb +20 -15
  7. data/app/components/solidus_admin/orders/index/component.yml +0 -1
  8. data/app/components/solidus_admin/payment_methods/index/component.rb +28 -18
  9. data/app/components/solidus_admin/payment_methods/index/component.yml +0 -5
  10. data/app/components/solidus_admin/products/index/component.rb +17 -10
  11. data/app/components/solidus_admin/products/index/component.yml +0 -2
  12. data/app/components/solidus_admin/promotion_categories/index/component.rb +12 -13
  13. data/app/components/solidus_admin/promotions/index/component.rb +17 -10
  14. data/app/components/solidus_admin/promotions/index/component.yml +0 -4
  15. data/app/components/solidus_admin/properties/index/component.rb +17 -18
  16. data/app/components/solidus_admin/refund_reasons/index/component.rb +18 -18
  17. data/app/components/solidus_admin/refunds_and_returns/component.rb +33 -13
  18. data/app/components/solidus_admin/reimbursement_types/index/component.rb +7 -25
  19. data/app/components/solidus_admin/return_reasons/index/component.rb +9 -19
  20. data/app/components/solidus_admin/shipping/component.rb +23 -11
  21. data/app/components/solidus_admin/shipping_categories/index/component.rb +18 -18
  22. data/app/components/solidus_admin/shipping_methods/index/component.rb +18 -18
  23. data/app/components/solidus_admin/stock_items/index/component.rb +9 -15
  24. data/app/components/solidus_admin/stock_locations/index/component.rb +18 -10
  25. data/app/components/solidus_admin/stock_locations/index/component.yml +0 -3
  26. data/app/components/solidus_admin/store_credit_reasons/index/component.rb +18 -18
  27. data/app/components/solidus_admin/stores/index/component.rb +17 -18
  28. data/app/components/solidus_admin/tax_categories/index/component.rb +20 -20
  29. data/app/components/solidus_admin/tax_rates/index/component.rb +18 -14
  30. data/app/components/solidus_admin/taxes/component.rb +8 -8
  31. data/app/components/solidus_admin/taxonomies/index/component.rb +17 -11
  32. data/app/components/solidus_admin/ui/pages/index/component.html.erb +30 -0
  33. data/app/components/solidus_admin/ui/pages/index/component.rb +119 -0
  34. data/app/components/solidus_admin/ui/table/component.html.erb +2 -1
  35. data/app/components/solidus_admin/ui/table/component.rb +1 -1
  36. data/app/components/solidus_admin/users/index/component.rb +17 -10
  37. data/app/components/solidus_admin/users/index/component.yml +0 -3
  38. data/app/components/solidus_admin/zones/index/component.rb +18 -10
  39. data/app/controllers/solidus_admin/promotion_categories_controller.rb +0 -9
  40. data/app/controllers/solidus_admin/properties_controller.rb +1 -1
  41. data/app/views/layouts/solidus_admin/preview.html.erb +2 -0
  42. data/config/initializers/view_component.rb +1 -1
  43. data/lib/solidus_admin/configuration.rb +3 -1
  44. data/lib/solidus_admin/version.rb +1 -1
  45. metadata +6 -43
  46. data/app/components/solidus_admin/adjustment_reasons/index/component.html.erb +0 -32
  47. data/app/components/solidus_admin/adjustment_reasons/index/component.yml +0 -4
  48. data/app/components/solidus_admin/option_types/index/component.html.erb +0 -30
  49. data/app/components/solidus_admin/orders/index/component.html.erb +0 -35
  50. data/app/components/solidus_admin/payment_methods/index/component.html.erb +0 -38
  51. data/app/components/solidus_admin/products/index/component.html.erb +0 -34
  52. data/app/components/solidus_admin/promotion_categories/index/component.html.erb +0 -26
  53. data/app/components/solidus_admin/promotion_categories/index/component.yml +0 -4
  54. data/app/components/solidus_admin/promotions/index/component.html.erb +0 -34
  55. data/app/components/solidus_admin/properties/index/component.html.erb +0 -34
  56. data/app/components/solidus_admin/properties/index/component.yml +0 -4
  57. data/app/components/solidus_admin/refund_reasons/index/component.html.erb +0 -31
  58. data/app/components/solidus_admin/refund_reasons/index/component.yml +0 -4
  59. data/app/components/solidus_admin/refunds_and_returns/component.html.erb +0 -26
  60. data/app/components/solidus_admin/reimbursement_types/index/component.html.erb +0 -22
  61. data/app/components/solidus_admin/reimbursement_types/index/component.yml +0 -4
  62. data/app/components/solidus_admin/return_reasons/index/component.html.erb +0 -31
  63. data/app/components/solidus_admin/return_reasons/index/component.yml +0 -4
  64. data/app/components/solidus_admin/shipping/component.html.erb +0 -30
  65. data/app/components/solidus_admin/shipping_categories/index/component.html.erb +0 -32
  66. data/app/components/solidus_admin/shipping_categories/index/component.yml +0 -4
  67. data/app/components/solidus_admin/shipping_methods/index/component.html.erb +0 -32
  68. data/app/components/solidus_admin/shipping_methods/index/component.yml +0 -4
  69. data/app/components/solidus_admin/stock_items/index/component.html.erb +0 -26
  70. data/app/components/solidus_admin/stock_locations/index/component.html.erb +0 -32
  71. data/app/components/solidus_admin/store_credit_reasons/index/component.html.erb +0 -31
  72. data/app/components/solidus_admin/store_credit_reasons/index/component.yml +0 -4
  73. data/app/components/solidus_admin/stores/index/component.html.erb +0 -34
  74. data/app/components/solidus_admin/stores/index/component.yml +0 -4
  75. data/app/components/solidus_admin/tax_categories/index/component.html.erb +0 -32
  76. data/app/components/solidus_admin/tax_categories/index/component.yml +0 -6
  77. data/app/components/solidus_admin/tax_rates/index/component.html.erb +0 -32
  78. data/app/components/solidus_admin/tax_rates/index/component.yml +0 -4
  79. data/app/components/solidus_admin/taxes/component.html.erb +0 -24
  80. data/app/components/solidus_admin/taxonomies/index/component.html.erb +0 -28
  81. data/app/components/solidus_admin/taxonomies/index/component.yml +0 -4
  82. data/app/components/solidus_admin/users/index/component.html.erb +0 -34
  83. data/app/components/solidus_admin/zones/index/component.html.erb +0 -35
  84. data/app/components/solidus_admin/zones/index/component.yml +0 -4
  85. /data/app/components/solidus_admin/{option_types → ui/pages}/index/component.yml +0 -0
@@ -1,22 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class SolidusAdmin::ReturnReasons::Index::Component < SolidusAdmin::BaseComponent
4
- include SolidusAdmin::Layout::PageHelpers
5
-
6
- def initialize(page:)
7
- @page = page
3
+ class SolidusAdmin::ReturnReasons::Index::Component < SolidusAdmin::RefundsAndReturns::Component
4
+ def model_class
5
+ Spree::ReturnReason
8
6
  end
9
7
 
10
- def title
11
- Spree::ReturnReason.model_name.human.pluralize
8
+ def search_url
9
+ solidus_admin.return_reasons_path
12
10
  end
13
11
 
14
- def prev_page_path
15
- solidus_admin.url_for(**request.params, page: @page.number - 1, only_path: true) unless @page.first?
12
+ def search_key
13
+ :name_cont
16
14
  end
17
15
 
18
- def next_page_path
19
- solidus_admin.url_for(**request.params, page: @page.next_param, only_path: true) unless @page.last?
16
+ def row_url(return_reason)
17
+ spree.edit_admin_return_reason_path(return_reason)
20
18
  end
21
19
 
22
20
  def batch_actions
@@ -30,14 +28,6 @@ class SolidusAdmin::ReturnReasons::Index::Component < SolidusAdmin::BaseComponen
30
28
  ]
31
29
  end
32
30
 
33
- def scopes
34
- []
35
- end
36
-
37
- def filters
38
- []
39
- end
40
-
41
31
  def columns
42
32
  [
43
33
  :name,
@@ -1,18 +1,30 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class SolidusAdmin::Shipping::Component < SolidusAdmin::BaseComponent
4
- include SolidusAdmin::Layout::PageHelpers
5
- renders_one :actions
6
-
7
- def initialize(current_class:)
8
- @current_class = current_class
3
+ class SolidusAdmin::Shipping::Component < SolidusAdmin::UI::Pages::Index::Component
4
+ def title
5
+ page_header_title safe_join([
6
+ tag.div(t(".title")),
7
+ tag.div(t(".subtitle"), class: "font-normal text-sm text-gray-500"),
8
+ ])
9
9
  end
10
10
 
11
11
  def tabs
12
- {
13
- Spree::ShippingMethod => solidus_admin.shipping_methods_path,
14
- Spree::ShippingCategory => solidus_admin.shipping_categories_path,
15
- Spree::StockLocation => solidus_admin.stock_locations_path,
16
- }
12
+ [
13
+ {
14
+ text: Spree::ShippingMethod.model_name.human.pluralize,
15
+ href: solidus_admin.shipping_methods_path,
16
+ current: model_class == Spree::ShippingMethod,
17
+ },
18
+ {
19
+ text: Spree::ShippingCategory.model_name.human.pluralize,
20
+ href: solidus_admin.shipping_categories_path,
21
+ current: model_class == Spree::ShippingCategory,
22
+ },
23
+ {
24
+ text: Spree::StockLocation.model_name.human.pluralize,
25
+ href: solidus_admin.stock_locations_path,
26
+ current: model_class == Spree::StockLocation,
27
+ },
28
+ ]
17
29
  end
18
30
  end
@@ -1,22 +1,30 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class SolidusAdmin::ShippingCategories::Index::Component < SolidusAdmin::BaseComponent
4
- include SolidusAdmin::Layout::PageHelpers
3
+ class SolidusAdmin::ShippingCategories::Index::Component < SolidusAdmin::Shipping::Component
4
+ def model_class
5
+ Spree::ShippingCategory
6
+ end
5
7
 
6
- def initialize(page:)
7
- @page = page
8
+ def actions
9
+ render component("ui/button").new(
10
+ tag: :a,
11
+ text: t('.add'),
12
+ href: spree.new_admin_shipping_category_path,
13
+ icon: "add-line",
14
+ class: "align-self-end w-full",
15
+ )
8
16
  end
9
17
 
10
- def title
11
- Spree::ShippingCategory.model_name.human.pluralize
18
+ def row_url(shipping_category)
19
+ spree.edit_admin_shipping_category_path(shipping_category)
12
20
  end
13
21
 
14
- def prev_page_path
15
- solidus_admin.url_for(**request.params, page: @page.number - 1, only_path: true) unless @page.first?
22
+ def search_key
23
+ :name_or_description_cont
16
24
  end
17
25
 
18
- def next_page_path
19
- solidus_admin.url_for(**request.params, page: @page.next_param, only_path: true) unless @page.last?
26
+ def search_url
27
+ solidus_admin.shipping_categories_path
20
28
  end
21
29
 
22
30
  def batch_actions
@@ -30,14 +38,6 @@ class SolidusAdmin::ShippingCategories::Index::Component < SolidusAdmin::BaseCom
30
38
  ]
31
39
  end
32
40
 
33
- def scopes
34
- []
35
- end
36
-
37
- def filters
38
- []
39
- end
40
-
41
41
  def columns
42
42
  [
43
43
  :name
@@ -1,22 +1,30 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class SolidusAdmin::ShippingMethods::Index::Component < SolidusAdmin::BaseComponent
4
- include SolidusAdmin::Layout::PageHelpers
3
+ class SolidusAdmin::ShippingMethods::Index::Component < SolidusAdmin::Shipping::Component
4
+ def model_class
5
+ Spree::ShippingMethod
6
+ end
5
7
 
6
- def initialize(page:)
7
- @page = page
8
+ def row_url(shipping_method)
9
+ spree.edit_admin_shipping_method_path(shipping_method)
8
10
  end
9
11
 
10
- def title
11
- Spree::ShippingMethod.model_name.human.pluralize
12
+ def search_url
13
+ solidus_admin.shipping_methods_path
12
14
  end
13
15
 
14
- def prev_page_path
15
- solidus_admin.url_for(**request.params, page: @page.number - 1, only_path: true) unless @page.first?
16
+ def search_key
17
+ :name_or_description_cont
16
18
  end
17
19
 
18
- def next_page_path
19
- solidus_admin.url_for(**request.params, page: @page.next_param, only_path: true) unless @page.last?
20
+ def actions
21
+ render component("ui/button").new(
22
+ tag: :a,
23
+ text: t('.add'),
24
+ href: spree.new_admin_shipping_method_path,
25
+ icon: "add-line",
26
+ class: "align-self-end w-full",
27
+ )
20
28
  end
21
29
 
22
30
  def batch_actions
@@ -30,14 +38,6 @@ class SolidusAdmin::ShippingMethods::Index::Component < SolidusAdmin::BaseCompon
30
38
  ]
31
39
  end
32
40
 
33
- def scopes
34
- []
35
- end
36
-
37
- def filters
38
- []
39
- end
40
-
41
41
  def columns
42
42
  [
43
43
  {
@@ -1,26 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class SolidusAdmin::StockItems::Index::Component < SolidusAdmin::BaseComponent
4
- include SolidusAdmin::Layout::PageHelpers
5
-
6
- def initialize(page:)
7
- @page = page
8
- end
9
-
10
- def title
11
- Spree::StockItem.model_name.human.pluralize
3
+ class SolidusAdmin::StockItems::Index::Component < SolidusAdmin::UI::Pages::Index::Component
4
+ def model_class
5
+ Spree::StockItem
12
6
  end
13
7
 
14
- def prev_page_path
15
- solidus_admin.url_for(**request.params, page: @page.number - 1, only_path: true) unless @page.first?
8
+ def search_key
9
+ :variant_product_name_or_variant_sku_or_variant_option_values_name_or_variant_option_values_presentation_cont
16
10
  end
17
11
 
18
- def next_page_path
19
- solidus_admin.url_for(**request.params, page: @page.next_param, only_path: true) unless @page.last?
12
+ def search_url
13
+ solidus_admin.stock_items_path
20
14
  end
21
15
 
22
- def batch_actions
23
- []
16
+ def row_url(stock_item)
17
+ solidus_admin.edit_stock_item_path(stock_item, page: params[:page], q: permitted_query_params)
24
18
  end
25
19
 
26
20
  def scopes
@@ -1,22 +1,30 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class SolidusAdmin::StockLocations::Index::Component < SolidusAdmin::BaseComponent
4
- include SolidusAdmin::Layout::PageHelpers
3
+ class SolidusAdmin::StockLocations::Index::Component < SolidusAdmin::Shipping::Component
4
+ def model_class
5
+ Spree::StockLocation
6
+ end
5
7
 
6
- def initialize(page:)
7
- @page = page
8
+ def actions
9
+ render component("ui/button").new(
10
+ tag: :a,
11
+ text: t('.add'),
12
+ href: spree.new_admin_stock_location_path,
13
+ icon: "add-line",
14
+ class: "align-self-end w-full",
15
+ )
8
16
  end
9
17
 
10
- def title
11
- Spree::StockLocation.model_name.human.pluralize
18
+ def row_url(stock_location)
19
+ spree.edit_admin_stock_location_path(stock_location)
12
20
  end
13
21
 
14
- def prev_page_path
15
- solidus_admin.url_for(**request.params, page: @page.number - 1, only_path: true) unless @page.first?
22
+ def search_url
23
+ solidus_admin.stock_locations_path
16
24
  end
17
25
 
18
- def next_page_path
19
- solidus_admin.url_for(**request.params, page: @page.next_param, only_path: true) unless @page.last?
26
+ def search_key
27
+ :name_or_description_cont
20
28
  end
21
29
 
22
30
  def batch_actions
@@ -1,6 +1,3 @@
1
1
  en:
2
2
  active: 'Active'
3
3
  inactive: 'Inactive'
4
- add: 'Add new'
5
- batch_actions:
6
- delete: 'Delete'
@@ -1,22 +1,30 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class SolidusAdmin::StoreCreditReasons::Index::Component < SolidusAdmin::BaseComponent
4
- include SolidusAdmin::Layout::PageHelpers
3
+ class SolidusAdmin::StoreCreditReasons::Index::Component < SolidusAdmin::RefundsAndReturns::Component
4
+ def model_class
5
+ Spree::StoreCreditReason
6
+ end
5
7
 
6
- def initialize(page:)
7
- @page = page
8
+ def actions
9
+ render component("ui/button").new(
10
+ tag: :a,
11
+ text: t('.add'),
12
+ href: spree.new_admin_store_credit_reason_path,
13
+ icon: "add-line",
14
+ class: "align-self-end w-full",
15
+ )
8
16
  end
9
17
 
10
- def title
11
- Spree::StoreCreditReason.model_name.human.pluralize
18
+ def row_url(store_credit_reason)
19
+ spree.edit_admin_store_credit_reason_path(store_credit_reason)
12
20
  end
13
21
 
14
- def prev_page_path
15
- solidus_admin.url_for(**request.params, page: @page.number - 1, only_path: true) unless @page.first?
22
+ def search_url
23
+ solidus_admin.store_credit_reasons_path
16
24
  end
17
25
 
18
- def next_page_path
19
- solidus_admin.url_for(**request.params, page: @page.next_param, only_path: true) unless @page.last?
26
+ def search_key
27
+ :name_cont
20
28
  end
21
29
 
22
30
  def batch_actions
@@ -30,14 +38,6 @@ class SolidusAdmin::StoreCreditReasons::Index::Component < SolidusAdmin::BaseCom
30
38
  ]
31
39
  end
32
40
 
33
- def scopes
34
- []
35
- end
36
-
37
- def filters
38
- []
39
- end
40
-
41
41
  def columns
42
42
  [
43
43
  :name,
@@ -1,22 +1,29 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class SolidusAdmin::Stores::Index::Component < SolidusAdmin::BaseComponent
4
- include SolidusAdmin::Layout::PageHelpers
3
+ class SolidusAdmin::Stores::Index::Component < SolidusAdmin::UI::Pages::Index::Component
4
+ def model_class
5
+ Spree::Store
6
+ end
5
7
 
6
- def initialize(page:)
7
- @page = page
8
+ def search_key
9
+ :name_or_url_or_code_cont
8
10
  end
9
11
 
10
- def title
11
- Spree::Store.model_name.human.pluralize
12
+ def search_url
13
+ solidus_admin.stores_path
12
14
  end
13
15
 
14
- def prev_page_path
15
- solidus_admin.url_for(**request.params, page: @page.number - 1, only_path: true) unless @page.first?
16
+ def row_url(store)
17
+ spree.edit_admin_store_path(store)
16
18
  end
17
19
 
18
- def next_page_path
19
- solidus_admin.url_for(**request.params, page: @page.next_param, only_path: true) unless @page.last?
20
+ def page_actions
21
+ render component("ui/button").new(
22
+ tag: :a,
23
+ text: t('.add'),
24
+ href: spree.new_admin_store_path,
25
+ icon: "add-line",
26
+ )
20
27
  end
21
28
 
22
29
  def batch_actions
@@ -30,14 +37,6 @@ class SolidusAdmin::Stores::Index::Component < SolidusAdmin::BaseComponent
30
37
  ]
31
38
  end
32
39
 
33
- def scopes
34
- []
35
- end
36
-
37
- def filters
38
- []
39
- end
40
-
41
40
  def columns
42
41
  [
43
42
  :name,
@@ -1,22 +1,30 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class SolidusAdmin::TaxCategories::Index::Component < SolidusAdmin::BaseComponent
4
- include SolidusAdmin::Layout::PageHelpers
3
+ class SolidusAdmin::TaxCategories::Index::Component < SolidusAdmin::Taxes::Component
4
+ def row_url(tax_category)
5
+ spree.edit_admin_tax_category_path(tax_category)
6
+ end
5
7
 
6
- def initialize(page:)
7
- @page = page
8
+ def model_class
9
+ Spree::TaxCategory
8
10
  end
9
11
 
10
- def title
11
- Spree::TaxCategory.model_name.human.pluralize
12
+ def search_url
13
+ solidus_admin.tax_categories_path
12
14
  end
13
15
 
14
- def prev_page_path
15
- solidus_admin.url_for(**request.params, page: @page.number - 1, only_path: true) unless @page.first?
16
+ def actions
17
+ render component("ui/button").new(
18
+ tag: :a,
19
+ text: t('.add'),
20
+ href: spree.new_admin_tax_category_path,
21
+ icon: "add-line",
22
+ class: "align-self-end w-full",
23
+ )
16
24
  end
17
25
 
18
- def next_page_path
19
- solidus_admin.url_for(**request.params, page: @page.next_param, only_path: true) unless @page.last?
26
+ def search_key
27
+ :name_or_description_cont
20
28
  end
21
29
 
22
30
  def batch_actions
@@ -30,14 +38,6 @@ class SolidusAdmin::TaxCategories::Index::Component < SolidusAdmin::BaseComponen
30
38
  ]
31
39
  end
32
40
 
33
- def scopes
34
- []
35
- end
36
-
37
- def filters
38
- []
39
- end
40
-
41
41
  def columns
42
42
  [
43
43
  :name,
@@ -47,9 +47,9 @@ class SolidusAdmin::TaxCategories::Index::Component < SolidusAdmin::BaseComponen
47
47
  header: :is_default,
48
48
  data: ->(tax_category) {
49
49
  if tax_category.is_default?
50
- component('ui/badge').new(name: t('.yes'), color: :green)
50
+ component('ui/badge').yes
51
51
  else
52
- component('ui/badge').new(name: t('.no'), color: :graphite_light)
52
+ component('ui/badge').no
53
53
  end
54
54
  },
55
55
  },
@@ -1,22 +1,30 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class SolidusAdmin::TaxRates::Index::Component < SolidusAdmin::BaseComponent
4
- include SolidusAdmin::Layout::PageHelpers
3
+ class SolidusAdmin::TaxRates::Index::Component < SolidusAdmin::Taxes::Component
4
+ def row_url(tax_rate)
5
+ spree.edit_admin_tax_rate_path(tax_rate)
6
+ end
5
7
 
6
- def initialize(page:)
7
- @page = page
8
+ def model_class
9
+ Spree::TaxRate
8
10
  end
9
11
 
10
- def title
11
- Spree::TaxRate.model_name.human.pluralize
12
+ def search_url
13
+ solidus_admin.tax_rates_path
12
14
  end
13
15
 
14
- def prev_page_path
15
- solidus_admin.url_for(**request.params, page: @page.number - 1, only_path: true) unless @page.first?
16
+ def actions
17
+ render component("ui/button").new(
18
+ tag: :a,
19
+ text: t('.add'),
20
+ href: spree.new_admin_tax_rate_path,
21
+ icon: "add-line",
22
+ class: "align-self-end w-full",
23
+ )
16
24
  end
17
25
 
18
- def next_page_path
19
- solidus_admin.url_for(**request.params, page: @page.next_param, only_path: true) unless @page.last?
26
+ def search_key
27
+ :name_or_description_cont
20
28
  end
21
29
 
22
30
  def batch_actions
@@ -30,10 +38,6 @@ class SolidusAdmin::TaxRates::Index::Component < SolidusAdmin::BaseComponent
30
38
  ]
31
39
  end
32
40
 
33
- def scopes
34
- []
35
- end
36
-
37
41
  def filters
38
42
  [
39
43
  {
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class SolidusAdmin::Taxes::Component < SolidusAdmin::BaseComponent
4
- include SolidusAdmin::Layout::PageHelpers
5
- renders_one :actions
6
-
7
- def initialize(model_class:)
8
- @model_class = model_class
3
+ class SolidusAdmin::Taxes::Component < SolidusAdmin::UI::Pages::Index::Component
4
+ def title
5
+ safe_join([
6
+ tag.div(t(".title")),
7
+ tag.div(t(".subtitle"), class: "font-normal text-sm text-gray-500"),
8
+ ])
9
9
  end
10
10
 
11
11
  def tabs
@@ -13,12 +13,12 @@ class SolidusAdmin::Taxes::Component < SolidusAdmin::BaseComponent
13
13
  {
14
14
  text: Spree::TaxCategory.model_name.human.pluralize,
15
15
  href: solidus_admin.tax_categories_path,
16
- "aria-current": @model_class == Spree::TaxCategory,
16
+ current: model_class == Spree::TaxCategory,
17
17
  },
18
18
  {
19
19
  text: Spree::TaxRate.model_name.human.pluralize,
20
20
  href: solidus_admin.tax_rates_path,
21
- "aria-current": @model_class == Spree::TaxRate,
21
+ current: model_class == Spree::TaxRate,
22
22
  },
23
23
  ]
24
24
  end
@@ -1,22 +1,28 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class SolidusAdmin::Taxonomies::Index::Component < SolidusAdmin::BaseComponent
4
- include SolidusAdmin::Layout::PageHelpers
5
-
6
- def initialize(page:)
7
- @page = page
3
+ class SolidusAdmin::Taxonomies::Index::Component < SolidusAdmin::UI::Pages::Index::Component
4
+ def model_class
5
+ Spree::Taxonomy
8
6
  end
9
7
 
10
- def title
11
- Spree::Taxonomy.model_name.human.pluralize
8
+ def row_url(taxonomy)
9
+ spree.edit_admin_taxonomy_path(taxonomy)
12
10
  end
13
11
 
14
- def prev_page_path
15
- solidus_admin.url_for(**request.params, page: @page.number - 1, only_path: true) unless @page.first?
12
+ def sortable_options
13
+ {
14
+ url: ->(taxonomy) { solidus_admin.move_taxonomy_path(taxonomy) },
15
+ param: 'position',
16
+ }
16
17
  end
17
18
 
18
- def next_page_path
19
- solidus_admin.url_for(**request.params, page: @page.next_param, only_path: true) unless @page.last?
19
+ def page_actions
20
+ render component("ui/button").new(
21
+ tag: :a,
22
+ text: t('.add'),
23
+ href: spree.new_admin_taxonomy_path,
24
+ icon: "add-line",
25
+ )
20
26
  end
21
27
 
22
28
  def batch_actions
@@ -0,0 +1,30 @@
1
+ <%= page do %>
2
+ <% if @tabs %>
3
+ <%= page_header do %>
4
+ <%= page_header_title title %>
5
+ <% end %>
6
+
7
+ <%= page_header do %>
8
+ <% rendered_tabs = capture do %>
9
+ <% @tabs.each do %>
10
+ <%= render(component("ui/button").new(tag: :a, scheme: :ghost, text: _1.text, 'aria-current': _1.current, href: _1.href)) %>
11
+ <% end %>
12
+ <% end %>
13
+ <%= page_header_title rendered_tabs %>
14
+ <%= page_header_actions do %>
15
+ <%= page_actions %>
16
+ <% end %>
17
+ <% end %>
18
+
19
+ <% else %>
20
+ <%= page_header do %>
21
+ <%= page_header_title title %>
22
+
23
+ <%= page_header_actions do %>
24
+ <%= page_actions %>
25
+ <% end %>
26
+ <% end %>
27
+ <% end %>
28
+
29
+ <%= render_table %>
30
+ <% end %>