solidus_admin 0.3.1 → 0.4.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 (140) hide show
  1. checksums.yaml +4 -4
  2. data/.prettierrc +4 -0
  3. data/app/assets/builds/solidus_admin/tailwind.css +164 -132
  4. data/app/components/solidus_admin/adjustment_reasons/edit/component.html.erb +2 -3
  5. data/app/components/solidus_admin/adjustment_reasons/edit/component.rb +1 -9
  6. data/app/components/solidus_admin/adjustment_reasons/index/component.rb +22 -8
  7. data/app/components/solidus_admin/adjustment_reasons/new/component.html.erb +2 -4
  8. data/app/components/solidus_admin/adjustment_reasons/new/component.rb +1 -9
  9. data/app/components/solidus_admin/base_component.rb +7 -9
  10. data/app/components/solidus_admin/layout/navigation/account/component.rb +2 -2
  11. data/app/components/solidus_admin/layout/navigation/component.js +1 -1
  12. data/app/components/solidus_admin/layout/navigation/component.rb +1 -1
  13. data/app/components/solidus_admin/layout/navigation/item/component.html.erb +2 -2
  14. data/app/components/solidus_admin/layout/navigation/item/component.rb +3 -6
  15. data/app/components/solidus_admin/orders/index/component.rb +3 -3
  16. data/app/components/solidus_admin/orders/show/address/component.js +2 -2
  17. data/app/components/solidus_admin/orders/show/adjustments/index/adjustable/component.rb +1 -1
  18. data/app/components/solidus_admin/orders/show/adjustments/index/source/component.rb +1 -1
  19. data/app/components/solidus_admin/orders/show/component.js +2 -2
  20. data/app/components/solidus_admin/orders/show/customer_search/component.js +5 -4
  21. data/app/components/solidus_admin/orders/show/summary/component.html.erb +6 -6
  22. data/app/components/solidus_admin/products/show/component.html.erb +7 -1
  23. data/app/components/solidus_admin/products/show/component.rb +6 -0
  24. data/app/components/solidus_admin/products/status/component.rb +1 -1
  25. data/app/components/solidus_admin/properties/edit/component.html.erb +16 -0
  26. data/app/components/solidus_admin/properties/edit/component.rb +4 -0
  27. data/app/components/solidus_admin/properties/edit/component.yml +4 -0
  28. data/app/components/solidus_admin/properties/index/component.rb +19 -6
  29. data/app/components/solidus_admin/properties/new/component.html.erb +16 -0
  30. data/app/components/solidus_admin/properties/new/component.rb +4 -0
  31. data/app/components/solidus_admin/properties/new/component.yml +4 -0
  32. data/app/components/solidus_admin/refund_reasons/edit/component.html.erb +2 -3
  33. data/app/components/solidus_admin/refund_reasons/edit/component.rb +1 -9
  34. data/app/components/solidus_admin/refund_reasons/index/component.rb +22 -8
  35. data/app/components/solidus_admin/refund_reasons/new/component.html.erb +2 -4
  36. data/app/components/solidus_admin/refund_reasons/new/component.rb +1 -9
  37. data/app/components/solidus_admin/resources/base_component.rb +20 -0
  38. data/app/components/solidus_admin/resources/edit/component.rb +11 -0
  39. data/app/components/solidus_admin/resources/new/component.rb +11 -0
  40. data/app/components/solidus_admin/return_reasons/edit/component.html.erb +2 -3
  41. data/app/components/solidus_admin/return_reasons/edit/component.rb +1 -9
  42. data/app/components/solidus_admin/return_reasons/index/component.rb +13 -7
  43. data/app/components/solidus_admin/return_reasons/new/component.html.erb +2 -4
  44. data/app/components/solidus_admin/return_reasons/new/component.rb +1 -9
  45. data/app/components/solidus_admin/roles/edit/component.html.erb +2 -4
  46. data/app/components/solidus_admin/roles/edit/component.rb +1 -10
  47. data/app/components/solidus_admin/roles/index/component.rb +16 -8
  48. data/app/components/solidus_admin/roles/new/component.html.erb +2 -4
  49. data/app/components/solidus_admin/roles/new/component.rb +1 -10
  50. data/app/components/solidus_admin/shipping_categories/edit/component.html.erb +2 -3
  51. data/app/components/solidus_admin/shipping_categories/edit/component.rb +1 -9
  52. data/app/components/solidus_admin/shipping_categories/index/component.rb +14 -17
  53. data/app/components/solidus_admin/shipping_categories/new/component.html.erb +2 -4
  54. data/app/components/solidus_admin/shipping_categories/new/component.rb +1 -9
  55. data/app/components/solidus_admin/stock_items/edit/component.html.erb +74 -73
  56. data/app/components/solidus_admin/stock_items/edit/component.js +4 -3
  57. data/app/components/solidus_admin/stock_items/edit/component.rb +1 -10
  58. data/app/components/solidus_admin/stock_items/index/component.rb +10 -6
  59. data/app/components/solidus_admin/stock_locations/index/component.rb +2 -2
  60. data/app/components/solidus_admin/store_credit_reasons/edit/component.html.erb +2 -3
  61. data/app/components/solidus_admin/store_credit_reasons/edit/component.rb +1 -9
  62. data/app/components/solidus_admin/store_credit_reasons/index/component.rb +14 -7
  63. data/app/components/solidus_admin/store_credit_reasons/new/component.html.erb +2 -4
  64. data/app/components/solidus_admin/store_credit_reasons/new/component.rb +1 -9
  65. data/app/components/solidus_admin/tax_categories/edit/component.html.erb +2 -4
  66. data/app/components/solidus_admin/tax_categories/edit/component.rb +1 -9
  67. data/app/components/solidus_admin/tax_categories/index/component.rb +30 -9
  68. data/app/components/solidus_admin/tax_categories/new/component.html.erb +2 -4
  69. data/app/components/solidus_admin/tax_categories/new/component.rb +1 -9
  70. data/app/components/solidus_admin/ui/dropdown/component.js +3 -3
  71. data/app/components/solidus_admin/ui/forms/address/component.js +5 -6
  72. data/app/components/solidus_admin/ui/forms/field/component.rb +18 -18
  73. data/app/components/solidus_admin/ui/forms/input/component.js +3 -4
  74. data/app/components/solidus_admin/ui/forms/input/component.rb +15 -4
  75. data/app/components/solidus_admin/ui/icon/component.rb +3 -1
  76. data/app/components/solidus_admin/ui/modal/component.js +2 -2
  77. data/app/components/solidus_admin/ui/pages/index/component.html.erb +3 -3
  78. data/app/components/solidus_admin/ui/pages/index/component.rb +11 -6
  79. data/app/components/solidus_admin/ui/table/component.html.erb +4 -3
  80. data/app/components/solidus_admin/ui/table/component.js +13 -17
  81. data/app/components/solidus_admin/ui/table/component.rb +1 -1
  82. data/app/components/solidus_admin/ui/table/ransack_filter/component.js +18 -16
  83. data/app/components/solidus_admin/ui/thumbnail_with_caption/component.rb +1 -1
  84. data/app/components/solidus_admin/ui/toast/component.html.erb +1 -1
  85. data/app/components/solidus_admin/ui/toast/component.js +3 -3
  86. data/app/components/solidus_admin/ui/toggletip/component.js +14 -12
  87. data/app/components/solidus_admin/users/index/component.rb +1 -1
  88. data/app/components/solidus_admin/users/orders/component.rb +1 -1
  89. data/app/components/solidus_admin/users/store_credits/edit_amount/component.html.erb +22 -0
  90. data/app/components/solidus_admin/users/store_credits/edit_amount/component.rb +22 -0
  91. data/app/components/solidus_admin/users/store_credits/edit_amount/component.yml +5 -0
  92. data/app/components/solidus_admin/users/store_credits/edit_memo/component.html.erb +15 -0
  93. data/app/components/solidus_admin/users/store_credits/edit_memo/component.rb +16 -0
  94. data/app/components/solidus_admin/users/store_credits/edit_memo/component.yml +4 -0
  95. data/app/components/solidus_admin/users/store_credits/edit_validity/component.html.erb +21 -0
  96. data/app/components/solidus_admin/users/store_credits/edit_validity/component.rb +22 -0
  97. data/app/components/solidus_admin/users/store_credits/edit_validity/component.yml +5 -0
  98. data/app/components/solidus_admin/users/store_credits/index/component.html.erb +65 -0
  99. data/app/components/solidus_admin/users/store_credits/index/component.rb +114 -0
  100. data/app/components/solidus_admin/users/store_credits/index/component.yml +12 -0
  101. data/app/components/solidus_admin/users/store_credits/new/component.html.erb +30 -0
  102. data/app/components/solidus_admin/users/store_credits/new/component.rb +22 -0
  103. data/app/components/solidus_admin/users/store_credits/new/component.yml +5 -0
  104. data/app/components/solidus_admin/users/store_credits/show/component.html.erb +83 -0
  105. data/app/components/solidus_admin/users/store_credits/show/component.rb +120 -0
  106. data/app/components/solidus_admin/users/store_credits/show/component.yml +18 -0
  107. data/app/controllers/solidus_admin/adjustment_reasons_controller.rb +3 -105
  108. data/app/controllers/solidus_admin/authentication_adapters/backend.rb +1 -1
  109. data/app/controllers/solidus_admin/base_controller.rb +12 -1
  110. data/app/controllers/solidus_admin/controller_helpers/search.rb +4 -4
  111. data/app/controllers/solidus_admin/properties_controller.rb +6 -24
  112. data/app/controllers/solidus_admin/refund_reasons_controller.rb +5 -105
  113. data/app/controllers/solidus_admin/resources_controller.rb +152 -0
  114. data/app/controllers/solidus_admin/return_reasons_controller.rb +4 -104
  115. data/app/controllers/solidus_admin/roles_controller.rb +3 -105
  116. data/app/controllers/solidus_admin/shipping_categories_controller.rb +3 -107
  117. data/app/controllers/solidus_admin/stock_items_controller.rb +12 -29
  118. data/app/controllers/solidus_admin/store_credit_reasons_controller.rb +5 -105
  119. data/app/controllers/solidus_admin/store_credits_controller.rb +231 -0
  120. data/app/controllers/solidus_admin/tax_categories_controller.rb +3 -109
  121. data/app/helpers/solidus_admin/void_elements_helper.rb +13 -0
  122. data/app/views/layouts/solidus_admin/application.html.erb +3 -0
  123. data/config/locales/menu_item.en.yml +0 -1
  124. data/config/locales/properties.en.yml +4 -0
  125. data/config/locales/store_credits.en.yml +16 -0
  126. data/config/routes.rb +12 -1
  127. data/lib/generators/solidus_admin/install/install_generator.rb +2 -0
  128. data/lib/solidus_admin/component_registry.rb +1 -1
  129. data/lib/solidus_admin/configuration.rb +3 -8
  130. data/lib/solidus_admin/engine.rb +6 -0
  131. data/lib/solidus_admin/install_tailwindcss.rb +1 -1
  132. data/lib/solidus_admin/testing_support/component_helpers.rb +3 -9
  133. data/lib/solidus_admin/testing_support/feature_helpers.rb +1 -1
  134. data/lib/solidus_admin/testing_support/shared_examples/bulk_delete_resources.rb +20 -0
  135. data/lib/solidus_admin/testing_support/shared_examples/crud_resource_requests.rb +138 -0
  136. data/lib/solidus_admin/testing_support/shared_examples/promotion_categories_features.rb +72 -0
  137. data/lib/solidus_admin/version.rb +1 -1
  138. data/solidus_admin.gemspec +2 -2
  139. metadata +39 -8
  140. data/bin/rails +0 -13
