mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-15 04:14:24 +00:00
Use select2 for order cycle selection
This commit is contained in:
@@ -118,6 +118,11 @@ Spree::Admin::OrdersController.class_eval do
|
||||
|
||||
def load_distribution_choices
|
||||
@shops = Enterprise.is_distributor.managed_by(spree_current_user).by_name
|
||||
@order_cycles = OrderCycle.managed_by(spree_current_user).by_name
|
||||
|
||||
ocs = OrderCycle.managed_by(spree_current_user)
|
||||
@order_cycles = ocs.soonest_closing +
|
||||
ocs.soonest_opening +
|
||||
ocs.closed +
|
||||
ocs.undated
|
||||
end
|
||||
end
|
||||
|
||||
@@ -19,11 +19,11 @@
|
||||
.alpha.six.columns
|
||||
.field
|
||||
%label{for: "order_distributor_id"} Distributor
|
||||
%select{id: "order_distributor_id", name: "order[distributor_id]", 'ng-model' => 'distributor_id'}
|
||||
%select.fullwidth{id: "order_distributor_id", name: "order[distributor_id]", 'ng-model' => 'distributor_id'}
|
||||
%option{"ng-repeat" => "shop in shops", "ng-value" => "shop.id", "ng-selected" => "distributor_id == shop.id", "ng-disabled" => "!distributorHasOrderCycles(shop)", "ng-bind" => "shop.name"}
|
||||
|
||||
.omega.six.columns
|
||||
.field{"ng-show" => "distributor_id"}
|
||||
%label{for: "order_order_cycle_id"} Order Cycle
|
||||
%select{id: "order_order_cycle_id", name: "order[order_cycle_id]", 'ng-model' => 'order_cycle_id'}
|
||||
%select.select2.fullwidth{id: "order_order_cycle_id", name: "order[order_cycle_id]", 'ng-model' => 'order_cycle_id'}
|
||||
%option{"ng-repeat" => "oc in orderCycles | filter:validOrderCycle", "ng-value" => "oc.id", "ng-selected" => "order_cycle_id == oc.id", "ng-bind" => "oc.name"}
|
||||
|
||||
@@ -3,3 +3,4 @@
|
||||
var scope = angular.element("#order-form-wrapper").scope();
|
||||
$("#order-form-wrapper").html(scope.$compile('<%= escape_javascript(render :partial => "spree/admin/orders/form") %>')(scope));
|
||||
scope.$apply();
|
||||
$('select.select2').select2({allowClear: true});
|
||||
|
||||
Reference in New Issue
Block a user