Skip to content

Commit

Permalink
Rework promotion batches views
Browse files Browse the repository at this point in the history
  • Loading branch information
tomdonarski committed Dec 4, 2023
1 parent 0058fed commit c01af53
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 17 deletions.
6 changes: 6 additions & 0 deletions app/views/spree/admin/promotion_batches/_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div data-hook="new_promotion_batch_template_promotion" class="col-12 col-md-4">
<%= 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 %>
</div>
21 changes: 21 additions & 0 deletions app/views/spree/admin/promotion_batches/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<% content_for :page_title do %>
<%= link_to Spree.t(:promotion_batches), admin_promotion_batches_path %> /
<%= @promotion_batch.id %>
<% end %>

<div class="card">
<div class="card-body">
<%= 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 %>
</div>
</div>

<%= form_for @promotion_batch, url: object_url, method: :put do |f| %>
<div class="card mb-4">
<div class="card-body">
<%= render partial: 'spree/admin/shared/edit_resource_links' %>
</div>
</div>
<% end %>
3 changes: 2 additions & 1 deletion app/views/spree/admin/promotion_batches/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
<td><%= link_to promotion_batch.template_promotion.name, spree.edit_admin_promotion_path(promotion_batch.template_promotion) if promotion_batch.template_promotion %></td>
<td class="actions" data-hook="admin_promotion_batches_index_row_actions">
<span class="d-flex justify-content-end">
<%= 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) %>
</span>
</td>
</tr>
Expand Down
9 changes: 2 additions & 7 deletions app/views/spree/admin/promotion_batches/new.html.erb
Original file line number Diff line number Diff line change
@@ -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 %>

<div class="card">
<div class="card-body">
<%= form_for :promotion_batch, url: collection_url do |f| %>
<div data-hook="new_promotion_batch_template_promotion" class="col-12 col-md-4">
<%= 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 %>
</div>
<%= render partial: 'form', locals: { f: f } %>
<%= render partial: 'spree/admin/shared/new_resource_links' %>
<% end %>
</div>
Expand Down
9 changes: 0 additions & 9 deletions app/views/spree/admin/promotion_batches/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,6 @@
<% end %>
<% end %>

<div class="card">
<div class="card-body">
<%= 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 %>
</div>
</div>

<table class="table">
<thead class="text-muted">
<tr>
Expand Down

0 comments on commit c01af53

Please sign in to comment.