@@ -1,6 +1,6 @@
1
- <%= turbo_frame_tag :edit_adjustment_reason_modal do %>
1
+ <%= turbo_frame_tag :resource_modal, target: "_top" do %>
2
2
  <%= render component("ui/modal").new(title: t(".title")) do |modal| %>
3
- <%= form_for @adjustment_reason, url: solidus_admin.adjustment_reason_path(@adjustment_reason), html: { id: form_id } do |f| %>
3
+ <%= form_for @adjustment_reason, url: form_url, html: { id: form_id } do |f| %>
4
4
  <div class="flex flex-col gap-6 pb-4">
5
5
  <%= render component("ui/forms/field").text_field(f, :name, class: "required") %>
6
6
  <%= render component("ui/forms/field").text_field(f, :code, class: "required") %>
@@ -24,4 +24,3 @@
24
24
  <% end %>
25
25
  <% end %>
26
26
  <% end %>
27
- <%= render component("adjustment_reasons/index").new(page: @page) %>
@@ -1,12 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class SolidusAdmin::AdjustmentReasons::Edit::Component < SolidusAdmin::BaseComponent
4
- def initialize(page:, adjustment_reason:)
5
- @page = page
6
- @adjustment_reason = adjustment_reason
7
- end
8
-
9
- def form_id
10
- dom_id(@adjustment_reason, "#{stimulus_id}_edit_adjustment_reason_form")
11
- end
3
+ class SolidusAdmin::AdjustmentReasons::Edit::Component < SolidusAdmin::Resources::Edit::Component
12
4
  end
