mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-13 23:37:47 +00:00
Edit Orders: more variant info in variant search
Displaying variant's full name and the producer's name.
This commit is contained in:
33
app/views/spree/admin/variants/_autocomplete.js.erb
Normal file
33
app/views/spree/admin/variants/_autocomplete.js.erb
Normal file
@@ -0,0 +1,33 @@
|
||||
<script type='text/template' id='variant_autocomplete_template'>
|
||||
<div class='variant-autocomplete-item'>
|
||||
<figure class='variant-image'>
|
||||
{{#if variant.image }}
|
||||
<img src='{{variant.image}}' />
|
||||
{{ else }}
|
||||
<img src='/assets/noimage/mini.png' />
|
||||
{{/if}}
|
||||
</figure>
|
||||
|
||||
<div class='variant-details'>
|
||||
|
||||
<h6 class="variant-name">{{variant.name}}</h6>
|
||||
|
||||
<ul>
|
||||
<li><strong>Producer:</strong> {{variant.producer_name}}</li>
|
||||
</ul>
|
||||
<ul class='variant-data'>
|
||||
<li class='variant-sku'><strong>{{t 'sku'}}:</strong> {{variant.sku}}</li>
|
||||
<li class='variant-on_hand'><strong>{{t 'on_hand' }}:</strong> {{variant.count_on_hand}}</li>
|
||||
</ul>
|
||||
|
||||
{{#if variant.option_values}}
|
||||
<ul class='variant-options'>
|
||||
{{#each variant.option_values}}
|
||||
<li><strong>{{this.option_type.presentation}}:</strong> {{this.presentation}}</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
{{/if}}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
34
app/views/spree/admin/variants/search.rabl
Normal file
34
app/views/spree/admin/variants/search.rabl
Normal file
@@ -0,0 +1,34 @@
|
||||
#
|
||||
# overriding spree/core/app/views/spree/admin/variants/search.rabl
|
||||
#
|
||||
collection @variants
|
||||
attributes :sku, :options_text, :count_on_hand, :id, :cost_price
|
||||
|
||||
node(:name) do |v|
|
||||
# TODO: when products must have a unit, full_name will always be present
|
||||
variant_specific = v.full_name
|
||||
if variant_specific.present?
|
||||
"#{v.name} - #{v.full_name}"
|
||||
else
|
||||
v.name
|
||||
end
|
||||
end
|
||||
|
||||
node(:full_name) do |v|
|
||||
v.full_name
|
||||
end
|
||||
|
||||
node(:producer_name) do |v|
|
||||
v.product.supplier.name
|
||||
end
|
||||
|
||||
child(:images => :images) do
|
||||
attributes :mini_url
|
||||
end
|
||||
|
||||
child(:option_values => :option_values) do
|
||||
child(:option_type => :option_type) do
|
||||
attributes :name, :presentation
|
||||
end
|
||||
attributes :name, :presentation
|
||||
end
|
||||
Reference in New Issue
Block a user