mirror of
https://github.com/sismics/docs.git
synced 2024-11-22 14:07:55 +01:00
#158: advanced search form (wip)
This commit is contained in:
parent
742ff183bf
commit
23660961bd
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
angular.module('docs').controller('Document', function ($scope, $rootScope, $timeout, $state, Restangular, $q) {
|
angular.module('docs').controller('Document', function ($scope, $rootScope, $timeout, $state, Restangular, $q) {
|
||||||
/**
|
/**
|
||||||
* Documents table sort status.
|
* Scope variables.
|
||||||
*/
|
*/
|
||||||
$scope.sortColumn = 3;
|
$scope.sortColumn = 3;
|
||||||
$scope.asc = false;
|
$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.search = $state.params.search ? $state.params.search : '';
|
||||||
$scope.searchOpened = false;
|
$scope.searchOpened = false;
|
||||||
$scope.setSearch = function (search) { $scope.search = search };
|
$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
|
// A timeout promise is used to slow down search requests to the server
|
||||||
// We keep track of it for cancellation purpose
|
// We keep track of it for cancellation purpose
|
||||||
@ -149,21 +152,57 @@ angular.module('docs').controller('Document', function ($scope, $rootScope, $tim
|
|||||||
return deferred.promise;
|
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 () {
|
$rootScope.$on('$translateChangeSuccess', function () {
|
||||||
$scope.paginationShown = false;
|
$scope.paginationShown = false;
|
||||||
$timeout(function () {
|
$timeout(function () {
|
||||||
$scope.paginationShown = true;
|
$scope.paginationShown = true;
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
|
|
||||||
// Advanced search
|
/**
|
||||||
$scope.searchDropdownAnchor = angular.element(document.querySelector('.search-dropdown-anchor'));
|
* Open the advanced search panel.
|
||||||
|
*/
|
||||||
$scope.openSearch = function () {
|
$scope.openSearch = function () {
|
||||||
var opened = $scope.searchOpened;
|
var opened = $scope.searchOpened;
|
||||||
$timeout(function () {
|
$timeout(function () {
|
||||||
$scope.searchOpened = !opened;
|
$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;
|
||||||
|
};
|
||||||
});
|
});
|
@ -40,6 +40,7 @@ angular.module('docs').directive('selectTag', function() {
|
|||||||
// Add the new tag
|
// Add the new tag
|
||||||
if (tag) {
|
if (tag) {
|
||||||
if (!duplicate) {
|
if (!duplicate) {
|
||||||
|
if (!$scope.tags) $scope.tags = [];
|
||||||
$scope.tags.push(tag);
|
$scope.tags.push(tag);
|
||||||
}
|
}
|
||||||
$scope.input = '';
|
$scope.input = '';
|
||||||
|
@ -22,6 +22,15 @@
|
|||||||
"logout": "Logout"
|
"logout": "Logout"
|
||||||
},
|
},
|
||||||
"document": {
|
"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",
|
"add_document": "Add a document",
|
||||||
"tags": "Tags",
|
"tags": "Tags",
|
||||||
"no_tags": "No tags",
|
"no_tags": "No tags",
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
<input type="search" class="form-control" ng-attr-placeholder="{{ 'document.search' | translate }}" ng-model="search" />
|
<input type="search" class="form-control" ng-attr-placeholder="{{ 'document.search' | translate }}" ng-model="search" />
|
||||||
<span class="input-group-addon pointer" ng-click="openSearch()">
|
<span class="input-group-addon pointer" ng-click="openSearch()">
|
||||||
<div uib-dropdown
|
<div uib-dropdown
|
||||||
auto-close="outsideClick" is-open="searchOpened" dropdown-append-to="searchDropdownAnchor">
|
auto-close="disabled" is-open="searchOpened" dropdown-append-to="searchDropdownAnchor">
|
||||||
<span class="btn-open-search">
|
<span class="btn-open-search">
|
||||||
<span class="glyphicon glyphicon-search"></span>
|
<span class="glyphicon glyphicon-search"></span>
|
||||||
<span class="caret"></span>
|
<span class="caret"></span>
|
||||||
@ -61,12 +61,49 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="control-label sr-only" for="inputSearchAfterDate">{{ 'document.search_after_date' | translate }}</label>
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<input type="text" id="inputSearchAfterDate"
|
||||||
|
ng-attr-placeholder="{{ 'document.search_after_date' | translate }}"
|
||||||
|
current-text="{{ 'directive.datepicker.current' | translate }}"
|
||||||
|
clear-text="{{ 'directive.datepicker.clear' | translate }}"
|
||||||
|
close-text="{{ 'directive.datepicker.close' | translate }}"
|
||||||
|
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" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="control-label sr-only" for="inputSearchBeforeDate">{{ 'document.search_before_date' | translate }}</label>
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<input type="text" id="inputSearchBeforeDate"
|
||||||
|
ng-attr-placeholder="{{ 'document.search_before_date' | translate }}"
|
||||||
|
current-text="{{ 'directive.datepicker.current' | translate }}"
|
||||||
|
clear-text="{{ 'directive.datepicker.clear' | translate }}"
|
||||||
|
close-text="{{ 'directive.datepicker.close' | translate }}"
|
||||||
|
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" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="control-label sr-only" for="inputSearchTags">{{ 'document.search_tags' | translate }}</label>
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<select-tag tags="advsearch.tags" ref="inputSearchTags"></select-tag>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group text-center">
|
<div class="form-group text-center">
|
||||||
<button type="submit" class="btn btn-primary">
|
<button type="submit" ng-click="startSearch()" class="btn btn-primary">
|
||||||
<span class="glyphicon glyphicon-search"></span> {{ 'document.search' | translate }}
|
<span class="glyphicon glyphicon-search"></span> {{ 'document.search' | translate }}
|
||||||
</button>
|
</button>
|
||||||
<button class="btn" ng-click="advsearch = {}">
|
<button class="btn" ng-click="clearSearch()">
|
||||||
{{ 'document.clear' | translate }}
|
{{ 'document.search_clear' | translate }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
@ -54,6 +54,7 @@
|
|||||||
.row-full {
|
.row-full {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
margin-top: -20px !important;
|
margin-top: -20px !important;
|
||||||
|
min-height: 80vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
.well-full {
|
.well-full {
|
||||||
|
Loading…
Reference in New Issue
Block a user