@@ -17,7 +17,8 @@ class SolidusAdmin::AdjustmentReasons::Index::Component < SolidusAdmin::RefundsA
17
17
  render component("ui/button").new(
18
18
  tag: :a,
19
19
  text: t('.add'),
20
- href: solidus_admin.new_adjustment_reason_path, data: { turbo_frame: :new_adjustment_reason_modal },
20
+ href: solidus_admin.new_adjustment_reason_path(**search_filter_params),
21
+ data: { turbo_frame: :resource_modal },
21
22
  icon: "add-line",
22
23
  class: "align-self-end w-full",
23
24
  )
@@ -25,20 +26,19 @@ class SolidusAdmin::AdjustmentReasons::Index::Component < SolidusAdmin::RefundsA
25
26
 
26
27
  def turbo_frames
27
28
  %w[
28
- new_adjustment_reason_modal
29
- edit_adjustment_reason_modal
29
+ resource_modal
30
30
  ]
31
31
  end
32
32
 
33
- def row_url(adjustment_reason)
34
- spree.edit_admin_adjustment_reason_path(adjustment_reason, _turbo_frame: :edit_adjustment_reason_modal)
33
+ def edit_path(adjustment_reason)
34
+ spree.edit_admin_adjustment_reason_path(adjustment_reason, **search_filter_params)
35
35
  end
36
36
 
37
37
  def batch_actions
