diff --git a/admin/app/components/solidus_admin/adjustment_reasons/index/component.rb b/admin/app/components/solidus_admin/adjustment_reasons/index/component.rb
index a7ae5b6b6db..520007d4a0b 100644
--- a/admin/app/components/solidus_admin/adjustment_reasons/index/component.rb
+++ b/admin/app/components/solidus_admin/adjustment_reasons/index/component.rb
@@ -18,7 +18,7 @@ def page_actions
tag: :a,
text: t('.add'),
href: solidus_admin.new_adjustment_reason_path(**search_filter_params),
- data: { turbo_frame: :resource_modal },
+ data: { turbo_frame: :resource_form },
icon: "add-line",
class: "align-self-end w-full",
)
@@ -26,7 +26,7 @@ def page_actions
def turbo_frames
%w[
- resource_modal
+ resource_form
]
end
@@ -52,7 +52,7 @@ def columns
data: ->(adjustment_reason) do
link_to adjustment_reason.name, edit_path(adjustment_reason),
class: 'body-link',
- data: { turbo_frame: :resource_modal }
+ data: { turbo_frame: :resource_form }
end
},
{
@@ -60,7 +60,7 @@ def columns
data: ->(adjustment_reason) do
link_to adjustment_reason.code, edit_path(adjustment_reason),
class: 'body-link',
- data: { turbo_frame: :resource_modal }
+ data: { turbo_frame: :resource_form }
end
},
{
diff --git a/admin/app/components/solidus_admin/adjustment_reasons/new/component.html.erb b/admin/app/components/solidus_admin/adjustment_reasons/new/component.html.erb
index 8cc79b783f2..f1bd76aeb54 100644
--- a/admin/app/components/solidus_admin/adjustment_reasons/new/component.html.erb
+++ b/admin/app/components/solidus_admin/adjustment_reasons/new/component.html.erb
@@ -1,4 +1,4 @@
-<%= turbo_frame_tag :resource_modal, target: "_top" do %>
+<%= turbo_frame_tag :resource_form, target: "_top" do %>
<%= render component("ui/modal").new(title: t(".title")) do |modal| %>
<%= form_for @adjustment_reason, url: form_url, html: { id: form_id } do |f| %>
diff --git a/admin/app/components/solidus_admin/layout/flashes/component.html.erb b/admin/app/components/solidus_admin/layout/flashes/component.html.erb
new file mode 100644
index 00000000000..b909471733f
--- /dev/null
+++ b/admin/app/components/solidus_admin/layout/flashes/component.html.erb
@@ -0,0 +1,5 @@
+
+ <% flash.each do |key, message| %>
+ <%= render component("ui/toast").new(text: message, scheme: key.to_sym == :error ? :error : :default) %>
+ <% end %>
+
diff --git a/admin/app/components/solidus_admin/layout/flashes/component.rb b/admin/app/components/solidus_admin/layout/flashes/component.rb
new file mode 100644
index 00000000000..1105b1405fb
--- /dev/null
+++ b/admin/app/components/solidus_admin/layout/flashes/component.rb
@@ -0,0 +1,4 @@
+# frozen_string_literal: true
+
+class SolidusAdmin::Layout::Flashes::Component < SolidusAdmin::BaseComponent
+end
diff --git a/admin/app/components/solidus_admin/option_types/edit/component.html.erb b/admin/app/components/solidus_admin/option_types/edit/component.html.erb
new file mode 100644
index 00000000000..a2ef821ac09
--- /dev/null
+++ b/admin/app/components/solidus_admin/option_types/edit/component.html.erb
@@ -0,0 +1,44 @@
+<%= turbo_frame_tag :resource_form, target: "_top" do %>
+ <%= page do %>
+ <%= page_header do %>
+ <%= page_header_back(back_url) %>
+ <%= page_header_title(t('.title')) %>
+ <%= page_header_actions do %>
+ <%= render component("ui/button").new(text: t(".save"),form: form_id) %>
+ <% end %>
+ <% end %>
+
+
+ <%= form_for @option_type, url: form_url, html: { id: form_id } do |f| %>
+ <%= render component("ui/panel").new(title: t(".panels.option_type.title")) do |panel| %>
+ <% panel.with_section(class: "flex flex-col gap-4") do %>
+
+ <%= render component("ui/forms/field").text_field(f, :name, class: "required") %>
+ <%= render component("ui/forms/field").text_field(f, :presentation, class: "required") %>
+
+ <% end %>
+ <% end %>
+ <% end %>
+
+ <%= render component("ui/panel").new(title: t(".panels.option_values.title")) do |panel| %>
+ <% panel.with_section(wide: true, high: true, class: "flex flex-col gap-4") do %>
+
+ <%= render component("option_values/table").new(@option_type) %>
+
+ <% end %>
+
+ <% panel.with_action(
+ name: t(".panels.option_values.add"),
+ href: solidus_admin.new_option_type_option_value_path(@option_type),
+ data: { turbo_frame: :option_value_modal }
+ ) %>
+ <% end %>
+
+ <%= page_footer do %>
+ <%= render component("ui/button").new(text: t(".save"), form: form_id) %>
+ <% end %>
+
+
+ <%= turbo_frame_tag :option_value_modal, target: "_top" %>
+ <% end %>
+<% end %>
diff --git a/admin/app/components/solidus_admin/option_types/edit/component.rb b/admin/app/components/solidus_admin/option_types/edit/component.rb
new file mode 100644
index 00000000000..ec40c3e2fd0
--- /dev/null
+++ b/admin/app/components/solidus_admin/option_types/edit/component.rb
@@ -0,0 +1,5 @@
+# frozen_string_literal: true
+
+class SolidusAdmin::OptionTypes::Edit::Component < SolidusAdmin::Resources::Edit::Component
+ include SolidusAdmin::Layout::PageHelpers
+end
diff --git a/admin/app/components/solidus_admin/option_types/edit/component.yml b/admin/app/components/solidus_admin/option_types/edit/component.yml
new file mode 100644
index 00000000000..108d8f6fa7f
--- /dev/null
+++ b/admin/app/components/solidus_admin/option_types/edit/component.yml
@@ -0,0 +1,10 @@
+en:
+ back: "Back"
+ panels:
+ option_type:
+ title: "Option Type"
+ option_values:
+ title: "Option Values"
+ add: "Add new"
+ save: "Save"
+ title: "Edit Option Type"
diff --git a/admin/app/components/solidus_admin/option_types/index/component.rb b/admin/app/components/solidus_admin/option_types/index/component.rb
index 288931a0fd2..86993d22df1 100644
--- a/admin/app/components/solidus_admin/option_types/index/component.rb
+++ b/admin/app/components/solidus_admin/option_types/index/component.rb
@@ -12,11 +12,16 @@ def sortable_options
}
end
+ def turbo_frames
+ %w[resource_form]
+ end
+
def page_actions
render component("ui/button").new(
tag: :a,
text: t('.add'),
- href: spree.new_admin_option_type_path,
+ href: solidus_admin.new_option_type_path,
+ data: { turbo_frame: :resource_form },
icon: "add-line",
)
end
@@ -36,6 +41,7 @@ def batch_actions
action: solidus_admin.option_types_path,
method: :delete,
icon: 'delete-bin-7-line',
+ require_confirmation: true,
},
]
end
@@ -60,11 +66,14 @@ def name_column
def presentation_column
{
header: :presentation,
- data: ->(option_type) { option_type.presentation }
+ data: ->(option_type) do
+ link_to option_type.presentation, edit_path(option_type),
+ class: 'body-link'
+ end
}
end
def edit_path(option_type)
- spree.edit_admin_option_type_path(option_type)
+ solidus_admin.edit_option_type_path(option_type)
end
end
diff --git a/admin/app/components/solidus_admin/option_types/new/component.html.erb b/admin/app/components/solidus_admin/option_types/new/component.html.erb
new file mode 100644
index 00000000000..6e4dacb5b89
--- /dev/null
+++ b/admin/app/components/solidus_admin/option_types/new/component.html.erb
@@ -0,0 +1,16 @@
+<%= turbo_frame_tag :resource_form, target: "_top" do %>
+ <%= render component("ui/modal").new(title: t(".title")) do |modal| %>
+ <%= form_for @option_type, url: form_url, html: { id: form_id } do |f| %>
+
+ <%= render component("ui/forms/field").text_field(f, :name, class: "required") %>
+ <%= render component("ui/forms/field").text_field(f, :presentation, class: "required") %>
+
+ <% modal.with_actions do %>
+
+ <%= render component("ui/button").new(form: form_id, type: :submit, text: t('.submit')) %>
+ <% end %>
+ <% end %>
+ <% end %>
+<% end %>
diff --git a/admin/app/components/solidus_admin/option_types/new/component.rb b/admin/app/components/solidus_admin/option_types/new/component.rb
new file mode 100644
index 00000000000..fc791bdebc2
--- /dev/null
+++ b/admin/app/components/solidus_admin/option_types/new/component.rb
@@ -0,0 +1,4 @@
+# frozen_string_literal: true
+
+class SolidusAdmin::OptionTypes::New::Component < SolidusAdmin::Resources::New::Component
+end
diff --git a/admin/app/components/solidus_admin/option_types/new/component.yml b/admin/app/components/solidus_admin/option_types/new/component.yml
new file mode 100644
index 00000000000..6b233d44a0c
--- /dev/null
+++ b/admin/app/components/solidus_admin/option_types/new/component.yml
@@ -0,0 +1,4 @@
+en:
+ title: "New Option Type"
+ cancel: "Cancel"
+ submit: "Add Option Type"
diff --git a/admin/app/components/solidus_admin/option_values/edit/component.html.erb b/admin/app/components/solidus_admin/option_values/edit/component.html.erb
new file mode 100644
index 00000000000..90d343ce8a1
--- /dev/null
+++ b/admin/app/components/solidus_admin/option_values/edit/component.html.erb
@@ -0,0 +1,16 @@
+<%= turbo_frame_tag :option_value_modal, target: "_top" do %>
+ <%= render component("ui/modal").new(title: t(".title")) do |modal| %>
+ <%= form_for @option_value, url: form_url, html: { id: form_id } do |f| %>
+
+ <%= render component("ui/forms/field").text_field(f, :name, class: "required") %>
+ <%= render component("ui/forms/field").text_field(f, :presentation, class: "required") %>
+
+ <% modal.with_actions do %>
+
+ <%= render component("ui/button").new(form: form_id, type: :submit, text: t('.submit')) %>
+ <% end %>
+ <% end %>
+ <% end %>
+<% end %>
diff --git a/admin/app/components/solidus_admin/option_values/edit/component.rb b/admin/app/components/solidus_admin/option_values/edit/component.rb
new file mode 100644
index 00000000000..3dd3368e98a
--- /dev/null
+++ b/admin/app/components/solidus_admin/option_values/edit/component.rb
@@ -0,0 +1,4 @@
+# frozen_string_literal: true
+
+class SolidusAdmin::OptionValues::Edit::Component < SolidusAdmin::Resources::Edit::Component
+end
diff --git a/admin/app/components/solidus_admin/option_values/edit/component.yml b/admin/app/components/solidus_admin/option_values/edit/component.yml
new file mode 100644
index 00000000000..399dfe74216
--- /dev/null
+++ b/admin/app/components/solidus_admin/option_values/edit/component.yml
@@ -0,0 +1,4 @@
+en:
+ title: "Edit Option Value"
+ cancel: "Cancel"
+ submit: "Update Option Value"
diff --git a/admin/app/components/solidus_admin/option_values/new/component.html.erb b/admin/app/components/solidus_admin/option_values/new/component.html.erb
new file mode 100644
index 00000000000..90d343ce8a1
--- /dev/null
+++ b/admin/app/components/solidus_admin/option_values/new/component.html.erb
@@ -0,0 +1,16 @@
+<%= turbo_frame_tag :option_value_modal, target: "_top" do %>
+ <%= render component("ui/modal").new(title: t(".title")) do |modal| %>
+ <%= form_for @option_value, url: form_url, html: { id: form_id } do |f| %>
+
+ <%= render component("ui/forms/field").text_field(f, :name, class: "required") %>
+ <%= render component("ui/forms/field").text_field(f, :presentation, class: "required") %>
+
+ <% modal.with_actions do %>
+
+ <%= render component("ui/button").new(form: form_id, type: :submit, text: t('.submit')) %>
+ <% end %>
+ <% end %>
+ <% end %>
+<% end %>
diff --git a/admin/app/components/solidus_admin/option_values/new/component.rb b/admin/app/components/solidus_admin/option_values/new/component.rb
new file mode 100644
index 00000000000..9d48574c110
--- /dev/null
+++ b/admin/app/components/solidus_admin/option_values/new/component.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class SolidusAdmin::OptionValues::New::Component < SolidusAdmin::Resources::New::Component
+ def form_url
+ solidus_admin.option_type_option_values_path(@option_value.option_type)
+ end
+end
diff --git a/admin/app/components/solidus_admin/option_values/new/component.yml b/admin/app/components/solidus_admin/option_values/new/component.yml
new file mode 100644
index 00000000000..11043a335d2
--- /dev/null
+++ b/admin/app/components/solidus_admin/option_values/new/component.yml
@@ -0,0 +1,4 @@
+en:
+ title: "New Option Value"
+ cancel: "Cancel"
+ submit: "Add Option Value"
diff --git a/admin/app/components/solidus_admin/option_values/table/component.rb b/admin/app/components/solidus_admin/option_values/table/component.rb
new file mode 100644
index 00000000000..0380d187671
--- /dev/null
+++ b/admin/app/components/solidus_admin/option_values/table/component.rb
@@ -0,0 +1,53 @@
+# frozen_string_literal: true
+
+class SolidusAdmin::OptionValues::Table::Component < SolidusAdmin::BaseComponent
+ def initialize(option_type)
+ @option_type = option_type
+ end
+
+ def call
+ render component("ui/table").new(
+ id: stimulus_id,
+ data: {
+ class: Spree::OptionValue,
+ rows: @option_type.option_values,
+ columns: option_value_columns,
+ batch_actions: [
+ {
+ label: t('.batch_actions.delete'),
+ action: solidus_admin.option_type_option_values_path(@option_type),
+ method: :delete,
+ icon: 'delete-bin-7-line',
+ require_confirmation: true,
+ },
+ ]
+ },
+ sortable: {
+ url: ->(option_value) { solidus_admin.move_option_value_path(option_value) },
+ param: "position",
+ },
+ embedded: true,
+ )
+ end
+
+ def option_value_columns
+ [
+ {
+ header: :name,
+ data: ->(option_value) do
+ link_to option_value.name, solidus_admin.edit_option_value_path(option_value),
+ class: 'body-link',
+ data: { turbo_frame: :option_value_modal }
+ end
+ },
+ {
+ header: :presentation,
+ data: ->(option_value) do
+ link_to option_value.presentation, solidus_admin.edit_option_value_path(option_value),
+ class: 'body-link',
+ data: { turbo_frame: :option_value_modal }
+ end
+ },
+ ]
+ end
+end
diff --git a/admin/app/components/solidus_admin/option_values/table/component.yml b/admin/app/components/solidus_admin/option_values/table/component.yml
new file mode 100644
index 00000000000..d6429972d90
--- /dev/null
+++ b/admin/app/components/solidus_admin/option_values/table/component.yml
@@ -0,0 +1,3 @@
+en:
+ batch_actions:
+ delete: "Delete"
diff --git a/admin/app/components/solidus_admin/properties/edit/component.html.erb b/admin/app/components/solidus_admin/properties/edit/component.html.erb
index b2a90586684..cf56ae99a60 100644
--- a/admin/app/components/solidus_admin/properties/edit/component.html.erb
+++ b/admin/app/components/solidus_admin/properties/edit/component.html.erb
@@ -1,4 +1,4 @@
-<%= turbo_frame_tag :resource_modal, target: "_top" do %>
+<%= turbo_frame_tag :resource_form, target: "_top" do %>
<%= render component("ui/modal").new(title: t(".title")) do |modal| %>
<%= form_for @property, url: form_url, html: { id: form_id } do |f| %>
diff --git a/admin/app/components/solidus_admin/properties/index/component.rb b/admin/app/components/solidus_admin/properties/index/component.rb
index 9782ba2e624..e902f80aa16 100644
--- a/admin/app/components/solidus_admin/properties/index/component.rb
+++ b/admin/app/components/solidus_admin/properties/index/component.rb
@@ -22,7 +22,7 @@ def edit_path(property)
end
def turbo_frames
- %w[resource_modal]
+ %w[resource_form]
end
def page_actions
@@ -30,7 +30,7 @@ def page_actions
tag: :a,
text: t('.add'),
href: solidus_admin.new_property_path(**search_filter_params),
- data: { turbo_frame: :resource_modal },
+ data: { turbo_frame: :resource_form },
icon: "add-line",
)
end
@@ -58,7 +58,7 @@ def name_column
header: :name,
data: ->(property) do
link_to property.name, edit_path(property),
- data: { turbo_frame: :resource_modal },
+ data: { turbo_frame: :resource_form },
class: 'body-link'
end
}
@@ -69,7 +69,7 @@ def presentation_column
header: :presentation,
data: ->(property) do
link_to property.presentation, edit_path(property),
- data: { turbo_frame: :resource_modal },
+ data: { turbo_frame: :resource_form },
class: 'body-link'
end
}
diff --git a/admin/app/components/solidus_admin/properties/new/component.html.erb b/admin/app/components/solidus_admin/properties/new/component.html.erb
index b2a90586684..cf56ae99a60 100644
--- a/admin/app/components/solidus_admin/properties/new/component.html.erb
+++ b/admin/app/components/solidus_admin/properties/new/component.html.erb
@@ -1,4 +1,4 @@
-<%= turbo_frame_tag :resource_modal, target: "_top" do %>
+<%= turbo_frame_tag :resource_form, target: "_top" do %>
<%= render component("ui/modal").new(title: t(".title")) do |modal| %>
<%= form_for @property, url: form_url, html: { id: form_id } do |f| %>
diff --git a/admin/app/components/solidus_admin/refund_reasons/edit/component.html.erb b/admin/app/components/solidus_admin/refund_reasons/edit/component.html.erb
index 630f10dfd16..e66db8f069c 100644
--- a/admin/app/components/solidus_admin/refund_reasons/edit/component.html.erb
+++ b/admin/app/components/solidus_admin/refund_reasons/edit/component.html.erb
@@ -1,4 +1,4 @@
-<%= turbo_frame_tag :resource_modal, target: "_top" do %>
+<%= turbo_frame_tag :resource_form, target: "_top" do %>
<%= render component("ui/modal").new(title: t(".title")) do |modal| %>
<%= form_for @refund_reason, url: form_url, html: { id: form_id } do |f| %>
diff --git a/admin/app/components/solidus_admin/refund_reasons/index/component.rb b/admin/app/components/solidus_admin/refund_reasons/index/component.rb
index 62d4f6b9d06..01c4046fd0a 100644
--- a/admin/app/components/solidus_admin/refund_reasons/index/component.rb
+++ b/admin/app/components/solidus_admin/refund_reasons/index/component.rb
@@ -19,7 +19,7 @@ def edit_path(refund_reason)
def turbo_frames
%w[
- resource_modal
+ resource_form
]
end
@@ -28,7 +28,7 @@ def page_actions
tag: :a,
text: t('.add'),
href: solidus_admin.new_refund_reason_path(**search_filter_params),
- data: { turbo_frame: :resource_modal },
+ data: { turbo_frame: :resource_form },
icon: "add-line",
class: "align-self-end w-full",
)
@@ -51,7 +51,7 @@ def columns
header: :name,
data: ->(refund_reason) do
link_to refund_reason.name, edit_path(refund_reason),
- data: { turbo_frame: :resource_modal },
+ data: { turbo_frame: :resource_form },
class: 'body-link'
end
},
@@ -59,7 +59,7 @@ def columns
header: :code,
data: ->(refund_reason) do
link_to_if refund_reason.code, refund_reason.code, edit_path(refund_reason),
- data: { turbo_frame: :resource_modal },
+ data: { turbo_frame: :resource_form },
class: 'body-link'
end
},
diff --git a/admin/app/components/solidus_admin/refund_reasons/new/component.html.erb b/admin/app/components/solidus_admin/refund_reasons/new/component.html.erb
index 72a6b996d7c..85482d1dec2 100644
--- a/admin/app/components/solidus_admin/refund_reasons/new/component.html.erb
+++ b/admin/app/components/solidus_admin/refund_reasons/new/component.html.erb
@@ -1,4 +1,4 @@
-<%= turbo_frame_tag :resource_modal, target: "_top" do %>
+<%= turbo_frame_tag :resource_form, target: "_top" do %>
<%= render component("ui/modal").new(title: t(".title")) do |modal| %>
<%= form_for @refund_reason, url: form_url, html: { id: form_id } do |f| %>
diff --git a/admin/app/components/solidus_admin/return_reasons/edit/component.html.erb b/admin/app/components/solidus_admin/return_reasons/edit/component.html.erb
index e1c6af09dc0..ade96525347 100644
--- a/admin/app/components/solidus_admin/return_reasons/edit/component.html.erb
+++ b/admin/app/components/solidus_admin/return_reasons/edit/component.html.erb
@@ -1,4 +1,4 @@
-<%= turbo_frame_tag :resource_modal, target: "_top" do %>
+<%= turbo_frame_tag :resource_form, target: "_top" do %>
<%= render component("ui/modal").new(title: t(".title")) do |modal| %>
<%= form_for @return_reason, url: form_url, html: { id: form_id } do |f| %>
diff --git a/admin/app/components/solidus_admin/return_reasons/index/component.rb b/admin/app/components/solidus_admin/return_reasons/index/component.rb
index 594eac21696..e8fb147dd7a 100644
--- a/admin/app/components/solidus_admin/return_reasons/index/component.rb
+++ b/admin/app/components/solidus_admin/return_reasons/index/component.rb
@@ -19,7 +19,7 @@ def edit_path(return_reason)
def turbo_frames
%w[
- resource_modal
+ resource_form
]
end
@@ -28,7 +28,7 @@ def page_actions
tag: :a,
text: t('.add'),
href: solidus_admin.new_return_reason_path(**search_filter_params),
- data: { turbo_frame: :resource_modal },
+ data: { turbo_frame: :resource_form },
icon: "add-line",
class: "align-self-end w-full",
)
@@ -51,7 +51,7 @@ def columns
header: :name,
data: ->(return_reason) do
link_to return_reason.name, edit_path(return_reason),
- data: { turbo_frame: :resource_modal },
+ data: { turbo_frame: :resource_form },
class: 'body-link'
end
},
diff --git a/admin/app/components/solidus_admin/return_reasons/new/component.html.erb b/admin/app/components/solidus_admin/return_reasons/new/component.html.erb
index e1c6af09dc0..ade96525347 100644
--- a/admin/app/components/solidus_admin/return_reasons/new/component.html.erb
+++ b/admin/app/components/solidus_admin/return_reasons/new/component.html.erb
@@ -1,4 +1,4 @@
-<%= turbo_frame_tag :resource_modal, target: "_top" do %>
+<%= turbo_frame_tag :resource_form, target: "_top" do %>
<%= render component("ui/modal").new(title: t(".title")) do |modal| %>
<%= form_for @return_reason, url: form_url, html: { id: form_id } do |f| %>
diff --git a/admin/app/components/solidus_admin/roles/edit/component.html.erb b/admin/app/components/solidus_admin/roles/edit/component.html.erb
index ff14e0363df..481132339aa 100644
--- a/admin/app/components/solidus_admin/roles/edit/component.html.erb
+++ b/admin/app/components/solidus_admin/roles/edit/component.html.erb
@@ -1,4 +1,4 @@
-<%= turbo_frame_tag :resource_modal, target: "_top" do %>
+<%= turbo_frame_tag :resource_form, target: "_top" do %>
<%= render component("ui/modal").new(title: t(".title")) do |modal| %>
<%= form_for @role, url: form_url, html: { id: form_id } do |f| %>
diff --git a/admin/app/components/solidus_admin/roles/index/component.rb b/admin/app/components/solidus_admin/roles/index/component.rb
index 97ce166278a..4a8f513301e 100644
--- a/admin/app/components/solidus_admin/roles/index/component.rb
+++ b/admin/app/components/solidus_admin/roles/index/component.rb
@@ -22,14 +22,14 @@ def page_actions
tag: :a,
text: t('.add'),
href: solidus_admin.new_role_path(**search_filter_params),
- data: { turbo_frame: :resource_modal },
+ data: { turbo_frame: :resource_form },
icon: "add-line",
)
end
def turbo_frames
%w[
- resource_modal
+ resource_form
]
end
@@ -61,7 +61,7 @@ def columns
header: :role,
data: ->(role) do
link_to role.name, edit_path(role),
- data: { turbo_frame: :resource_modal },
+ data: { turbo_frame: :resource_form },
class: "body-link"
end,
},
@@ -69,7 +69,7 @@ def columns
header: :description,
data: ->(role) do
link_to_if role.description, role.description, edit_path(role),
- data: { turbo_frame: :resource_modal },
+ data: { turbo_frame: :resource_form },
class: "body-link"
end
}
diff --git a/admin/app/components/solidus_admin/roles/new/component.html.erb b/admin/app/components/solidus_admin/roles/new/component.html.erb
index 3216408ea58..a921f2e2d27 100644
--- a/admin/app/components/solidus_admin/roles/new/component.html.erb
+++ b/admin/app/components/solidus_admin/roles/new/component.html.erb
@@ -1,4 +1,4 @@
-<%= turbo_frame_tag :resource_modal, target: "_top" do %>
+<%= turbo_frame_tag :resource_form, target: "_top" do %>
<%= render component("ui/modal").new(title: t(".title")) do |modal| %>
<%= form_for @role, url: form_url, html: { id: form_id } do |f| %>
diff --git a/admin/app/components/solidus_admin/shipping_categories/edit/component.html.erb b/admin/app/components/solidus_admin/shipping_categories/edit/component.html.erb
index b3e1b61981a..69b2ee08f8e 100644
--- a/admin/app/components/solidus_admin/shipping_categories/edit/component.html.erb
+++ b/admin/app/components/solidus_admin/shipping_categories/edit/component.html.erb
@@ -1,4 +1,4 @@
-<%= turbo_frame_tag :resource_modal, target: "_top" do %>
+<%= turbo_frame_tag :resource_form, target: "_top" do %>
<%= render component("ui/modal").new(title: t(".title")) do |modal| %>
<%= form_for @shipping_category, url: form_url, html: { id: form_id } do |f| %>
diff --git a/admin/app/components/solidus_admin/shipping_categories/index/component.rb b/admin/app/components/solidus_admin/shipping_categories/index/component.rb
index 2302b16417e..2c303296914 100644
--- a/admin/app/components/solidus_admin/shipping_categories/index/component.rb
+++ b/admin/app/components/solidus_admin/shipping_categories/index/component.rb
@@ -10,7 +10,7 @@ def page_actions
tag: :a,
text: t('.add'),
href: solidus_admin.new_shipping_category_path(**search_filter_params),
- data: { turbo_frame: :resource_modal },
+ data: { turbo_frame: :resource_form },
icon: "add-line",
class: "align-self-end w-full",
)
@@ -18,7 +18,7 @@ def page_actions
def turbo_frames
%w[
- resource_modal
+ resource_form
]
end
@@ -51,7 +51,7 @@ def columns
header: :name,
data: ->(shipping_category) do
link_to shipping_category.name, edit_url(shipping_category),
- data: { turbo_frame: :resource_modal },
+ data: { turbo_frame: :resource_form },
class: "body-link"
end
},
diff --git a/admin/app/components/solidus_admin/shipping_categories/new/component.html.erb b/admin/app/components/solidus_admin/shipping_categories/new/component.html.erb
index b3e1b61981a..69b2ee08f8e 100644
--- a/admin/app/components/solidus_admin/shipping_categories/new/component.html.erb
+++ b/admin/app/components/solidus_admin/shipping_categories/new/component.html.erb
@@ -1,4 +1,4 @@
-<%= turbo_frame_tag :resource_modal, target: "_top" do %>
+<%= turbo_frame_tag :resource_form, target: "_top" do %>
<%= render component("ui/modal").new(title: t(".title")) do |modal| %>
<%= form_for @shipping_category, url: form_url, html: { id: form_id } do |f| %>
diff --git a/admin/app/components/solidus_admin/stock_items/edit/component.html.erb b/admin/app/components/solidus_admin/stock_items/edit/component.html.erb
index a0faf887296..c6d9725b49f 100644
--- a/admin/app/components/solidus_admin/stock_items/edit/component.html.erb
+++ b/admin/app/components/solidus_admin/stock_items/edit/component.html.erb
@@ -1,4 +1,4 @@
-<%= turbo_frame_tag :resource_modal, target: "_top" do %>
+<%= turbo_frame_tag :resource_form, target: "_top" do %>
<%= render component("ui/modal").new(title: t(".title")) do |modal| %>
<%= form_for @stock_item, url: form_url, html: { id: form_id } do |f| %>
(stock_item) do
link_to stock_item.variant.name, edit_path(stock_item),
- data: { turbo_frame: :resource_modal },
+ data: { turbo_frame: :resource_form },
class: 'body-link'
end
}
@@ -102,7 +102,7 @@ def sku_column
header: :sku,
data: ->(stock_item) do
link_to stock_item.variant.sku, edit_path(stock_item),
- data: { turbo_frame: :resource_modal },
+ data: { turbo_frame: :resource_form },
class: 'body-link'
end
}
@@ -172,6 +172,6 @@ def count_on_hand_column
end
def turbo_frames
- %w[resource_modal]
+ %w[resource_form]
end
end
diff --git a/admin/app/components/solidus_admin/store_credit_reasons/edit/component.html.erb b/admin/app/components/solidus_admin/store_credit_reasons/edit/component.html.erb
index 432322ba69a..db080fb6831 100644
--- a/admin/app/components/solidus_admin/store_credit_reasons/edit/component.html.erb
+++ b/admin/app/components/solidus_admin/store_credit_reasons/edit/component.html.erb
@@ -1,4 +1,4 @@
-<%= turbo_frame_tag :resource_modal, target: "_top" do %>
+<%= turbo_frame_tag :resource_form, target: "_top" do %>
<%= render component("ui/modal").new(title: t(".title")) do |modal| %>
<%= form_for @store_credit_reason, url: form_url, html: { id: form_id } do |f| %>
diff --git a/admin/app/components/solidus_admin/store_credit_reasons/index/component.rb b/admin/app/components/solidus_admin/store_credit_reasons/index/component.rb
index 632c314147d..c1186925d28 100644
--- a/admin/app/components/solidus_admin/store_credit_reasons/index/component.rb
+++ b/admin/app/components/solidus_admin/store_credit_reasons/index/component.rb
@@ -10,7 +10,7 @@ def page_actions
tag: :a,
text: t('.add'),
href: solidus_admin.new_store_credit_reason_path(**search_filter_params),
- data: { turbo_frame: :resource_modal },
+ data: { turbo_frame: :resource_form },
icon: "add-line",
class: "align-self-end w-full",
)
@@ -18,7 +18,7 @@ def page_actions
def turbo_frames
%w[
- resource_modal
+ resource_form
]
end
@@ -51,7 +51,7 @@ def columns
header: :name,
data: ->(store_credit_reason) do
link_to store_credit_reason.name, edit_path(store_credit_reason),
- data: { turbo_frame: :resource_modal },
+ data: { turbo_frame: :resource_form },
class: 'body-link'
end
},
diff --git a/admin/app/components/solidus_admin/store_credit_reasons/new/component.html.erb b/admin/app/components/solidus_admin/store_credit_reasons/new/component.html.erb
index 432322ba69a..db080fb6831 100644
--- a/admin/app/components/solidus_admin/store_credit_reasons/new/component.html.erb
+++ b/admin/app/components/solidus_admin/store_credit_reasons/new/component.html.erb
@@ -1,4 +1,4 @@
-<%= turbo_frame_tag :resource_modal, target: "_top" do %>
+<%= turbo_frame_tag :resource_form, target: "_top" do %>
<%= render component("ui/modal").new(title: t(".title")) do |modal| %>
<%= form_for @store_credit_reason, url: form_url, html: { id: form_id } do |f| %>
diff --git a/admin/app/components/solidus_admin/tax_categories/edit/component.html.erb b/admin/app/components/solidus_admin/tax_categories/edit/component.html.erb
index d5b8b25115b..4fd0f5f25fa 100644
--- a/admin/app/components/solidus_admin/tax_categories/edit/component.html.erb
+++ b/admin/app/components/solidus_admin/tax_categories/edit/component.html.erb
@@ -1,4 +1,4 @@
-<%= turbo_frame_tag :resource_modal, target: "_top" do %>
+<%= turbo_frame_tag :resource_form, target: "_top" do %>
<%= render component("ui/modal").new(title: t(".title")) do |modal| %>
<%= form_for @tax_category, url: form_url, html: { id: form_id } do |f| %>
diff --git a/admin/app/components/solidus_admin/tax_categories/index/component.rb b/admin/app/components/solidus_admin/tax_categories/index/component.rb
index 2937b3b2942..d7d2f40567c 100644
--- a/admin/app/components/solidus_admin/tax_categories/index/component.rb
+++ b/admin/app/components/solidus_admin/tax_categories/index/component.rb
@@ -18,7 +18,7 @@ def page_actions
tag: :a,
text: t('.add'),
href: solidus_admin.new_tax_category_path(**search_filter_params),
- data: { turbo_frame: :resource_modal },
+ data: { turbo_frame: :resource_form },
icon: "add-line",
class: "align-self-end w-full",
)
@@ -26,7 +26,7 @@ def page_actions
def turbo_frames
%w[
- resource_modal
+ resource_form
]
end
@@ -51,7 +51,7 @@ def columns
header: :name,
data: ->(tax_category) do
link_to tax_category.name, edit_path(tax_category),
- data: { turbo_frame: :resource_modal },
+ data: { turbo_frame: :resource_form },
class: 'body-link'
end
},
@@ -59,7 +59,7 @@ def columns
header: :tax_code,
data: ->(tax_category) do
link_to_if tax_category.tax_code, tax_category.tax_code, edit_path(tax_category),
- data: { turbo_frame: :resource_modal },
+ data: { turbo_frame: :resource_form },
class: 'body-link'
end
},
@@ -67,7 +67,7 @@ def columns
header: :description,
data: ->(tax_category) do
link_to_if tax_category.description, tax_category.description, edit_path(tax_category),
- data: { turbo_frame: :resource_modal },
+ data: { turbo_frame: :resource_form },
class: 'body-link'
end
},
diff --git a/admin/app/components/solidus_admin/tax_categories/new/component.html.erb b/admin/app/components/solidus_admin/tax_categories/new/component.html.erb
index d5b8b25115b..4fd0f5f25fa 100644
--- a/admin/app/components/solidus_admin/tax_categories/new/component.html.erb
+++ b/admin/app/components/solidus_admin/tax_categories/new/component.html.erb
@@ -1,4 +1,4 @@
-<%= turbo_frame_tag :resource_modal, target: "_top" do %>
+<%= turbo_frame_tag :resource_form, target: "_top" do %>
<%= render component("ui/modal").new(title: t(".title")) do |modal| %>
<%= form_for @tax_category, url: form_url, html: { id: form_id } do |f| %>
diff --git a/admin/app/components/solidus_admin/ui/icon/component.rb b/admin/app/components/solidus_admin/ui/icon/component.rb
index d2736e6afd6..b66e13ea061 100644
--- a/admin/app/components/solidus_admin/ui/icon/component.rb
+++ b/admin/app/components/solidus_admin/ui/icon/component.rb
@@ -26,6 +26,6 @@ def call
# bypass the asset_host configuration to avoid CORS issues with CDNs:
# https://github.com/solidusio/solidus/issues/5657
href = asset_path("solidus_admin/remixicon.symbol.svg#ri-#{@name}", host: "")
- tag.svg(tag.use("xlink:href": href), **@attrs)
+ tag.svg(tag.use("xlink:href": href, href:), **@attrs)
end
end
diff --git a/admin/app/components/solidus_admin/ui/table/component.html.erb b/admin/app/components/solidus_admin/ui/table/component.html.erb
index 9cbdb312ade..400c745ace1 100644
--- a/admin/app/components/solidus_admin/ui/table/component.html.erb
+++ b/admin/app/components/solidus_admin/ui/table/component.html.erb
@@ -1,8 +1,6 @@
data-action="click-><%= stimulus_id %>#rowClicked"
data-<%= stimulus_id %>-url-param="<%= row_url %>"
- <%= "data-sortable-url=#{@sortable.url.call(row)}" if @sortable&.url %>
<% end %>
+ <%= "data-sortable-url=#{@sortable.url.call(row)}" if @sortable&.url %>
>
<% @data.columns.each do |column| %>
<%= render_data_cell(column, row) %>
diff --git a/admin/app/components/solidus_admin/ui/table/component.rb b/admin/app/components/solidus_admin/ui/table/component.rb
index 1059f8007c4..7649c1f9cfe 100644
--- a/admin/app/components/solidus_admin/ui/table/component.rb
+++ b/admin/app/components/solidus_admin/ui/table/component.rb
@@ -60,12 +60,14 @@ def value
end
end
- def initialize(id:, data:, search: nil, sortable: nil)
+ # @option options [Boolean] :embedded if true, does not add border around table
+ def initialize(id:, data:, search: nil, sortable: nil, **options)
@id = id
@data = Data.new(**data)
@data.columns.unshift selectable_column if @data.batch_actions.present? && @data.rows.present?
@search = Search.new(**search) if search
@sortable = Sortable.new(**sortable) if sortable
+ @options = options
end
def selectable_column
diff --git a/admin/app/components/solidus_admin/users/store_credits/edit_amount/component.html.erb b/admin/app/components/solidus_admin/users/store_credits/edit_amount/component.html.erb
index 61ff2d48d82..7a1327d4854 100644
--- a/admin/app/components/solidus_admin/users/store_credits/edit_amount/component.html.erb
+++ b/admin/app/components/solidus_admin/users/store_credits/edit_amount/component.html.erb
@@ -1,4 +1,4 @@
-<%= turbo_frame_tag :resource_modal, target: "_top" do %>
+<%= turbo_frame_tag :resource_form, target: "_top" do %>
<%= render component("ui/modal").new(title: t(".title")) do |modal| %>
<%= form_for @store_credit, url: form_url, method: :put, html: { id: form_id } do |f| %>
diff --git a/admin/app/components/solidus_admin/users/store_credits/edit_memo/component.html.erb b/admin/app/components/solidus_admin/users/store_credits/edit_memo/component.html.erb
index 54ce226b3a4..e283df9bd7f 100644
--- a/admin/app/components/solidus_admin/users/store_credits/edit_memo/component.html.erb
+++ b/admin/app/components/solidus_admin/users/store_credits/edit_memo/component.html.erb
@@ -1,4 +1,4 @@
-<%= turbo_frame_tag :resource_modal, target: "_top" do %>
+<%= turbo_frame_tag :resource_form, target: "_top" do %>
<%= render component("ui/modal").new(title: t(".title")) do |modal| %>
<%= form_for @store_credit, url: form_url, method: :put, html: { id: form_id } do |f| %>
diff --git a/admin/app/components/solidus_admin/users/store_credits/edit_validity/component.html.erb b/admin/app/components/solidus_admin/users/store_credits/edit_validity/component.html.erb
index fd91a48fb88..c838809b383 100644
--- a/admin/app/components/solidus_admin/users/store_credits/edit_validity/component.html.erb
+++ b/admin/app/components/solidus_admin/users/store_credits/edit_validity/component.html.erb
@@ -1,4 +1,4 @@
-<%= turbo_frame_tag :resource_modal, target: "_top" do %>
+<%= turbo_frame_tag :resource_form, target: "_top" do %>
<%= render component("ui/modal").new(title: t(".title")) do |modal| %>
<%= form_for @store_credit, url: form_url, method: :put, html: { id: form_id } do |f| %>
diff --git a/admin/app/components/solidus_admin/users/store_credits/index/component.html.erb b/admin/app/components/solidus_admin/users/store_credits/index/component.html.erb
index 06e06e1a1bd..ea58963369a 100644
--- a/admin/app/components/solidus_admin/users/store_credits/index/component.html.erb
+++ b/admin/app/components/solidus_admin/users/store_credits/index/component.html.erb
@@ -8,7 +8,7 @@
tag: :a,
href: new_store_credit_path,
data: {
- turbo_frame: :resource_modal
+ turbo_frame: :resource_form
},
text: t(".add_store_credit"),
icon: "add-line"
@@ -47,7 +47,7 @@
<%= render component("ui/button").new(
tag: :a,
data: {
- turbo_frame: :resource_modal
+ turbo_frame: :resource_form
},
href: new_store_credit_path,
text: t(".create_one"),
@@ -61,5 +61,5 @@
<% end %>
<% end %>
- <%= turbo_frame_tag :resource_modal, target: "_top" %>
+ <%= turbo_frame_tag :resource_form, target: "_top" %>
<% end %>
diff --git a/admin/app/components/solidus_admin/users/store_credits/new/component.html.erb b/admin/app/components/solidus_admin/users/store_credits/new/component.html.erb
index df37ce9b238..6e517fa6be1 100644
--- a/admin/app/components/solidus_admin/users/store_credits/new/component.html.erb
+++ b/admin/app/components/solidus_admin/users/store_credits/new/component.html.erb
@@ -1,4 +1,4 @@
-<%= turbo_frame_tag :resource_modal, target: "_top" do %>
+<%= turbo_frame_tag :resource_form, target: "_top" do %>
<%= render component("ui/modal").new(title: t(".title")) do |modal| %>
<%= form_for @store_credit, url: form_url, method: :post, html: { id: form_id } do |f| %>
diff --git a/admin/app/components/solidus_admin/users/store_credits/show/component.html.erb b/admin/app/components/solidus_admin/users/store_credits/show/component.html.erb
index 239faac3233..9d7fcde977b 100644
--- a/admin/app/components/solidus_admin/users/store_credits/show/component.html.erb
+++ b/admin/app/components/solidus_admin/users/store_credits/show/component.html.erb
@@ -31,7 +31,7 @@
tag: :a,
scheme: :danger,
data: {
- turbo_frame: :resource_modal
+ turbo_frame: :resource_form
},
href: edit_validity_url,
text: t(".invalidate"),
@@ -41,7 +41,7 @@
<%= render component("ui/button").new(
tag: :a,
data: {
- turbo_frame: :resource_modal
+ turbo_frame: :resource_form
},
href: edit_memo_url,
text: t(".edit_memo"),
@@ -51,7 +51,7 @@
<%= render component("ui/button").new(
tag: :a,
data: {
- turbo_frame: :resource_modal
+ turbo_frame: :resource_form
},
href: edit_amount_url,
text: t(".edit_amount"),
@@ -79,5 +79,5 @@
<% end %>
<% end %>
- <%= turbo_frame_tag :resource_modal, target: "_top" %>
+ <%= turbo_frame_tag :resource_form, target: "_top" %>
<% end %>
diff --git a/admin/app/components/solidus_admin/zones/form/component.html.erb b/admin/app/components/solidus_admin/zones/form/component.html.erb
index 3fdfecb436b..c96c26a1075 100644
--- a/admin/app/components/solidus_admin/zones/form/component.html.erb
+++ b/admin/app/components/solidus_admin/zones/form/component.html.erb
@@ -1,4 +1,4 @@
-<%= turbo_frame_tag :resource_modal, target: "_top" do %>
+<%= turbo_frame_tag :resource_form, target: "_top" do %>
<%= render component("ui/modal").new(title:) do |modal| %>
<%= form_for @zone, url: @form_url, html: { id: @form_id, **stimulus_controller, **stimulus_value(name: :kind, value: @zone.kind) } do |f| %>
diff --git a/admin/app/components/solidus_admin/zones/index/component.rb b/admin/app/components/solidus_admin/zones/index/component.rb
index 33390df6bea..747bf3399d1 100644
--- a/admin/app/components/solidus_admin/zones/index/component.rb
+++ b/admin/app/components/solidus_admin/zones/index/component.rb
@@ -22,7 +22,7 @@ def edit_path(zone)
end
def turbo_frames
- %w[resource_modal]
+ %w[resource_form]
end
def page_actions
@@ -30,7 +30,7 @@ def page_actions
tag: :a,
text: t('.add'),
href: solidus_admin.new_zone_path(**search_filter_params),
- data: { turbo_frame: :resource_modal },
+ data: { turbo_frame: :resource_form },
icon: "add-line",
class: "align-self-end w-full",
)
@@ -69,7 +69,7 @@ def name_column
header: :name,
data: ->(zone) do
link_to zone.name, edit_path(zone),
- data: { turbo_frame: :resource_modal },
+ data: { turbo_frame: :resource_form },
class: 'body-link'
end
}
@@ -80,7 +80,7 @@ def description_column
header: :description,
data: ->(zone) do
link_to zone.description, edit_path(zone),
- data: { turbo_frame: :resource_modal },
+ data: { turbo_frame: :resource_form },
class: 'body-link'
end
}
diff --git a/admin/app/controllers/concerns/solidus_admin/moveable.rb b/admin/app/controllers/concerns/solidus_admin/moveable.rb
new file mode 100644
index 00000000000..a1f3756d0de
--- /dev/null
+++ b/admin/app/controllers/concerns/solidus_admin/moveable.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+module SolidusAdmin::Moveable
+ extend ActiveSupport::Concern
+
+ included do
+ before_action :load_moveable, only: [:move]
+ end
+
+ def move
+ @moveable.insert_at(params.require(:position).to_i)
+
+ respond_to do |format|
+ format.js { head :no_content }
+ end
+ end
+
+ private
+
+ def load_moveable
+ @moveable = moveable_class.find(params.require(:id))
+ authorize! action_name, @moveable
+ end
+
+ def moveable_class
+ "Spree::#{self.class.name.demodulize.remove('Controller').singularize}".constantize
+ rescue NameError
+ raise NameError,
+ "could not infer model class from #{self.class.name}. Please override `moveable_class` to specify it explicitly."
+ end
+end
diff --git a/admin/app/controllers/solidus_admin/option_types_controller.rb b/admin/app/controllers/solidus_admin/option_types_controller.rb
index 444f1bbbafa..08b2e45a32c 100644
--- a/admin/app/controllers/solidus_admin/option_types_controller.rb
+++ b/admin/app/controllers/solidus_admin/option_types_controller.rb
@@ -1,46 +1,25 @@
# frozen_string_literal: true
module SolidusAdmin
- class OptionTypesController < SolidusAdmin::BaseController
- include SolidusAdmin::ControllerHelpers::Search
+ class OptionTypesController < SolidusAdmin::ResourcesController
+ include SolidusAdmin::Moveable
- before_action :load_option_type, only: [:move]
-
- def index
- option_types = apply_search_to(
- Spree::OptionType.all,
- param: :q,
- )
-
- set_page_and_extract_portion_from(option_types)
-
- respond_to do |format|
- format.html { render component('option_types/index').new(page: @page) }
- end
- end
-
- def move
- @option_type.insert_at(params[:position].to_i)
+ private
- respond_to do |format|
- format.js { head :no_content }
- end
+ def after_create_path
+ solidus_admin.edit_option_type_path(@resource)
end
- def destroy
- @option_types = Spree::OptionType.where(id: params[:id])
+ def resource_class = Spree::OptionType
- Spree::OptionType.transaction { @option_types.destroy_all }
-
- flash[:notice] = t('.success')
- redirect_back_or_to option_types_path, status: :see_other
+ def permitted_resource_params
+ params.require(:option_type).permit(:name, :presentation)
end
- private
+ def resources_collection = Spree::OptionType.unscoped
- def load_option_type
- @option_type = Spree::OptionType.find(params[:id])
- authorize! action_name, @option_type
+ def resources_sorting_options
+ { position: :asc }
end
end
end
diff --git a/admin/app/controllers/solidus_admin/option_values_controller.rb b/admin/app/controllers/solidus_admin/option_values_controller.rb
new file mode 100644
index 00000000000..a5513f0d641
--- /dev/null
+++ b/admin/app/controllers/solidus_admin/option_values_controller.rb
@@ -0,0 +1,54 @@
+# frozen_string_literal: true
+
+module SolidusAdmin
+ class OptionValuesController < SolidusAdmin::ResourcesController
+ include SolidusAdmin::Moveable
+
+ before_action :set_option_type, only: [:new, :create, :destroy]
+
+ def new
+ @resource = @option_type.option_values.build
+ super
+ end
+
+ def create
+ @resource = @option_type.option_values.build(permitted_resource_params)
+ super
+ end
+
+ private
+
+ def prefer_turbo_stream?
+ case params[:action]
+ when "create", "update", "destroy" then true
+ else false
+ end
+ end
+
+ def resource_class = Spree::OptionValue
+
+ def permitted_resource_params
+ params.require(:option_value).permit(:name, :presentation)
+ end
+
+ def resource_form_frame
+ :option_value_modal
+ end
+
+ def after_create_path
+ solidus_admin.edit_option_type_path(@option_type)
+ end
+
+ def after_update_path
+ solidus_admin.edit_option_type_path(@option_value.option_type)
+ end
+
+ def after_destroy_path
+ solidus_admin.edit_option_type_path(@option_type)
+ end
+
+ def set_option_type
+ @option_type = Spree::OptionType.find(params[:option_type_id])
+ end
+ end
+end
diff --git a/admin/app/controllers/solidus_admin/payment_methods_controller.rb b/admin/app/controllers/solidus_admin/payment_methods_controller.rb
index 684eb7381f3..fc3ce0316dd 100644
--- a/admin/app/controllers/solidus_admin/payment_methods_controller.rb
+++ b/admin/app/controllers/solidus_admin/payment_methods_controller.rb
@@ -3,8 +3,7 @@
module SolidusAdmin
class PaymentMethodsController < SolidusAdmin::BaseController
include SolidusAdmin::ControllerHelpers::Search
-
- before_action :load_payment_method, only: [:move]
+ include SolidusAdmin::Moveable
search_scope(:all)
search_scope(:active, default: true, &:active)
@@ -25,14 +24,6 @@ def index
end
end
- def move
- @payment_method.insert_at(params[:position].to_i)
-
- respond_to do |format|
- format.js { head :no_content }
- end
- end
-
def destroy
@payment_methods = Spree::PaymentMethod.where(id: params[:id])
@@ -41,12 +32,5 @@ def destroy
flash[:notice] = t('.success')
redirect_back_or_to payment_methods_path, status: :see_other
end
-
- private
-
- def load_payment_method
- @payment_method = Spree::PaymentMethod.find_by!(id: params[:id])
- authorize! action_name, @payment_method
- end
end
end
diff --git a/admin/app/controllers/solidus_admin/resources_controller.rb b/admin/app/controllers/solidus_admin/resources_controller.rb
index 7ebc49c7eaa..a636c34d24a 100644
--- a/admin/app/controllers/solidus_admin/resources_controller.rb
+++ b/admin/app/controllers/solidus_admin/resources_controller.rb
@@ -4,7 +4,7 @@ module SolidusAdmin
class ResourcesController < SolidusAdmin::BaseController
include SolidusAdmin::ControllerHelpers::Search
- helper_method :search_filter_params
+ helper_method :search_filter_params, :resource_form_frame
before_action :set_paginated_resources, only: %i[index]
before_action :set_resource, only: %i[edit update]
@@ -26,16 +26,19 @@ def index
end
def new
- @resource = resource_class.new
+ @resource ||= resource_class.new
render new_component.new(@resource)
end
def create
- @resource = resource_class.new(permitted_resource_params)
+ @resource ||= resource_class.new(permitted_resource_params)
if @resource.save
flash[:notice] = t('.success')
- redirect_to after_create_path, status: :see_other
+ respond_to do |format|
+ format.html { redirect_to after_create_path, status: :see_other }
+ format.turbo_stream if prefer_turbo_stream?
+ end
else
page_component = new_component.new(@resource)
render_resource_form_with_errors(page_component)
@@ -43,13 +46,18 @@ def create
end
def edit
- render edit_component.new(@resource)
+ respond_to do |format|
+ format.html { render edit_component.new(@resource) }
+ end
end
def update
if @resource.update(permitted_resource_params)
flash[:notice] = t('.success')
- redirect_to after_update_path, status: :see_other
+ respond_to do |format|
+ format.html { redirect_to after_update_path, status: :see_other }
+ format.turbo_stream if prefer_turbo_stream?
+ end
else
page_component = edit_component.new(@resource)
render_resource_form_with_errors(page_component)
@@ -62,7 +70,10 @@ def destroy
resource_class.transaction { @resource.destroy_all }
flash[:notice] = t('.success')
- redirect_back_or_to after_destroy_path, status: :see_other
+ respond_to do |format|
+ format.html { redirect_back_or_to after_destroy_path, status: :see_other }
+ format.turbo_stream if prefer_turbo_stream?
+ end
end
private
@@ -129,7 +140,7 @@ def render_resource_form_with_errors(page_component)
render page_component, status: :unprocessable_entity
end
format.turbo_stream do
- render turbo_stream: turbo_stream.replace(:resource_modal, page_component),
+ render turbo_stream: turbo_stream.replace(resource_form_frame, page_component),
status: :unprocessable_entity
end
end
@@ -151,5 +162,11 @@ def after_update_path
def after_destroy_path
solidus_admin.send("#{plural_resource_name}_path", **search_filter_params)
end
+
+ def resource_form_frame
+ :resource_form
+ end
+
+ def prefer_turbo_stream? = false
end
end
diff --git a/admin/app/controllers/solidus_admin/taxonomies_controller.rb b/admin/app/controllers/solidus_admin/taxonomies_controller.rb
index fb0387d075a..3c6b4cdc2db 100644
--- a/admin/app/controllers/solidus_admin/taxonomies_controller.rb
+++ b/admin/app/controllers/solidus_admin/taxonomies_controller.rb
@@ -3,8 +3,7 @@
module SolidusAdmin
class TaxonomiesController < SolidusAdmin::BaseController
include SolidusAdmin::ControllerHelpers::Search
-
- before_action :load_taxonomy, only: [:move]
+ include SolidusAdmin::Moveable
def index
taxonomies = apply_search_to(
@@ -19,14 +18,6 @@ def index
end
end
- def move
- @taxonomy.insert_at(params[:position].to_i)
-
- respond_to do |format|
- format.js { head :no_content }
- end
- end
-
def destroy
@taxonomies = Spree::Taxonomy.where(id: params[:id])
@@ -35,12 +26,5 @@ def destroy
flash[:notice] = t('.success')
redirect_back_or_to taxonomies_path, status: :see_other
end
-
- private
-
- def load_taxonomy
- @taxonomy = Spree::Taxonomy.find(params[:id])
- authorize! action_name, @taxonomy
- end
end
end
diff --git a/admin/app/views/layouts/solidus_admin/application.html.erb b/admin/app/views/layouts/solidus_admin/application.html.erb
index 6755eea3c1d..8bc30dfadf4 100644
--- a/admin/app/views/layouts/solidus_admin/application.html.erb
+++ b/admin/app/views/layouts/solidus_admin/application.html.erb
@@ -31,10 +31,6 @@
-
- <% flash.each do |key, message| %>
- <%= render component("ui/toast").new(text: message, scheme: key.to_sym == :error ? :error : :default) %>
- <% end %>
-
+ <%= render component("layout/flashes").new %>