diff --git a/docs-web/src/main/webapp/src/app/docs/controller/document/Document.js b/docs-web/src/main/webapp/src/app/docs/controller/document/Document.js index 88decb32..d75f084f 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/document/Document.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/document/Document.js @@ -5,7 +5,7 @@ */ angular.module('docs').controller('Document', function ($scope, $rootScope, $timeout, $state, Restangular, $q) { /** - * Documents table sort status. + * Scope variables. */ $scope.sortColumn = 3; $scope.asc = false; @@ -15,6 +15,9 @@ angular.module('docs').controller('Document', function ($scope, $rootScope, $tim $scope.search = $state.params.search ? $state.params.search : ''; $scope.searchOpened = false; $scope.setSearch = function (search) { $scope.search = search }; + $scope.searchDropdownAnchor = angular.element(document.querySelector('.search-dropdown-anchor')); + $scope.paginationShown = true; + $scope.advsearch = {}; // A timeout promise is used to slow down search requests to the server // We keep track of it for cancellation purpose @@ -149,21 +152,57 @@ angular.module('docs').controller('Document', function ($scope, $rootScope, $tim return deferred.promise; }; - // Hack to reload the pagination directive after language change - $scope.paginationShown = true; + /** + * Hack to reload the pagination directive after language change. + */ $rootScope.$on('$translateChangeSuccess', function () { $scope.paginationShown = false; $timeout(function () { $scope.paginationShown = true; }); - }) + }); - // Advanced search - $scope.searchDropdownAnchor = angular.element(document.querySelector('.search-dropdown-anchor')); + /** + * Open the advanced search panel. + */ $scope.openSearch = function () { var opened = $scope.searchOpened; $timeout(function () { $scope.searchOpened = !opened; }); - } + }; + + /** + * Start the advanced search. + */ + $scope.startSearch = function () { + var search = ''; + if (!_.isEmpty($scope.advsearch.search_simple)) { + search += $scope.advsearch.search_simple + ' '; + } + if (!_.isEmpty($scope.advsearch.search_fulltext)) { + search += 'full:' + $scope.advsearch.search_fulltext + ' '; + } + if (!_.isEmpty($scope.advsearch.creator)) { + search += 'by:' + $scope.advsearch.creator + ' '; + } + if (!_.isEmpty($scope.advsearch.language)) { + search += 'lang:' + $scope.advsearch.language + ' '; + } + $scope.advsearch.after_date; + $scope.advsearch.before_date; + if (!_.isEmpty($scope.advsearch.tags)) { + search += _.reduce($scope.advsearch.tags, function(s, t) { + return s + 'tag:' + t + ' '; + }, ''); + } + $scope.search = search; + $scope.searchOpened = false; + }; + + $scope.clearSearch = function () { + $scope.advsearch = {}; + $scope.search = ''; + $scope.searchOpened = false; + }; }); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/app/docs/directive/SelectTag.js b/docs-web/src/main/webapp/src/app/docs/directive/SelectTag.js index 3765e0b8..84b4ac2f 100644 --- a/docs-web/src/main/webapp/src/app/docs/directive/SelectTag.js +++ b/docs-web/src/main/webapp/src/app/docs/directive/SelectTag.js @@ -40,6 +40,7 @@ angular.module('docs').directive('selectTag', function() { // Add the new tag if (tag) { if (!duplicate) { + if (!$scope.tags) $scope.tags = []; $scope.tags.push(tag); } $scope.input = ''; diff --git a/docs-web/src/main/webapp/src/locale/en.json b/docs-web/src/main/webapp/src/locale/en.json index 71866c63..0935ad54 100644 --- a/docs-web/src/main/webapp/src/locale/en.json +++ b/docs-web/src/main/webapp/src/locale/en.json @@ -22,6 +22,15 @@ "logout": "Logout" }, "document": { + "search_simple": "Simple search", + "search_fulltext": "Fulltext search", + "search_creator": "Creator", + "search_language": "Language", + "search_before_date": "Before this date", + "search_after_date": "After this date", + "search_tags": "Tags", + "search_clear": "Clear", + "any_language": "Any language", "add_document": "Add a document", "tags": "Tags", "no_tags": "No tags", diff --git a/docs-web/src/main/webapp/src/partial/docs/document.html b/docs-web/src/main/webapp/src/partial/docs/document.html index a96544a2..86bd4f4a 100644 --- a/docs-web/src/main/webapp/src/partial/docs/document.html +++ b/docs-web/src/main/webapp/src/partial/docs/document.html @@ -20,7 +20,7 @@
+ auto-close="disabled" is-open="searchOpened" dropdown-append-to="searchDropdownAnchor"> @@ -61,12 +61,49 @@
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+
- -
diff --git a/docs-web/src/main/webapp/src/style/main.less b/docs-web/src/main/webapp/src/style/main.less index e31c74c6..51038a1c 100644 --- a/docs-web/src/main/webapp/src/style/main.less +++ b/docs-web/src/main/webapp/src/style/main.less @@ -54,6 +54,7 @@ .row-full { overflow: hidden; margin-top: -20px !important; + min-height: 80vh; } .well-full {