nitweb/angular: filter entity lists
[nit.git] / share / nitweb / javascripts / entities.js
index e56d676..255602c 100644 (file)
@@ -16,7 +16,7 @@
 
 (function() {
        angular
-               .module('entities', ['model'])
+               .module('entities', ['ui', 'model'])
 
                .controller('EntityCtrl', ['Model', '$routeParams', '$scope', function(Model, $routeParams, $scope) {
                        Model.loadEntity($routeParams.id,
                                scope: {
                                        listEntities: '=',
                                        listTitle: '@',
+                                       listObjectFilter: '=',
                                },
                                templateUrl: '/directives/entity/list.html',
+                               link: function ($scope, element, attrs) {
+                                       $scope.showFilters = false;
+                                       if(!$scope.listObjectFilter) {
+                                               $scope.listObjectFilter = {};
+                                       }
+                                       if(!$scope.visibilityFilter) {
+                                               $scope.visibilityFilter = {
+                                                       public: true,
+                                                       protected: true,
+                                                       private: false
+                                               };
+                                       }
+                                       $scope.toggleFilters = function() {
+                                               $scope.showFilters = !$scope.showFilters;
+                                       };
+                               }
                        };
                })
 })();