mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-08 22:56:06 +00:00
Generalize sorting through SortOptions service
This commit is contained in:
committed by
Maikel Linke
parent
8b6b694244
commit
55d0b1dfc5
@@ -1,4 +1,4 @@
|
||||
angular.module("admin.customers").controller "customersCtrl", ($scope, $q, $filter, Customers, TagRuleResource, CurrentShop, RequestMonitor, Columns, pendingChanges, shops, availableCountries) ->
|
||||
angular.module("admin.customers").controller "customersCtrl", ($scope, $q, $filter, Customers, TagRuleResource, CurrentShop, RequestMonitor, Columns, SortOptions, pendingChanges, shops, availableCountries) ->
|
||||
$scope.shops = shops
|
||||
$scope.availableCountries = availableCountries
|
||||
$scope.RequestMonitor = RequestMonitor
|
||||
@@ -6,9 +6,7 @@ angular.module("admin.customers").controller "customersCtrl", ($scope, $q, $filt
|
||||
$scope.customerLimit = 20
|
||||
$scope.customers = Customers.all
|
||||
$scope.columns = Columns.columns
|
||||
$scope.sorting =
|
||||
predicate: ""
|
||||
reverse: true
|
||||
$scope.sorting = SortOptions
|
||||
|
||||
$scope.confirmRefresh = (event) ->
|
||||
event.preventDefault() unless pendingChanges.unsavedCount() == 0 || confirm(t("unsaved_changes_warning"))
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
angular.module("admin.indexUtils").factory 'SortOptions', ->
|
||||
new class SortOptions
|
||||
predicate: ""
|
||||
reverse: true
|
||||
@@ -1,4 +1,4 @@
|
||||
angular.module("admin.lineItems").controller 'LineItemsCtrl', ($scope, $timeout, $http, $q, StatusMessage, Columns, Dereferencer, Orders, LineItems, Enterprises, OrderCycles, VariantUnitManager, RequestMonitor) ->
|
||||
angular.module("admin.lineItems").controller 'LineItemsCtrl', ($scope, $timeout, $http, $q, StatusMessage, Columns, SortOptions, Dereferencer, Orders, LineItems, Enterprises, OrderCycles, VariantUnitManager, RequestMonitor) ->
|
||||
$scope.initialized = false
|
||||
$scope.RequestMonitor = RequestMonitor
|
||||
$scope.filteredLineItems = []
|
||||
@@ -10,9 +10,7 @@ angular.module("admin.lineItems").controller 'LineItemsCtrl', ($scope, $timeout,
|
||||
$scope.selectedUnitsVariant = {}
|
||||
$scope.sharedResource = false
|
||||
$scope.columns = Columns.columns
|
||||
$scope.sorting =
|
||||
predicate: ""
|
||||
reverse: true
|
||||
$scope.sorting = SortOptions
|
||||
|
||||
$scope.confirmRefresh = ->
|
||||
LineItems.allSaved() || confirm(t("unsaved_changes_warning"))
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
describe "SortOptions service", ->
|
||||
SortOptions = null
|
||||
|
||||
beforeEach ->
|
||||
module 'admin.indexUtils'
|
||||
inject (_SortOptions_) ->
|
||||
SortOptions = _SortOptions_
|
||||
|
||||
describe "initialising predicate", ->
|
||||
it "sets predicate to blank", ->
|
||||
expect(SortOptions.predicate).toEqual ""
|
||||
|
||||
describe "initialising reverse", ->
|
||||
it "sets reverse to true", ->
|
||||
expect(SortOptions.reverse).toBe true
|
||||
Reference in New Issue
Block a user