Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SD-824] Corrects color presentation in admin panel #10012

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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