38
38
  [
39
39
  {
40
40
  label: t('.batch_actions.delete'),
41
- action: solidus_admin.adjustment_reasons_path,
41
+ action: solidus_admin.adjustment_reasons_path(**search_filter_params),
42
42
  method: :delete,
43
43
  icon: 'delete-bin-7-line',
44
44
  },
@@ -47,8 +47,22 @@ class SolidusAdmin::AdjustmentReasons::Index::Component < SolidusAdmin::RefundsA
47
47
 
48
48
  def columns
49
49
  [
50
- :name,
51
- :code,
50
+ {
51
+ header: :name,
52
+ data: ->(adjustment_reason) do
53
+ link_to adjustment_reason.name, edit_path(adjustment_reason),
54
+ class: 'body-link',
55
+ data: { turbo_frame: :resource_modal }
56
+ end
57
+ },
58
+ {
59
+ header: :code,
60
+ data: ->(adjustment_reason) do
61
+ link_to adjustment_reason.code, edit_path(adjustment_reason),
62
+ class: 'body-link',
63
+ data: { turbo_frame: :resource_modal }
64
+ end
65
+ },
52
66
  {
53
67
  header: :active,
54
68
  data: ->(adjustment_reason) do
@@ -1,6 +1,6 @@
1
- <%= turbo_frame_tag :new_adjustment_reason_modal do %>
1
+ <%= turbo_frame_tag :resource_modal, target: "_top" do %>
2
2
  <%= render component("ui/modal").new(title: t(".title")) do |modal| %>
3
- <%= form_for @adjustment_reason, url: solidus_admin.adjustment_reasons_path, html: { id: form_id } do |f| %>
3
+ <%= form_for @adjustment_reason, url: form_url, html: { id: form_id } do |f| %>
4
4
  <div class="flex flex-col gap-6 pb-4">
5
5
  <%= render component("ui/forms/field").text_field(f, :name, class: "required") %>
6
6
  <%= render component("ui/forms/field").text_field(f, :code, class: "required") %>
@@ -24,5 +24,3 @@
24
24
  <% end %>
25
25
  <% end %>
26
26
  <% end %>
27
-
28
- <%= render component("adjustment_reasons/index").new(page: @page) %>
@@ -1,12 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class SolidusAdmin::AdjustmentReasons::New::Component < SolidusAdmin::BaseComponent
4
- def initialize(page:, adjustment_reason:)
5
- @page = page
6
- @adjustment_reason = adjustment_reason
7
- end
8
-
9
- def form_id
10
- dom_id(@adjustment_reason, "#{stimulus_id}_new_adjustment_reason_form")
11
- end
3
+ class SolidusAdmin::AdjustmentReasons::New::Component < SolidusAdmin::Resources::New::Component
12
4
  end
@@ -7,10 +7,11 @@ module SolidusAdmin
7
7
  # BaseComponent is the base class for all components in Solidus Admin.
8
8
  class BaseComponent < ViewComponent::Base
9
9
  include SolidusAdmin::ComponentsHelper
10
+ include SolidusAdmin::VoidElementsHelper
10
11
  include Turbo::FramesHelper
11
12
 
12
13
  def icon_tag(name, **attrs)
13
- render component("ui/icon").new(name: name, **attrs)
14
+ render component("ui/icon").new(name:, **attrs)
14
15
  end
15
16
 
16
17
  def missing_translation(key, options)
@@ -25,6 +26,10 @@ module SolidusAdmin
25
26
  end
26
27
  end
27
28
 
29
+ def self.i18n_scope
30
+ @i18n_scope ||= name.underscore.tr("/", ".")
31
+ end
32
+
28
33
  def self.stimulus_id
29
34
  @stimulus_id ||= name.underscore
30
35
  .sub(/^solidus_admin\/(.*)\/component$/, '\1')
@@ -33,13 +38,6 @@ module SolidusAdmin
33
38
  end
34
39
 
35
40
  delegate :stimulus_id, to: :class
36
-
37
- def spree
38
- @spree ||= Spree::Core::Engine.routes.url_helpers
39
- end
40
-
41
- def solidus_admin
42
- @solidus_admin ||= SolidusAdmin::Engine.routes.url_helpers
43
- end
41
+ delegate :search_filter_params, to: :helpers
44
42
  end
45
43
  end
@@ -11,7 +11,7 @@ class SolidusAdmin::Layout::Navigation::Account::Component < SolidusAdmin::BaseC
11
11
  def locale_options_for_select(available_locales)
12
12
  available_locales.map do |locale|
13
13
  [
14
- t("spree.i18n.this_file_language", locale: locale, default: locale.to_s, fallback: false),
14
+ t("spree.i18n.this_file_language", locale:, default: locale.to_s, fallback: false),
15
15
  locale,
16
16
  ]
17
17
  end.sort
@@ -27,7 +27,7 @@ class SolidusAdmin::Layout::Navigation::Account::Component < SolidusAdmin::BaseC
27
27
  block_given? ? capture(&block) : nil,
28
28
  tag.label(safe_join([
29
29
  icon_tag(icon, class: "w-full max-w-[20px] h-5 fill-current shrink"),
30
- tag.select(options, name: name, onchange: "this.form.requestSubmit()", class: "w-full appearance-none grow bg-transparent outline-none"),
30
+ tag.select(options, name:, onchange: "this.form.requestSubmit()", class: "w-full appearance-none grow bg-transparent outline-none"),
31
31
  icon_tag("expand-up-down-line", class: "w-full max-w-[20px] h-5 fill-current shrink"),
32
32
  ]), class: "flex gap-2 items-center px-2"),
33
33
  ])
@@ -2,7 +2,7 @@ import { Controller } from "@hotwired/stimulus"
2
2
 
3
3
  export default class extends Controller {
4
4
  static values = {
5
- cookie: String
5
+ cookie: String,
6
6
  }
7
7
 
8
8
  setCookie(event) {
@@ -9,7 +9,7 @@ class SolidusAdmin::Layout::Navigation::Component < SolidusAdmin::BaseComponent
9
9
  @logo_path = logo_path
10
10
  @items = items.map do |attrs|
11
11
  children = attrs[:children].to_a.map { SolidusAdmin::MenuItem.new(**_1, top_level: false) }
12
- SolidusAdmin::MenuItem.new(**attrs, children: children, top_level: true)
12
+ SolidusAdmin::MenuItem.new(**attrs, children:, top_level: true)
13
13
  end
14
14
  @store = store
15
15
  end
@@ -1,7 +1,7 @@
1
1
  <li class="group <%= "active" if active? %>">
2
2
  <a
3
3
  href="<%= path %>"
4
- aria-current="<%= @item.current?(@url_helpers, @fullpath) ? "page" : "false" %>"
4
+ aria-current="<%= @item.current?(self, @fullpath) ? "page" : "false" %>"
5
5
  class="
6
6
  flex gap-3 items-center
7
7
  py-1 px-3 rounded
@@ -20,7 +20,7 @@
20
20
 
21
21
  <% if @item.children? %>
22
22
  <ul class="flex flex-col gap-0.5 pt-0.5 <%= "hidden" unless active? %>">
23
- <%= render self.class.with_collection(@item.children, url_helpers: @url_helpers, fullpath: @fullpath) %>
23
+ <%= render self.class.with_collection(@item.children, fullpath: @fullpath) %>
24
24
  </ul>
25
25
  <% end %>
26
26
  </li>
@@ -6,22 +6,19 @@ class SolidusAdmin::Layout::Navigation::Item::Component < SolidusAdmin::BaseComp
6
6
 
7
7
  # @param item [SolidusAdmin::MenuItem]
8
8
  # @param fullpath [String] the current path
9
- # @param url_helpers [#solidus_admin, #spree] context for generating paths
10
9
  def initialize(
11
10
  item:,
12
- fullpath: "#",
13
- url_helpers: Struct.new(:spree, :solidus_admin).new(spree, solidus_admin)
11
+ fullpath: "#"
14
12
  )
15
13
  @item = item
16
- @url_helpers = url_helpers
17
14
  @fullpath = fullpath
18
15
  end
19
16
 
20
17
  def path
21
- @item.path(@url_helpers)
18
+ @item.path(self)
22
19
  end
23
20
 
24
21
  def active?
25
- @item.active?(@url_helpers, @fullpath)
22
+ @item.active?(self, @fullpath)
26
23
  end
27
24
  end
@@ -124,7 +124,7 @@ class SolidusAdmin::Orders::Index::Component < SolidusAdmin::UI::Pages::Index::C
124
124
  'canceled' => :blue,
125
125
  'cart' => :graphite_light,
126
126
  }[order.state] || :yellow
127
- component('ui/badge').new(name: order.state.humanize, color: color)
127
+ component('ui/badge').new(name: order.state.humanize, color:)
128
128
  end
129
129
  }
130
130
  end
@@ -143,7 +143,7 @@ class SolidusAdmin::Orders::Index::Component < SolidusAdmin::UI::Pages::Index::C
143
143
  col: { class: "w-[400px]" },
144
144
  header: :customer,
145
145
  data: ->(order) do
146
- customer_email = order.user&.email
146
+ customer_email = order.email
147
147
  content_tag :div, String(customer_email)
148
148
  end
149
149
  }
