Skip to content

Commit

Permalink
Merge pull request #4506 from tvdeyen/v3.1-fix-admin-variants-table
Browse files Browse the repository at this point in the history
[v3.1] Fix admin variants table UX
  • Loading branch information
waiting-for-dev authored Aug 16, 2022
2 parents ddc39e6 + dc21ab8 commit cb8e70e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
13 changes: 7 additions & 6 deletions backend/app/views/spree/admin/variants/_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
<table class="index sortable" data-sortable-link="<%= update_positions_admin_product_variants_path(@product) %>">
<colgroup>
<col style="width: 5%" />
<col style="width: 25%" />
<col style="width: 20%" />
<col style="width: 35%" />
<col style="width: 20%" />
<col style="width: 15%" />
<col style="width: 25%" />
<col style="width: 15%" />
</colgroup>
<thead data-hook="variants_header">
Expand Down Expand Up @@ -40,9 +39,11 @@
</td>
</tr>
<% end %>
<% if variants.empty? %>
<tr><td colspan="4"><%= t('spree.none') %></td></tr>
<% end %>
</tbody>
</table>
<% if variants.empty? %>
<div class="alert alert-warning">
<%= t('.no_variants_found', term: params[:variant_search_term]) %>
</div>
<% end %>
<%= paginate variants, theme: "solidus_admin" %>
17 changes: 8 additions & 9 deletions backend/app/views/spree/admin/variants/_table_filter.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@

<% content_for :table_filter do %>
<%= form_for :variant_search, url: spree.admin_product_variants_path(product), method: :get do |f| %>
<div class="col-10">
<div data-hook="admin_variants_index_search" class="field">
<%= f.label :variant_search_term, t('spree.variant_search_placeholder') %>
<%= text_field_tag :variant_search_term, params[:variant_search_term], class: "fullwidth", placeholder: t('spree.variant_search_placeholder') %>
<div class="row">
<div class="col-10">
<div data-hook="admin_variants_index_search" class="field">
<%= f.label :variant_search_term, t('spree.variant_search_placeholder') %>
<%= text_field_tag :variant_search_term, params[:variant_search_term], class: "fullwidth", placeholder: t('spree.variant_search_placeholder') %>
</div>
</div>
</div>

<% if product.variants.with_discarded.discarded.any? %>
<div class="col-2">
<div class="field checkbox">
<label>
Expand All @@ -20,10 +19,10 @@
</label>
</div>
</div>
<% end %>
</div>

<div class="actions filter-actions">
<%= f.button :search %>
<%= button_tag t('spree.filter_results'), class: 'btn btn-primary' %>
</div>
<% end %>
<% end %>
2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/variants/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<% end %>
<% end %>

<% if @product.variants.with_discarded.any? %>
<% if @product.variants.with_discarded.any? || params[:variant_search_term].present? %>
<%= render "table_filter", product: @product %>
<%= render "table", variants: @variants %>
<% else %>
Expand Down
2 changes: 1 addition & 1 deletion backend/spec/features/admin/products/variant_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
it 'allows to display deleted variants with a filter' do
visit spree.admin_product_variants_path(product)
check 'Show Deleted Variants'
click_button 'search'
click_button 'Filter Results'

expect(page).to have_content(discarded_variant.sku)
end
Expand Down
2 changes: 2 additions & 0 deletions core/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,8 @@ en:
use_product_tax_category: Use Product Tax Category
new:
new_variant: New Variant
table:
no_variants_found: No variants found for '%{term}'
table_filter:
show_deleted: Show Deleted Variants
administration: Administration
Expand Down

0 comments on commit cb8e70e

Please sign in to comment.