Skip to content

Commit c2c4443

Browse files
committed
Allow quick save with Apply button
When adding new option values it is more convenient to be able to save progress and stay on the same page (e.g. to reorder newly created option values). This button allows to do so, similar to how system dialogues would usually have an "Apply" button which saves changes but does not close the window.
1 parent d00fd54 commit c2c4443

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

admin/app/components/solidus_admin/option_types/edit/component.html.erb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@
3232
</div>
3333

3434
<%= page_footer do %>
35-
<%= render component("ui/button").new(text: t(".save"), form: form_id) %>
35+
<div class="flex gap-2">
36+
<%= render component("ui/button").new(text: t(".save"), form: form_id) %>
37+
<%= render component("ui/button").new(text: t(".apply"), scheme: :secondary, form: form_id, name: "apply", value: true) %>
38+
</div>
3639
<% end %>
3740
<% end %>
3841
<% end %>

admin/app/components/solidus_admin/option_types/edit/component.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
en:
2+
apply: Apply
23
back: Back
34
panels:
45
option_type:

admin/app/controllers/solidus_admin/option_types_controller.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ def after_create_path
1818
solidus_admin.edit_option_type_path(@resource)
1919
end
2020

21+
def after_update_path
22+
if params[:apply]
23+
solidus_admin.edit_option_type_path(@resource)
24+
else
25+
super
26+
end
27+
end
28+
2129
def resource_class = Spree::OptionType
2230

2331
def permitted_resource_params

0 commit comments

Comments
 (0)