From c01af537c7310b736aa82004a932eb7a387b1d56 Mon Sep 17 00:00:00 2001 From: Tomasz Donarski Date: Mon, 4 Dec 2023 17:08:36 +0100 Subject: [PATCH] Rework promotion batches views --- .../admin/promotion_batches/_form.html.erb | 6 ++++++ .../admin/promotion_batches/edit.html.erb | 21 +++++++++++++++++++ .../admin/promotion_batches/index.html.erb | 3 ++- .../admin/promotion_batches/new.html.erb | 9 ++------ .../admin/promotion_batches/show.html.erb | 9 -------- 5 files changed, 31 insertions(+), 17 deletions(-) create mode 100644 app/views/spree/admin/promotion_batches/_form.html.erb create mode 100644 app/views/spree/admin/promotion_batches/edit.html.erb diff --git a/app/views/spree/admin/promotion_batches/_form.html.erb b/app/views/spree/admin/promotion_batches/_form.html.erb new file mode 100644 index 0000000000..3864b47841 --- /dev/null +++ b/app/views/spree/admin/promotion_batches/_form.html.erb @@ -0,0 +1,6 @@ +
+ <%= f.field_container :template_promotion do %> + <%= f.label :template_promotion_id, Spree.t(:template_promotion) %> + <%= f.collection_select :template_promotion_id, Spree::Promotion.all, :id, :name, { include_blank: true }, { class: 'select2-clear w-100' } %> + <% end %> +
diff --git a/app/views/spree/admin/promotion_batches/edit.html.erb b/app/views/spree/admin/promotion_batches/edit.html.erb new file mode 100644 index 0000000000..893c2c41f4 --- /dev/null +++ b/app/views/spree/admin/promotion_batches/edit.html.erb @@ -0,0 +1,21 @@ +<% content_for :page_title do %> + <%= link_to Spree.t(:promotion_batches), admin_promotion_batches_path %> / + <%= @promotion_batch.id %> +<% end %> + +
+
+ <%= form_tag csv_import_admin_promotion_batch_path, method: :post, multipart: true do %> + <%= file_field_tag :file, accept: ".csv" %> + <%= submit_tag 'Import codes from CSV' %> + <% end %> +
+
+ +<%= form_for @promotion_batch, url: object_url, method: :put do |f| %> +
+
+ <%= render partial: 'spree/admin/shared/edit_resource_links' %> +
+
+<% end %> \ No newline at end of file diff --git a/app/views/spree/admin/promotion_batches/index.html.erb b/app/views/spree/admin/promotion_batches/index.html.erb index 91b64984ea..82f40e1aed 100644 --- a/app/views/spree/admin/promotion_batches/index.html.erb +++ b/app/views/spree/admin/promotion_batches/index.html.erb @@ -35,7 +35,8 @@ <%= link_to promotion_batch.template_promotion.name, spree.edit_admin_promotion_path(promotion_batch.template_promotion) if promotion_batch.template_promotion %> - <%= link_to_delete promotion_batch, no_text: true if can?(:delete, promotion_batch) %> + <%= link_to_edit promotion_batch, no_text: true if can?(:edit, promotion_batch) %> + <%= link_to_delete promotion_batch, no_text: true if can?(:delete, promotion_batch) %> diff --git a/app/views/spree/admin/promotion_batches/new.html.erb b/app/views/spree/admin/promotion_batches/new.html.erb index 256236261e..328fe5e0c0 100644 --- a/app/views/spree/admin/promotion_batches/new.html.erb +++ b/app/views/spree/admin/promotion_batches/new.html.erb @@ -1,17 +1,12 @@ <% content_for :page_title do %> - <%= link_to Spree.t(:promotion_batch), admin_promotion_batches_path %> / + <%= link_to Spree.t(:promotion_batches), admin_promotion_batches_path %> / <%= Spree.t(:new_promotion_batch) %> <% end %>
<%= form_for :promotion_batch, url: collection_url do |f| %> -
- <%= f.field_container :template_promotion do %> - <%= f.label :template_promotion_id, Spree.t(:template_promotion) %> - <%= f.collection_select :template_promotion_id, Spree::Promotion.all, :id, :name, { include_blank: true }, { class: 'select2-clear w-100' } %> - <% end %> -
+ <%= render partial: 'form', locals: { f: f } %> <%= render partial: 'spree/admin/shared/new_resource_links' %> <% end %>
diff --git a/app/views/spree/admin/promotion_batches/show.html.erb b/app/views/spree/admin/promotion_batches/show.html.erb index d342f664b2..7c11510a84 100644 --- a/app/views/spree/admin/promotion_batches/show.html.erb +++ b/app/views/spree/admin/promotion_batches/show.html.erb @@ -15,15 +15,6 @@ <% end %> <% end %> -
-
- <%= form_tag csv_import_admin_promotion_batch_path, method: :post, multipart: true do %> - <%= file_field_tag :file, accept: ".csv" %> - <%= submit_tag 'Import codes from CSV' %> - <% end %> -
-
-