Skip to content

Commit

Permalink
Load orders only if current line_items are loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
jibees committed Feb 3, 2023
1 parent d00e75d commit d2cb2c1
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ angular.module("admin.lineItems").controller 'LineItemsCtrl', ($scope, $timeout,
$scope.refreshData = ->
return "cancel" unless $scope.confirmRefresh()

$scope.loadOrders()
$scope.loadLineItems()

unless $scope.initialized
Expand Down Expand Up @@ -84,13 +83,15 @@ angular.module("admin.lineItems").controller 'LineItemsCtrl', ($scope, $timeout,
RequestMonitor.load $scope.suppliers = Enterprises.index(action: "visible", ams_prefix: "basic", "q[is_primary_producer_eq]": "true")

$scope.dereferenceLoadedData = ->
RequestMonitor.load $q.all([$scope.orders.$promise, $scope.distributors.$promise, $scope.orderCycles.$promise, $scope.suppliers.$promise, $scope.line_items.$promise]).then ->
Dereferencer.dereferenceAttr $scope.orders, "distributor", Enterprises.byID
Dereferencer.dereferenceAttr $scope.orders, "order_cycle", OrderCycles.byID
RequestMonitor.load $q.all([$scope.distributors.$promise, $scope.orderCycles.$promise, $scope.suppliers.$promise, $scope.line_items.$promise]).then ->
Dereferencer.dereferenceAttr $scope.line_items, "supplier", Enterprises.byID
Dereferencer.dereferenceAttr $scope.line_items, "order", Orders.byID
$scope.bulk_order_form.$setPristine()
StatusMessage.clear()
$scope.loadOrders()
RequestMonitor.load $q.all([$scope.orders.$promise]).then ->
Dereferencer.dereferenceAttr $scope.line_items, "order", Orders.byID
Dereferencer.dereferenceAttr $scope.orders, "distributor", Enterprises.byID
Dereferencer.dereferenceAttr $scope.orders, "order_cycle", OrderCycles.byID
$scope.bulk_order_form.$setPristine()
StatusMessage.clear()

unless $scope.initialized
$scope.initialized = true
Expand Down

0 comments on commit d2cb2c1

Please sign in to comment.