@@ -153,7 +153,7 @@ class SolidusAdmin::Orders::Index::Component < SolidusAdmin::UI::Pages::Index::C
153
153
  {
154
154
  header: :total,
155
155
  data: ->(order) do
156
- content_tag :div, number_to_currency(order.total)
156
+ content_tag :div, order.display_total
157
157
  end
158
158
  }
159
159
  end
@@ -1,9 +1,9 @@
1
- import { Controller } from '@hotwired/stimulus'
1
+ import { Controller } from "@hotwired/stimulus"
2
2
 
3
3
  export default class extends Controller {
4
4
  static targets = ["addresses"]
5
5
 
6
6
  close() {
7
- this.addressesTarget.removeAttribute('open')
7
+ this.addressesTarget.removeAttribute("open")
8
8
  }
9
9
  }
@@ -10,7 +10,7 @@ class SolidusAdmin::Orders::Show::Adjustments::Index::Adjustable::Component < So
10
10
  end
11
11
 
12
12
  def call
13
- render component("ui/thumbnail_with_caption").new(caption: caption, detail: detail) do
13
+ render component("ui/thumbnail_with_caption").new(caption:, detail:) do
14
14
  thumbnail
15
15
  end
16
16
  end
@@ -10,7 +10,7 @@ class SolidusAdmin::Orders::Show::Adjustments::Index::Source::Component < Solidu
10
10
  end
11
11
 
12
12
  def call
