When creating backoffice orders hide variants with no stock by default

But let people include out of stock variants by checking a checkbox if they want.

Note, we only apply the variants in stock scope if a distributor is
present. I think this is because this search method is also used when
setting up subscriptions so I don't think we want to change the
behaviour there.

Co-authored-by: Maikel Linke <maikel@email.org.au>
This commit is contained in:
Cillian O'Ruanaidh
2021-08-06 18:35:15 +01:00
parent 86404045f2
commit 2462d71ab5
6 changed files with 134 additions and 4 deletions

View File

@@ -19,6 +19,7 @@ angular.module("admin.utils").directive "variantAutocomplete", ($timeout) ->
distributor_id: scope.distributor_id
order_cycle_id: scope.order_cycle_id
eligible_for_subscriptions: scope.eligible_for_subscriptions
include_out_of_stock: scope.include_out_of_stock
results: (data, page) ->
window.variants = data # this is how spree auto complete JS code picks up variants
results: data
@@ -27,3 +28,5 @@ angular.module("admin.utils").directive "variantAutocomplete", ($timeout) ->
formatSelection: (variant) ->
element.parent().children(".options_placeholder").html variant.options_text
variant.name
element.on "select2-opening", ->
scope.include_out_of_stock = if $('#include_out_of_stock').is(':checked') then "1" else ""