diff --git a/src/javascripts/ng-admin/Crud/list/ListLayoutController.js b/src/javascripts/ng-admin/Crud/list/ListLayoutController.js index 03886599..8edd3714 100644 --- a/src/javascripts/ng-admin/Crud/list/ListLayoutController.js +++ b/src/javascripts/ng-admin/Crud/list/ListLayoutController.js @@ -53,6 +53,10 @@ export default class ListLayoutController { $scope.selection = []; } + if(this.hasFilters){ + this.updateFilters(); + } + $scope.$on('$destroy', this.destroy.bind(this)); } diff --git a/src/javascripts/test/unit/Crud/list/ListLayoutControllerSpec.js b/src/javascripts/test/unit/Crud/list/ListLayoutControllerSpec.js index 0c55e1d5..b6e7b4a3 100644 --- a/src/javascripts/test/unit/Crud/list/ListLayoutControllerSpec.js +++ b/src/javascripts/test/unit/Crud/list/ListLayoutControllerSpec.js @@ -1,6 +1,42 @@ /*global describe,it,expect,beforeEach*/ +import ListLayoutController, {getCurrentSearchParam} from '../../../../ng-admin/Crud/list/ListLayoutController' + describe('ListLayoutController', function () { - var getCurrentSearchParam = require('../../../../ng-admin/Crud/list/ListLayoutController').getCurrentSearchParam; + describe('constructor', () => { + it('should update filters if initialized with any', () => { + spyOn(ListLayoutController.prototype, 'updateFilters'); + spyOn(ListLayoutController, 'getCurrentSearchParam') + .and.returnValue({}); + + const $scope = { + $watch: () => {}, + $on: () => {}, + }; + + const $location = { + path: () => '/my_entity', + search: () => '', + }; + + const view = { + getEntity: () => 'my_entity', + batchActions: () => [], + actions: () => [], + filters: () => [{ + my_column: 17, + pinned: () => true, + }], + }; + + const listLayoutController = new ListLayoutController( + $scope, null, null, $location, null, view, null + ); + + expect(ListLayoutController.prototype.updateFilters) + .toHaveBeenCalled(); + }); + }); + describe('getCurrentSearchParam', function () { it('should return search url parameter mapped by filter', function () {