13
- render component("ui/thumbnail_with_caption").new(icon: icon, caption: caption, detail: detail)
13
+ render component("ui/thumbnail_with_caption").new(icon:, caption:, detail:)
14
14
  end
15
15
 
16
16
  def caption
@@ -1,7 +1,7 @@
1
- import { Controller } from '@hotwired/stimulus'
1
+ import { Controller } from "@hotwired/stimulus"
2
2
 
3
3
  export default class extends Controller {
4
4
  closeMenus() {
5
- this.element.querySelectorAll('details').forEach(details => details.removeAttribute('open'))
5
+ this.element.querySelectorAll("details").forEach((details) => details.removeAttribute("open"))
6
6
  }
7
7
  }
@@ -1,14 +1,15 @@
1
- import { Controller } from '@hotwired/stimulus'
1
+ import { Controller } from "@hotwired/stimulus"
2
2
 
3
3
  export default class extends Controller {
4
4
  static values = { customersUrl: String }
5
5
 
6
6
  async search({ detail: { query, controller } }) {
7
- controller.resultsValue =
8
- (await (await fetch(`${this.customersUrlValue}?q[name_or_variants_including_master_sku_cont]=${query}`)).text())
7
+ controller.resultsValue = await (
8
+ await fetch(`${this.customersUrlValue}?q[name_or_variants_including_master_sku_cont]=${query}`)
9
+ ).text()
9
10
  }
10
11
 
11
12
  submit(event) {
12
- event.detail.resultTarget.querySelector('form').submit()
13
+ event.detail.resultTarget.querySelector("form").submit()
13
14
  }
14
15
  }
@@ -2,12 +2,12 @@
2
2
  <%= render component('ui/panel').new(title: t('.summary')) do %>
3
3
  <%= render component('ui/details_list').new(
4
4
  items: [
5
- { label: t('.subtotal'), value: number_to_currency(@order.item_total), class: 'font-semibold' },
6
- { label: t('.taxes'), value: number_to_currency(@order.additional_tax_total) },
7
- { label: t('.shipping'), value: number_to_currency(@order.shipment_total) },
8
- { label: link_to(t('.add_promo_code'), '#', class: "body-link"), value: number_to_currency(@order.promo_total) },
9
- { label: link_to(t('.adjustments'), solidus_admin.order_adjustments_path(@order), class: "body-link"), value: number_to_currency(@order.adjustment_total) },
10
- { label: t('.total'), value: number_to_currency(@order.total), class: 'font-semibold' }
5
+ { label: t('.subtotal'), value: @order.display_item_total, class: 'font-semibold' },
6
+ { label: t('.taxes'), value: @order.display_additional_tax_total },
7
+ { label: t('.shipping'), value: @order.display_shipment_total },
8
+ { label: link_to(t('.add_promo_code'), '#', class: "body-link"), value: @order.display_promo_total },
9
+ { label: link_to(t('.adjustments'), solidus_admin.order_adjustments_path(@order), class: "body-link"), value: @order.display_adjustment_total },
10
+ { label: t('.total'), value: @order.display_total, class: 'font-semibold' }
11
11
  ]
12
12
  ) %>
13
13
  <% end %>
@@ -36,8 +36,14 @@
36
36
  <%= render component("ui/forms/field").text_field(f, :meta_title) %>
37
37
  <%= render component("ui/forms/field").text_field(f, :meta_description) %>
38
38
  <%= render component("ui/forms/field").text_area(f, :meta_keywords) %>
39
+ <%= render component("ui/forms/field").text_field(f, :gtin) %>
40
+ <%= render component("ui/forms/field").select(
41
+ f,
42
+ :condition,
43
+ condition_options,
44
+ include_blank: t('spree.unset'),
45
+ ) %>
39
46
  <% end %>
40
-
41
47
  <%= render component('ui/panel').new(title: "Media") do |panel| %>
