Skip to content

Commit

Permalink
[SD-824] Corrects color presentation in admin panel (#10012)
Browse files Browse the repository at this point in the history
* Corrects color presentation in admin panel

* Corrects handlebar_extensions.js

* Corrects color display in variant form and removes upparcase in handlebar_extensions.js

* Changes checks from option type presentation to name
  • Loading branch information
PSzyszkaSpark committed Mar 11, 2020
1 parent 20c2d42 commit 6703a79
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
Expand Up @@ -8,3 +8,10 @@ Handlebars.registerHelper('t', function (key) {
Handlebars.registerHelper('edit_product_url', function (productId) {
return Spree.routes.edit_product(productId)
})
Handlebars.registerHelper('name_or_presentation', function (optionValue) {
if (optionValue.name === 'color') {
return optionValue.name
} else {
return optionValue.presentation
}
})
Expand Up @@ -12,7 +12,7 @@
<h5 class="variant-name media-heading h6 mb-0">{{variant.name}}</h5>
{{#if variant.option_values}}
{{#each variant.option_values}}
<strong>{{this.option_type_presentation}}:</strong> {{this.presentation}}<br/>
<strong>{{this.option_type_presentation}}:</strong> {{name_or_presentation this}}<br/>
{{/each}}
{{/if}}
<strong><%= Spree.t(:sku) %>:</strong> {{variant.sku}}
Expand Down
9 changes: 7 additions & 2 deletions backend/app/views/spree/admin/variants/_form.html.erb
Expand Up @@ -4,8 +4,13 @@
<% @product.option_types.each do |option_type| %>
<div class="form-group" data-hook="presentation">
<%= label :new_variant, option_type.presentation %>
<%= f.collection_select 'option_value_ids', option_type.option_values, :id, :presentation,
{ include_blank: true }, { name: 'variant[option_value_ids][]', class: 'select2' } %>
<% if option_type.name == 'color' %>
<%= f.collection_select 'option_value_ids', option_type.option_values, :id, :name,
{ include_blank: true }, { name: 'variant[option_value_ids][]', class: 'select2' } %>
<% else %>
<%= f.collection_select 'option_value_ids', option_type.option_values, :id, :presentation,
{ include_blank: true }, { name: 'variant[option_value_ids][]', class: 'select2' } %>
<% end %>
</div>
<% end %>

Expand Down

0 comments on commit 6703a79

Please sign in to comment.