Skip to content

Commit

Permalink
Add partial for duplicating a promotion.
Browse files Browse the repository at this point in the history
Add route and controller action.
  • Loading branch information
tomdonarski committed Nov 16, 2023
1 parent 60848a6 commit 8929e2d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/controllers/spree/admin/promotions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ def clone
end
end

def duplicate
end

protected

def location_after_save
Expand Down
6 changes: 6 additions & 0 deletions app/views/spree/admin/promotions/_duplicate.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div class="col-12 col-lg-4">
<%= form_tag({ action: :duplicate }, method: :post) do %>
<%= number_field_tag(:batch_size) %>
<%= submit_tag("Duplicate") %>
<% end %>
</div>
1 change: 1 addition & 0 deletions app/views/spree/admin/promotions/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<%= link_to Spree.t(:promotions), admin_promotions_url %> /
<%= @promotion.name %>
<% end %>
<%= render partial: 'spree/admin/promotions/duplicate' %>

<%= form_for @promotion, url: object_url, method: :put do |f| %>
<div class="card mb-4">
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
resources :promotion_actions
member do
post :clone
post :duplicate
end
end

Expand Down

0 comments on commit 8929e2d

Please sign in to comment.