dimanche 3 novembre 2019

Checkbox filter does not filter unchecked box

i tried to use checkbox to filter the list. The thing is, it does filter the checked box but somehow did not filter the unchecked ones.

I need the result to meet the condition of each of the checked and unchecked boxes.

I'm using Angular 7 and Bootstrap 4. Below is my code. Hope someone can help me with this, thanks.

HTML:

HTML: Approve By TA Transferred DOR Report

TS:

ngOnInit() {

this.formFilter = this._formBuilder.group({
  keyword: null,
  isSmeApproved: null,
  isTAApproved: null,
  isTransfered: null,
  isDorReport: null
});

this.formFilter.valueChanges
  .pipe(
    startWith(this.formFilter.value),
    takeUntil(this.destroy$),
    tap(() => {
      this.tableLoading$.next(true);
    }),
    debounceTime(600),
    distinctUntilChanged(),
    switchMap(formValue => {
      return this._dataExtractionService.getReports()
        .pipe(
          tap(() => {
            this.tableLoading$.next(false);
          }),
          map(report => {
            if (formValue.keyword) {
              report.extractedReport = report.extractedReport.filter(r => r.fileName.indexOf(formValue.keyword) !== -1);
            }

            if (formValue.isSmeApproved) {
              report.extractedReport = report.extractedReport.filter(r => r.isSmeApproved);
            }

            if (formValue.isTAApproved) {
              report.extractedReport = report.extractedReport.filter(r => r.isTAApproved);
            }

            if (formValue.isTransfered) {
              report.extractedReport = report.extractedReport.filter(r => r.isTransfered);
            }

            if (formValue.isDorReport) {
              report.extractedReport = report.extractedReport.filter(r => r.isDorReport);
            }

            return report;
          })
        )
    })
  )
  .subscribe();

}




Aucun commentaire:

Enregistrer un commentaire