Commit b85d9413 authored by luxcem's avatar luxcem

recherche multiple

parent 2587bd0b
......@@ -49,79 +49,41 @@ angular.module('soussurveillance')
currentDepute = depute;
}
};
$scope.changeName = function changeName(){
if ($scope.search.name === '') {
$scope.deputes = deputes;
} else {
var search = $scope.search.name.toLowerCase();
$scope.deputes = _.filter(deputes, function(depute) {
return depute.depute.nom.toLowerCase().indexOf(search) > -1;
$scope.applySearch = function applySearch() {
var filteredDeputes = deputes;
if ($scope.search.group !== '') {
filteredDeputes = _.filter(filteredDeputes, function(depute) {
return depute.depute.groupe_sigle === $scope.search.group;
});
}
$scope.search.group = '';
$scope.search.circ = '';
$scope.search.status = '';
hideCurrentDepute();
$scope.totalItems = $scope.deputes.length;
$scope.applyPaginate();
};
if ($scope.search.status !== '') {
filteredDeputes = _.filter(filteredDeputes, function(depute) {
return deputes.infos.position === parseInt($scope.search.status, 10);
});
}
$scope.changeCirc = function changeCirc() {
if ($scope.search.circ === '') {
$scope.deputes = deputes;
} else {
$scope.deputes = _.filter(deputes, function(depute) {
if ($scope.search.circ !== '') {
filteredDeputes = _.filter(filteredDeputes, function(depute) {
return depute.depute.nom_circo === $scope.search.circ;
});
}
$scope.search.group = '';
$scope.search.name = '';
$scope.search.status = '';
hideCurrentDepute();
$scope.totalItems = $scope.deputes.length;
$scope.applyPaginate();
};
$scope.changeStatus = function changeStatus() {
if ($scope.search.status === '') {
$scope.deputes = deputes;
} else {
$scope.deputes = _.filter(deputes, function(depute) {
var infos = DeputesInfos[depute.depute.slug];
return infos.position === parseInt($scope.search.status, 10);
});
if ($scope.search.name !== '') {
var search = $scope.search.name.toLowerCase();
filteredDeputes = _.filter(filteredDeputes, function(depute) {
return depute.depute.nom.toLowerCase().indexOf(search) > -1;
});
}
$scope.search.group = '';
$scope.search.circ = '';
$scope.search.name = '';
hideCurrentDepute();
$scope.totalItems = $scope.deputes.length;
$scope.applyPaginate();
};
$scope.deputes = filteredDeputes;
$scope.changeGroup = function changeGroup() {
if ($scope.search.group === '') {
$scope.deputes = deputes;
} else {
$scope.deputes = _.filter(deputes, function(depute) {
return depute.depute.groupe_sigle === $scope.search.group;
});
}
$scope.search.circ = '';
$scope.search.name = '';
$scope.search.status = '';
hideCurrentDepute();
$scope.totalItems = $scope.deputes.length;
$scope.applyPaginate();
};
$scope.applyPaginate = function applyPaginate() {
var begin = (($scope.currentPage - 1) * $scope.numPerPage);
var end = begin + $scope.numPerPage;
......
......@@ -4,7 +4,7 @@
<div class="row">
<div class="form-group col-md-4">
<label for="circonscriptionFilter">Circonscription</label>
<select id="circonscriptionFilter" class="form-control" ng-change="changeCirc()" ng-model="search.circ">
<select id="circonscriptionFilter" class="form-control" ng-change="applySearch()" ng-model="search.circ">
<option></option>
<option ng-repeat="circ in Circonscriptions | orderBy:circ " value="{{circ}}">{{circ}}</option>
</select>
......@@ -12,7 +12,7 @@
<div class="form-group col-md-4">
<label for="groupFilter">Groupe</label>
<select id="groupFilter" class="form-control" ng-change="changeGroup()" ng-model="search.group">
<select id="groupFilter" class="form-control" ng-change="applySearch()" ng-model="search.group">
<option></option>
<option ng-repeat="(groupe, nom) in Groupes | orderBy:groupe" value="{{ groupe }}">{{ groupe }} - {{ nom }}</option>
</select>
......@@ -20,7 +20,7 @@
<div class="form-group col-md-4">
<label for="statusFilter">Position</label>
<select id="statusFilter" class="form-control" ng-change="changeStatus()" ng-model="search.status">
<select id="statusFilter" class="form-control" ng-change="applySearch()" ng-model="search.status">
<option></option>
<option value="0">Inconnues</option>
<option value="1">Opposées au texte</option>
......@@ -31,7 +31,7 @@
</div>
<div class="form-group">
<input type="text" ng-model="search.name" class="form-control" placeholder="Recherche…" ng-change="changeName()">
<input type="text" ng-model="search.name" class="form-control" placeholder="Recherche…" ng-change="applySearch()">
</div>
</form>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment