mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-09 23:06:06 +00:00
Include sort direction parameter during bulk product update to prevent JS error causing 'Saving' text to hang
Before if you did a bulk product update there was an error: > TypeError: Cannot set property 'variants' of null It only seemed to happen if pagination was required i.e. more than 15 products. It seemed to be happening because the default sort order on the products API endpoint which handles the bulk update is 'created desc' but 'name asc' on the /admin/products controller. Another fix included here is for the sorting direction arrows which were not displaying on the admin products page. The sorting arrows require the sorting expression to be on the :sorting var instead of :q.sorting. Fixes #6399
This commit is contained in:
@@ -368,7 +368,7 @@ describe "AdminProductEditCtrl", ->
|
||||
$scope.sortOptions.toggle('name')
|
||||
$scope.$apply()
|
||||
|
||||
expect($scope.q.sorting).toEqual 'name asc'
|
||||
expect($scope.sorting).toEqual 'name desc'
|
||||
expect($scope.fetchProducts).toHaveBeenCalled()
|
||||
|
||||
describe "updating the product on hand count", ->
|
||||
|
||||
@@ -42,3 +42,19 @@ describe "SortOptions service", ->
|
||||
SortOptions.toggle("column.b")
|
||||
expect(SortOptions.predicate).toEqual "column.b"
|
||||
expect(SortOptions.reverse).toBe false
|
||||
|
||||
describe "getting the sorting expression", ->
|
||||
describe "when not specifying the default sort direction", ->
|
||||
it "sets the direction to 'asc' after the first toggle because the default direction is 'desc'", ->
|
||||
SortOptions.toggle("column.a")
|
||||
expect(SortOptions.getSortingExpr()).toEqual "column.a asc"
|
||||
|
||||
describe "when specifying the default sorting direction as 'desc'", ->
|
||||
it "sets the direction to 'asc' after the first toggle", ->
|
||||
SortOptions.toggle("column.a")
|
||||
expect(SortOptions.getSortingExpr(defaultDirection: "desc")).toEqual "column.a asc"
|
||||
|
||||
describe "when specifying the default sorting direction as 'asc'", ->
|
||||
it "sets the direction to 'desc' after the first toggle", ->
|
||||
SortOptions.toggle("column.a")
|
||||
expect(SortOptions.getSortingExpr(defaultDirection: "asc")).toEqual "column.a desc"
|
||||
|
||||
Reference in New Issue
Block a user