Closes #158: advanced search form

This commit is contained in:
Benjamin Gamard 2017-11-13 22:37:03 +01:00
parent 23660961bd
commit 00452cc505
3 changed files with 20 additions and 7 deletions

View File

@ -3,7 +3,7 @@
/**
* Document controller.
*/
angular.module('docs').controller('Document', function ($scope, $rootScope, $timeout, $state, Restangular, $q) {
angular.module('docs').controller('Document', function ($scope, $rootScope, $timeout, $state, Restangular, $q, $filter) {
/**
* Scope variables.
*/
@ -189,11 +189,15 @@ angular.module('docs').controller('Document', function ($scope, $rootScope, $tim
if (!_.isEmpty($scope.advsearch.language)) {
search += 'lang:' + $scope.advsearch.language + ' ';
}
$scope.advsearch.after_date;
$scope.advsearch.before_date;
if (!_.isUndefined($scope.advsearch.after_date)) {
search += 'after:' + $filter('date')($scope.advsearch.after_date, 'yyyy-MM-dd') + ' ';
}
if (!_.isUndefined($scope.advsearch.before_date)) {
search += 'before:' + $filter('date')($scope.advsearch.before_date, 'yyyy-MM-dd') + ' ';
}
if (!_.isEmpty($scope.advsearch.tags)) {
search += _.reduce($scope.advsearch.tags, function(s, t) {
return s + 'tag:' + t + ' ';
return s + 'tag:' + t.name + ' ';
}, '');
}
$scope.search = search;

View File

@ -22,6 +22,15 @@
"logout": "Déconnexion"
},
"document": {
"search_simple": "Recherche simple",
"search_fulltext": "Recherche texte intégral",
"search_creator": "Créateur",
"search_language": "Langue",
"search_before_date": "Avant cette date",
"search_after_date": "Après cette date",
"search_tags": "Tags",
"search_clear": "Réinitialiser",
"any_language": "Toutes les langues",
"add_document": "Ajouter un document",
"tags": "Tags",
"no_tags": "Aucun tag",

View File

@ -72,7 +72,7 @@
datepicker-append-to-body="true"
ng-readonly="true" uib-datepicker-popup="{{ dateFormat }}" class="form-control"
ng-model="advsearch.after_date" datepicker-options="{ startingDay:1, showWeeks: false }"
ng-click="datepickerAfterOpened = true" is-open="datepickerAfterOpened" />
ng-click="datepickerAfterOpened = !datepickerAfterOpened" is-open="datepickerAfterOpened" />
</div>
</div>
@ -87,7 +87,7 @@
datepicker-append-to-body="true"
ng-readonly="true" uib-datepicker-popup="{{ dateFormat }}" class="form-control"
ng-model="advsearch.before_date" datepicker-options="{ startingDay:1, showWeeks: false }"
ng-click="datepickerBeforeOpened = true" is-open="datepickerBeforeOpened" />
ng-click="datepickerBeforeOpened = !datepickerBeforeOpened" is-open="datepickerBeforeOpened" />
</div>
</div>
@ -113,7 +113,7 @@
</div>
</div>
{{advsearch}}
{{advsearch.before_date | date: 'yyyy-MM-dd'}}
<table class="row table table-hover table-documents">
<thead>