Cześć.
Dostaję dane z inputów w takiej formie :
[
{ name: "Producent", checked: true },
{ name: "Handel", checked: true },
{ name: "Simple", checked: true }
];
Zmieniać się mogą tylko wartości checked z true na false i odwrotnie. Przypisane jest to do zmiennej checkedTypeOfClient . Chciałbym później wyfiltrować swoich wszystkich klientów( tablica currentClientList) na podstawie zmiennej checkedTypeOfClient.
Tutaj właściwości klasy Client :
export class Client {
clientId: number;
name: string ;
district: string;
province: string;
zip: string;
city: string;
// tslint:disable-next-line: variable-name
full_Address: string;
latitude: number;
longitude: number;
segment: string;
ph: string;
bh: number;
canal: string;
isSimple: string;
}
Komplikacja tego zadania polega na tym że filtracja przebiega tak. Wartości Producent i Handel to wartości które mogą być umieszczone w kolumnie canal które są w Klasie Client, a wartość Simple to wartość która jest również jest w klasie Client w kolumnie isSimple i może przyjmować wartość "TAK" lub "NIE"
na razie co mi się udało zrobić to wyciągnąć jakie wartości Producent, Handel,Simple są zaznaczone oraz przemielić pole Simple na "TAK" lub NIE"
filterClients() {
console.log(this.checkedTypeOfClient);
const filter={
Producent:this.checkedTypeOfClient.find(x=>x.name=="Producent").checked,
Handel:this.checkedTypeOfClient.find(x=>x.name=="Handel").checked,
Simple:this.checkedTypeOfClient.find(x=>x.name=="Simple").checked
}
let simpleFilter = this.returnFilterSimpleValue(filter.Simple);
this.currentClientList = this.baseClientList;
}
returnFilterSimpleValue(value : boolean) : string {
switch (value) {
case true:
return "TAK";
case false:
return "NIE";
}
Pytanie jak to przefiltrować ?