diff --git a/app/assets/javascripts/admin/orders/controllers/orders_controller.js.coffee b/app/assets/javascripts/admin/orders/controllers/orders_controller.js.coffee index 797ee7c42f..a5ddc19115 100644 --- a/app/assets/javascripts/admin/orders/controllers/orders_controller.js.coffee +++ b/app/assets/javascripts/admin/orders/controllers/orders_controller.js.coffee @@ -15,3 +15,6 @@ angular.module("admin.orders").controller "ordersCtrl", ($scope, $compile, $attr $scope.orderCycleHasDistributor = (oc, distributor_id) -> distributor_ids = (d.id for d in oc.distributors) distributor_ids.indexOf(distributor_id) != -1 + + $scope.distributionChosen = -> + $scope.distributor_id && $scope.order_cycle_id diff --git a/app/overrides/spree/admin/orders/_form/hide_form_until_distribution.deface b/app/overrides/spree/admin/orders/_form/hide_form_until_distribution.deface new file mode 100644 index 0000000000..7fe5652aae --- /dev/null +++ b/app/overrides/spree/admin/orders/_form/hide_form_until_distribution.deface @@ -0,0 +1,2 @@ +add_to_attributes "table.index, [data-hook='admin_order_form_buttons']" +attributes "ng-show" => "distributionChosen()" diff --git a/app/views/spree/admin/orders/new.html.haml b/app/views/spree/admin/orders/new.html.haml index 0404790595..3c5466df14 100644 --- a/app/views/spree/admin/orders/new.html.haml +++ b/app/views/spree/admin/orders/new.html.haml @@ -15,7 +15,8 @@ = render 'spree/shared/error_messages', :target => @order %div{"ng-app" => "admin.orders", "ng-controller" => "ordersCtrl"} - = render 'add_product' + %div{"ng-show" => "distributionChosen()"} + = render 'add_product' - unless @order.line_items.any? %div{"data-hook" => "admin_order_new_form"}