42
48
  <% panel.with_action(
43
49
  name: t(".manage_images"),
@@ -25,4 +25,10 @@ class SolidusAdmin::Products::Show::Component < SolidusAdmin::BaseComponent
25
25
  ["#{_1} (#{_2})", _3]
26
26
  end
27
27
  end
28
+
29
+ def condition_options
30
+ @condition_options ||= Spree::Variant.conditions.map do |key, value|
31
+ [t("spree.condition.#{key}"), value]
32
+ end
33
+ end
28
34
  end
@@ -20,7 +20,7 @@ class SolidusAdmin::Products::Status::Component < SolidusAdmin::BaseComponent
20
20
  :unavailable
21
21
  end
22
22
 
23
- new(status: status)
23
+ new(status:)
24
24
  end
25
25
 
26
26
  def initialize(status:)
@@ -0,0 +1,16 @@
1
+ <%= turbo_frame_tag :resource_modal, target: "_top" do %>
2
+ <%= render component("ui/modal").new(title: t(".title")) do |modal| %>
3
+ <%= form_for @property, url: form_url, html: { id: form_id } do |f| %>
4
+ <div class="flex flex-col gap-6 pb-4">
5
+ <%= render component("ui/forms/field").text_field(f, :name, class: "required") %>
6
+ <%= render component("ui/forms/field").text_field(f, :presentation, class: "required") %>
7
+ </div>
8
+ <% modal.with_actions do %>
9
+ <form method="dialog">
10
+ <%= render component("ui/button").new(scheme: :secondary, text: t('.cancel')) %>
11
+ </form>
12
+ <%= render component("ui/button").new(form: form_id, type: :submit, text: t('.submit')) %>
13
+ <% end %>
14
+ <% end %>
15
+ <% end %>
16
+ <% end %>
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ class SolidusAdmin::Properties::Edit::Component < SolidusAdmin::Resources::Edit::Component
4
+ end
@@ -0,0 +1,4 @@
1
+ en:
2
+ title: "Edit Property"
3
+ cancel: "Cancel"
4
+ submit: "Update Property"
@@ -5,6 +5,10 @@ class SolidusAdmin::Properties::Index::Component < SolidusAdmin::UI::Pages::Inde
5
5
  Spree::Property
6
6
  end
7
7
 
8
+ def title
9
+ t('solidus_admin.properties.title')
10
+ end
11
+
8
12
  def search_key
9
13
  :name_cont
10
14
  end
@@ -13,15 +17,20 @@ class SolidusAdmin::Properties::Index::Component < SolidusAdmin::UI::Pages::Inde
13
17
  solidus_admin.properties_path
14
18
  end
15
19
 
16
- def row_url(property)
17
- spree.admin_property_path(property)
20
+ def edit_path(property)
21
+ solidus_admin.edit_property_path(property, **search_filter_params)
22
+ end
23
+
24
+ def turbo_frames
25
+ %w[resource_modal]
18
26
  end
19
27
 
20
28
  def page_actions
21
29
  render component("ui/button").new(
22
30
  tag: :a,
23
31
  text: t('.add'),
24
- href: spree.new_admin_property_path,
32
+ href: solidus_admin.new_property_path(**search_filter_params),
33
+ data: { turbo_frame: :resource_modal },
25
34
  icon: "add-line",
26
35
  )
27
36
  end
@@ -30,7 +39,7 @@ class SolidusAdmin::Properties::Index::Component < SolidusAdmin::UI::Pages::Inde
30
39
  [
31
40
  {
32
41
  label: t('.batch_actions.delete'),
33
- action: solidus_admin.properties_path,
42
+ action: solidus_admin.properties_path(**search_filter_params),
34
43
  method: :delete,
35
44
  icon: 'delete-bin-7-line',
36
45
  },
@@ -48,7 +57,9 @@ class SolidusAdmin::Properties::Index::Component < SolidusAdmin::UI::Pages::Inde
48
57
  {
49
58
  header: :name,
50
59
  data: ->(property) do
51
- content_tag :div, property.name
60
+ link_to property.name, edit_path(property),
61
+ data: { turbo_frame: :resource_modal },
62
+ class: 'body-link'
52
63
  end
53
64
  }
54
65
  end
@@ -57,7 +68,9 @@ class SolidusAdmin::Properties::Index::Component < SolidusAdmin::UI::Pages::Inde
57
68
  {
58
69
  header: :presentation,
59
70
  data: ->(property) do
60
- content_tag :div, property.presentation
71
+ link_to property.presentation, edit_path(property),
72
+ data: { turbo_frame: :resource_modal },
73
+ class: 'body-link'
61
74
  end
62
75
  }
63
76
  end
@@ -0,0 +1,16 @@
1
+ <%= turbo_frame_tag :resource_modal, target: "_top" do %>
2
+ <%= render component("ui/modal").new(title: t(".title")) do |modal| %>
3
+ <%= form_for @property, url: form_url, html: { id: form_id } do |f| %>
4
+ <div class="flex flex-col gap-6 pb-4">
5
+ <%= render component("ui/forms/field").text_field(f, :name, class: "required") %>
6
+ <%= render component("ui/forms/field").text_field(f, :presentation, class: "required") %>
7
+ </div>
8
+ <% modal.with_actions do %>
9
+ <form method="dialog">
10
+ <%= render component("ui/button").new(scheme: :secondary, text: t('.cancel')) %>
11
+ </form>
12
+ <%= render component("ui/button").new(form: form_id, type: :submit, text: t('.submit')) %>
13
+ <% end %>
14
+ <% end %>
15
+ <% end %>
16
+ <% end %>
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ class SolidusAdmin::Properties::New::Component < SolidusAdmin::Resources::New::Component
4
+ end
@@ -0,0 +1,4 @@
1
+ en:
2
+ title: "New Property"
3
+ cancel: "Cancel"
4
+ submit: "Add Property"
@@ -1,6 +1,6 @@
1
- <%= turbo_frame_tag :edit_refund_reason_modal do %>
1
+ <%= turbo_frame_tag :resource_modal, target: "_top" do %>
2
2
  <%= render component("ui/modal").new(title: t(".title")) do |modal| %>
3
- <%= form_for @refund_reason, url: solidus_admin.refund_reason_path(@refund_reason), html: { id: form_id } do |f| %>
3
+ <%= form_for @refund_reason, url: form_url, html: { id: form_id } do |f| %>
4
4
  <div class="flex flex-col gap-6 pb-4">
5
5
  <%= render component("ui/forms/field").text_field(f, :name, class: "required") %>
6
6
  <%= render component("ui/forms/field").text_field(f, :code, class: "required") %>
@@ -24,4 +24,3 @@
24
24
  <% end %>
25
25
  <% end %>
26
26
  <% end %>
27
- <%= render component("refund_reasons/index").new(page: @page) %>
@@ -1,12 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class SolidusAdmin::RefundReasons::Edit::Component < SolidusAdmin::BaseComponent
4
- def initialize(page:, refund_reason:)
5
- @page = page
6
- @refund_reason = refund_reason
7
- end
8
-
9
- def form_id
10
- dom_id(@refund_reason, "#{stimulus_id}_edit_refund_reason_form")
11
- end
3
+ class SolidusAdmin::RefundReasons::Edit::Component < SolidusAdmin::Resources::Edit::Component
12
4
  end
@@ -13,14 +13,13 @@ class SolidusAdmin::RefundReasons::Index::Component < SolidusAdmin::RefundsAndRe
13
13
  :name_or_code_cont
14
14
  end
15
15
 
16
- def row_url(refund_reason)
17
- spree.edit_admin_refund_reason_path(refund_reason, _turbo_frame: :edit_refund_reason_modal)
16
+ def edit_path(refund_reason)
17
+ spree.edit_admin_refund_reason_path(refund_reason, **search_filter_params)
18
18
  end
19
19
 
20
20
  def turbo_frames
21
21
  %w[
22
- new_refund_reason_modal
23
- edit_refund_reason_modal
22
+ resource_modal
24
23
  ]
25
24
  end
26
25
 
@@ -28,7 +27,8 @@ class SolidusAdmin::RefundReasons::Index::Component < SolidusAdmin::RefundsAndRe
28
27
  render component("ui/button").new(
29
28
  tag: :a,
30
29
  text: t('.add'),
31
- href: solidus_admin.new_refund_reason_path, data: { turbo_frame: :new_refund_reason_modal },
30
+ href: solidus_admin.new_refund_reason_path(**search_filter_params),
31
+ data: { turbo_frame: :resource_modal },
32
32
  icon: "add-line",
33
33
  class: "align-self-end w-full",
34
34
  )
@@ -38,7 +38,7 @@ class SolidusAdmin::RefundReasons::Index::Component < SolidusAdmin::RefundsAndRe
38
38
  [
39
39
  {
40
40
  label: t('.batch_actions.delete'),
41
- action: solidus_admin.refund_reasons_path,
41
+ action: solidus_admin.refund_reasons_path(**search_filter_params),
42
42
  method: :delete,
43
43
  icon: 'delete-bin-7-line',
44
44
  },
@@ -47,8 +47,22 @@ class SolidusAdmin::RefundReasons::Index::Component < SolidusAdmin::RefundsAndRe
47
47
 
48
48
  def columns
49
49
  [
50
- :name,
51
- :code,
50
+ {
51
+ header: :name,
52
+ data: ->(refund_reason) do
53
+ link_to refund_reason.name, edit_path(refund_reason),
54
+ data: { turbo_frame: :resource_modal },
55
+ class: 'body-link'
56
+ end
57
+ },
58
+ {
59
+ header: :code,
60
+ data: ->(refund_reason) do
61
+ link_to_if refund_reason.code, refund_reason.code, edit_path(refund_reason),
62
+ data: { turbo_frame: :resource_modal },
63
+ class: 'body-link'
64
+ end
65
+ },
52
66
  {
53
67
  header: :active,
54
68
  data: ->(refund_reason) do
@@ -1,6 +1,6 @@
1
- <%= turbo_frame_tag :new_refund_reason_modal do %>
1
+ <%= turbo_frame_tag :resource_modal, target: "_top" do %>
2
2
  <%= render component("ui/modal").new(title: t(".title")) do |modal| %>
3
- <%= form_for @refund_reason, url: solidus_admin.refund_reasons_path, html: { id: form_id } do |f| %>
3
+ <%= form_for @refund_reason, url: form_url, html: { id: form_id } do |f| %>
4
4
  <div class="flex flex-col gap-6 pb-4">
5
5
  <%= render component("ui/forms/field").text_field(f, :name, class: "required") %>
6
6
  <%= render component("ui/forms/field").text_field(f, :code, class: "required") %>
@@ -23,5 +23,3 @@
23
23
  <% end %>
24
24
  <% end %>
25
25
  <% end %>
26
-
27
- <%= render component("refund_reasons/index").new(page: @page) %>
@@ -1,12 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class SolidusAdmin::RefundReasons::New::Component < SolidusAdmin::BaseComponent
4
- def initialize(page:, refund_reason:)
5
- @page = page
6
- @refund_reason = refund_reason
7
- end
8
-
9
- def form_id
10
- dom_id(@refund_reason, "#{stimulus_id}_new_refund_reason_form")
11
- end
3
+ class SolidusAdmin::RefundReasons::New::Component < SolidusAdmin::Resources::New::Component
12
4
  end