From bef4488af1e9daf1d7b260a291a3f0cbee2ee217 Mon Sep 17 00:00:00 2001 From: Alexandre Terrasa Date: Tue, 31 May 2016 20:39:55 -0400 Subject: [PATCH] nitweb/angular: filter entity lists Signed-off-by: Alexandre Terrasa --- share/nitweb/directives/entity/list.html | 16 ++- share/nitweb/directives/ui-filter-button-vis.html | 6 ++ share/nitweb/directives/ui-filter-field.html | 4 + share/nitweb/directives/ui-filter-form.html | 6 ++ share/nitweb/directives/ui-filter-group-vis.html | 14 +++ share/nitweb/index.html | 1 + share/nitweb/javascripts/entities.js | 19 +++- share/nitweb/javascripts/ui.js | 109 +++++++++++++++++++++ share/nitweb/stylesheets/nitweb.css | 33 +++++++ 9 files changed, 203 insertions(+), 5 deletions(-) create mode 100644 share/nitweb/directives/ui-filter-button-vis.html create mode 100644 share/nitweb/directives/ui-filter-field.html create mode 100644 share/nitweb/directives/ui-filter-form.html create mode 100644 share/nitweb/directives/ui-filter-group-vis.html create mode 100644 share/nitweb/javascripts/ui.js diff --git a/share/nitweb/directives/entity/list.html b/share/nitweb/directives/entity/list.html index 9e40d82..cc026a4 100644 --- a/share/nitweb/directives/entity/list.html +++ b/share/nitweb/directives/entity/list.html @@ -1,11 +1,19 @@ -
+

{{listTitle}} +

+
+ +
- +
diff --git a/share/nitweb/directives/ui-filter-button-vis.html b/share/nitweb/directives/ui-filter-button-vis.html new file mode 100644 index 0000000..8d4f8d4 --- /dev/null +++ b/share/nitweb/directives/ui-filter-button-vis.html @@ -0,0 +1,6 @@ + diff --git a/share/nitweb/directives/ui-filter-field.html b/share/nitweb/directives/ui-filter-field.html new file mode 100644 index 0000000..05c51e4 --- /dev/null +++ b/share/nitweb/directives/ui-filter-field.html @@ -0,0 +1,4 @@ +
+ + +
diff --git a/share/nitweb/directives/ui-filter-form.html b/share/nitweb/directives/ui-filter-form.html new file mode 100644 index 0000000..9782af8 --- /dev/null +++ b/share/nitweb/directives/ui-filter-form.html @@ -0,0 +1,6 @@ +
+ +
+ +
+ diff --git a/share/nitweb/directives/ui-filter-group-vis.html b/share/nitweb/directives/ui-filter-group-vis.html new file mode 100644 index 0000000..7fcd475 --- /dev/null +++ b/share/nitweb/directives/ui-filter-group-vis.html @@ -0,0 +1,14 @@ +
+ + + +
diff --git a/share/nitweb/index.html b/share/nitweb/index.html index 2a4bdde..f2a54c5 100644 --- a/share/nitweb/index.html +++ b/share/nitweb/index.html @@ -40,5 +40,6 @@ + diff --git a/share/nitweb/javascripts/entities.js b/share/nitweb/javascripts/entities.js index e56d676..255602c 100644 --- a/share/nitweb/javascripts/entities.js +++ b/share/nitweb/javascripts/entities.js @@ -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, @@ -95,8 +95,25 @@ 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; + }; + } }; }) })(); diff --git a/share/nitweb/javascripts/ui.js b/share/nitweb/javascripts/ui.js new file mode 100644 index 0000000..aae0234 --- /dev/null +++ b/share/nitweb/javascripts/ui.js @@ -0,0 +1,109 @@ +/* + * Copyright 2016 Alexandre Terrasa . + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +(function() { + angular + .module('ui', [ 'model' ]) + + .directive('uiFilters', function() { + return { + restrict: 'E', + scope: { + property: '=', + classesOn: '=', + classesOff: '=' + }, + replace: true, + templateUrl: '/directives/ui-filter-button-vis.html', + link: function ($scope, element, attrs) { + $scope.toggle = function() { + $scope.property = !$scope.property; + } + } + }; + }) + + .filter('visibility', function() { + return function(input, visibilityFilter) { + var res = []; + input.forEach(function(entry) { + if(visibilityFilter.public == false && entry.visibility == "public") { + return; + } + if(visibilityFilter.protected == false && entry.visibility == "protected") { + return; + } + if(visibilityFilter.private == false && entry.visibility == "private") { + return; + } + res.push(entry); + }); + return res; + }; + }) + + .directive('uiFilterForm', function() { + return { + restrict: 'E', + scope: { + searchFilter: '=', + visibilityFilter: '=' + }, + replace: true, + templateUrl: '/directives/ui-filter-form.html' + }; + }) + + .directive('uiFilterField', function() { + return { + restrict: 'E', + scope: { + property: '=' + }, + replace: true, + templateUrl: '/directives/ui-filter-field.html' + }; + }) + + .directive('uiFilterGroupVis', function() { + return { + restrict: 'E', + scope: { + property: '=' + }, + replace: true, + templateUrl: '/directives/ui-filter-group-vis.html' + }; + }) + + .directive('uiFilterButtonVis', function() { + return { + restrict: 'E', + scope: { + property: '=', + classesOn: '=', + classesOff: '=' + }, + replace: true, + templateUrl: '/directives/ui-filter-button-vis.html', + link: function ($scope, element, attrs) { + $scope.toggle = function() { + $scope.property = !$scope.property; + } + } + }; + }) +})(); diff --git a/share/nitweb/stylesheets/nitweb.css b/share/nitweb/stylesheets/nitweb.css index ccecb1b..eca9c48 100644 --- a/share/nitweb/stylesheets/nitweb.css +++ b/share/nitweb/stylesheets/nitweb.css @@ -75,6 +75,16 @@ a { border-top: none; } +/* ui */ + +entity-list .btn-filter { + visibility: hidden; +} + +entity-list:hover .btn-filter { + visibility: visible; +} + /* doc */ .nitdoc .synopsys { @@ -112,6 +122,29 @@ a { background-color: #ff9c0f; } +/* forms */ + +.has-icon { + position: relative; +} + +.has-icon .form-control { + padding-left: 35px; +} + +.form-control-icon { + position: absolute; + top: 0; + left: 0; + z-index: 2; + display: block; + width: 34px; + height: 34px; + line-height: 34px; + text-align: center; + pointer-events: none; +} + /* * Code Highlighting */ -- 1.7.9.5