"use strict"; angular.module("vocabulary") .component("premadeCollection", { templateUrl: "/js/redesign-angular/premadeLessons/premade-resources-display.html", controller: "PremadeCollectionController", bindings:{ categoryId: '<', parentCategoryId: '<', levels: "<", resources: "<", description: "<", onUpdateNavigation: "&" } }) .controller("PremadeCollectionController", ["$filter", function ($filter) { var ctrl = this; this.$onInit = init; ctrl.filterField="categoryId"; ctrl.filterTitle="Unit"; ctrl.numColumns="4"; ctrl.inclusiveFiltering = false; ctrl.requiresFiltering = true; function init(){ ctrl.onUpdateNavigation({ $event:{ selectedParentCategoryId: parseInt(ctrl.parentCategoryId, 10), selectedSubCategoryId: parseInt(ctrl.categoryId, 10) } }); ctrl.filteredResources = ctrl.resources; } ctrl.numColumnsIsFour = function(){ return false; }; ctrl.numColumnsIsThree = function(){ return true; }; ctrl.updateFilteredResources = function(event){ ctrl.filteredResources = $filter('orderBy')(event.filteredResources, ['categorySortOrder', 'lessonName']); }; }]);