mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-28 01:53:25 +00:00
Adapt variants auto complete to spree v2 code with shipments
This commit is contained in:
@@ -23,6 +23,7 @@ angular.module("admin.utils").directive "variantAutocomplete", ($timeout) ->
|
||||
distributor_id: scope.distributor_id
|
||||
order_cycle_id: scope.order_cycle_id
|
||||
results: (data, page) ->
|
||||
window.variants = data # this is how spree auto complete JS code picks up variants
|
||||
results: data
|
||||
formatResult: (variant) ->
|
||||
if variant["images"][0] != undefined && variant["images"][0].image != undefined
|
||||
|
||||
@@ -46,26 +46,27 @@
|
||||
<th class="actions"></th>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each variant.stock_items}}
|
||||
<tr>
|
||||
<td>{{this.stock_location_name}}</td>
|
||||
{{#if this.available}}
|
||||
<td>
|
||||
{{this.count_on_hand}}
|
||||
{{#if this.backorderable}} (backorders allowed) {{/if}}
|
||||
</td>
|
||||
<td>
|
||||
<input class="quantity" id="stock_item_quantity" data-stock-location-id="{{this.stock_location_id}}" type="number" min="1" value="1">
|
||||
</td>
|
||||
<td class="actions">
|
||||
<button class="add_variant no-text icon-plus icon_link with-tip" data-stock-location-id="{{this.stock_location_id}}" title="Add" data-action="add"></button>
|
||||
</td>
|
||||
<tr>
|
||||
<td>{{variant.stock_location_name}}</td>
|
||||
{{#if variant.[in_stock?]}}
|
||||
{{#if variant.on_demand}}
|
||||
<td>Spree.t(:on_demand)</td>
|
||||
{{else}}
|
||||
<td><%= Spree.t(:out_of_stock) %></td>
|
||||
<td>0</td>
|
||||
{{/if}}
|
||||
</tr>
|
||||
{{/each}}
|
||||
<td>
|
||||
{{variant.count_on_hand}}
|
||||
</td>
|
||||
{{/if}}
|
||||
<td>
|
||||
<input class="quantity" id="stock_item_quantity" data-stock-location-id="{{variant.stock_location_id}}" type="number" min="1" value="1">
|
||||
</td>
|
||||
<td class="actions">
|
||||
<button class="add_variant no-text icon-plus icon_link with-tip" data-stock-location-id="{{variant.stock_location_id}}" title="Add" data-action="add"></button>
|
||||
</td>
|
||||
{{else}}
|
||||
<td><%= Spree.t(:out_of_stock) %></td>
|
||||
<td>0</td>
|
||||
{{/if}}
|
||||
</tr>
|
||||
</tbody>
|
||||
</fieldset>
|
||||
</script>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# overriding spree/core/app/views/spree/admin/variants/search.rabl
|
||||
#
|
||||
collection @variants
|
||||
attributes :sku, :options_text, :count_on_hand, :id, :cost_price
|
||||
attributes :sku, :options_text, :in_stock?, :on_demand, :count_on_hand, :id, :cost_price
|
||||
|
||||
node(:name) do |v|
|
||||
# TODO: when products must have a unit, full_name will always be present
|
||||
@@ -22,6 +22,14 @@ node(:producer_name) do |v|
|
||||
v.product.supplier.name
|
||||
end
|
||||
|
||||
node(:stock_location_id) do |v|
|
||||
v.stock_items.first.stock_location.id
|
||||
end
|
||||
|
||||
node(:stock_location_name) do |v|
|
||||
v.stock_items.first.stock_location.name
|
||||
end
|
||||
|
||||
child(:images => :images) do
|
||||
attributes :mini_url
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user