Don't try to load orders if the number of line_items with the current filters applied is zero

This ends up sending a request to the orders endpoint with no filters and no search params, which then tries to load every order in the entire database if the user is superadmin, which blows up.
This commit is contained in:
Matt-Yorkley
2023-06-13 15:12:13 +01:00
parent 12bb8db7b3
commit 73b2d37224

View File

@@ -62,6 +62,8 @@ angular.module("admin.lineItems").controller 'LineItemsCtrl', ($scope, $timeout,
$scope.dereferenceLoadedData()
$scope.loadOrders = ->
return $scope.orders = [] unless $scope.line_items.length
RequestMonitor.load $scope.orders = Orders.index(
"q[id_in][]": $scope.line_items.map((line_item) -> line_item.order.id)
)