Commit b85d9413 authored by luxcem's avatar luxcem

recherche multiple

parent 2587bd0b
...@@ -50,78 +50,40 @@ angular.module('soussurveillance') ...@@ -50,78 +50,40 @@ angular.module('soussurveillance')
} }
}; };
$scope.changeName = function changeName(){ $scope.applySearch = function applySearch() {
if ($scope.search.name === '') { var filteredDeputes = deputes;
$scope.deputes = deputes; if ($scope.search.group !== '') {
} else { filteredDeputes = _.filter(filteredDeputes, function(depute) {
var search = $scope.search.name.toLowerCase(); return depute.depute.groupe_sigle === $scope.search.group;
$scope.deputes = _.filter(deputes, function(depute) {
return depute.depute.nom.toLowerCase().indexOf(search) > -1;
}); });
} }
$scope.search.group = '';
$scope.search.circ = '';
$scope.search.status = '';
hideCurrentDepute();
$scope.totalItems = $scope.deputes.length; if ($scope.search.status !== '') {
$scope.applyPaginate(); filteredDeputes = _.filter(filteredDeputes, function(depute) {
}; return deputes.infos.position === parseInt($scope.search.status, 10);
});
}
$scope.changeCirc = function changeCirc() { if ($scope.search.circ !== '') {
if ($scope.search.circ === '') { filteredDeputes = _.filter(filteredDeputes, function(depute) {
$scope.deputes = deputes;
} else {
$scope.deputes = _.filter(deputes, function(depute) {
return depute.depute.nom_circo === $scope.search.circ; 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.name !== '') {
if ($scope.search.status === '') { var search = $scope.search.name.toLowerCase();
$scope.deputes = deputes; filteredDeputes = _.filter(filteredDeputes, function(depute) {
} else { return depute.depute.nom.toLowerCase().indexOf(search) > -1;
$scope.deputes = _.filter(deputes, function(depute) {
var infos = DeputesInfos[depute.depute.slug];
return infos.position === parseInt($scope.search.status, 10);
}); });
} }
$scope.search.group = ''; $scope.deputes = filteredDeputes;
$scope.search.circ = '';
$scope.search.name = '';
hideCurrentDepute();
$scope.totalItems = $scope.deputes.length;
$scope.applyPaginate();
};
$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(); hideCurrentDepute();
$scope.totalItems = $scope.deputes.length; $scope.totalItems = $scope.deputes.length;
$scope.applyPaginate(); $scope.applyPaginate();
}; };
$scope.applyPaginate = function applyPaginate() { $scope.applyPaginate = function applyPaginate() {
var begin = (($scope.currentPage - 1) * $scope.numPerPage); var begin = (($scope.currentPage - 1) * $scope.numPerPage);
var end = begin + $scope.numPerPage; var end = begin + $scope.numPerPage;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<div class="row"> <div class="row">
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="circonscriptionFilter">Circonscription</label> <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></option>
<option ng-repeat="circ in Circonscriptions | orderBy:circ " value="{{circ}}">{{circ}}</option> <option ng-repeat="circ in Circonscriptions | orderBy:circ " value="{{circ}}">{{circ}}</option>
</select> </select>
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="groupFilter">Groupe</label> <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></option>
<option ng-repeat="(groupe, nom) in Groupes | orderBy:groupe" value="{{ groupe }}">{{ groupe }} - {{ nom }}</option> <option ng-repeat="(groupe, nom) in Groupes | orderBy:groupe" value="{{ groupe }}">{{ groupe }} - {{ nom }}</option>
</select> </select>
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="statusFilter">Position</label> <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></option>
<option value="0">Inconnues</option> <option value="0">Inconnues</option>
<option value="1">Opposées au texte</option> <option value="1">Opposées au texte</option>
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
</div> </div>
<div class="form-group"> <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> </div>
</form> </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