Commit 33263b6f authored by Julien's avatar Julien
Browse files

adding filter for motor

parent 6dafc61a
......@@ -6833,12 +6833,14 @@
"balanced-match": {
"version": "1.0.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
......@@ -6853,17 +6855,20 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"concat-map": {
"version": "0.0.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"core-util-is": {
"version": "1.0.2",
......@@ -6980,7 +6985,8 @@
"inherits": {
"version": "2.0.3",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"ini": {
"version": "1.3.5",
......@@ -6992,6 +6998,7 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
......@@ -7006,6 +7013,7 @@
"version": "3.0.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
......@@ -7013,12 +7021,14 @@
"minimist": {
"version": "0.0.8",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"minipass": {
"version": "2.2.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.1",
"yallist": "^3.0.0"
......@@ -7037,6 +7047,7 @@
"version": "0.5.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"minimist": "0.0.8"
}
......@@ -7117,7 +7128,8 @@
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"object-assign": {
"version": "4.1.1",
......@@ -7129,6 +7141,7 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"wrappy": "1"
}
......@@ -7250,6 +7263,7 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
......
......@@ -20,14 +20,23 @@
type="number" class="form-control" name="" id="nbDays"></div> jours.
</div>
<div class="form-row">
<div class="form-group">
<div class="form-group col">
<label for="inputType">Type</label>
<select name="" id="inputType" class="form-control">
<option value=""></option>
<option value="Voiture">Voiture</option>
<option value="Scooter">Scooter</option>
<option value="Velo">Velo</option>
</select>
</div>
<div class="form-group col">
<label for="inputMotor">Motorisation</label>
<select name="" id="inputMotor" class="form-control">
<option value=""></option>
<option value="ESSENCE">Essence</option>
<option value="ELECTRIQUE">Electrique</option>
</select>
</div>
</div>
<button class="btn btn-primary" (click)="filter()">Filtrer</button>
</fieldset>
......@@ -37,6 +46,8 @@
<div class="card-body">
<h5 class="card-title">{{vehicule.marque}}</h5>
<p class="card-text">{{vehicule.modele}}</p>
<p class="card-text"> Prix : {{vehicule.prix}} €</p>
<p class="card-text"> {{vehicule.nbPlace}} places</p>
<a href="#/vehicule/{{vehicule.id}}/view" class="card-link">En savoir plus</a>
</div>
</div>
......
......@@ -129,7 +129,7 @@ export class HomeComponent implements OnInit {
} else {
this.vehicules = vehicules.body;
}
// this.queryVehicules = this.vehicules;
this.queryVehicules = this.vehicules;
const type = (<HTMLInputElement>$('#inputType')[0]).value;
if (type === 'Voiture') {
this.queryVehicules = [];
......@@ -153,6 +153,18 @@ export class HomeComponent implements OnInit {
}
}
}
const motor = (<HTMLInputElement>$('#inputMotor')[0]).value;
if (motor !== '') {
for (let i = this.queryVehicules.length - 1; i >= 0; i--) {
if (this.queryVehicules[i].voiture !== null && this.queryVehicules[i].voiture.motorisation !== motor) {
this.queryVehicules.splice(i, 1);
} else if (this.queryVehicules[i].scooter !== null && this.queryVehicules[i].scooter.motorisation !== motor) {
this.queryVehicules.splice(i, 1);
}
}
}
});
}
}
Supports Markdown
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