Remove status filters from simple filter display

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/4/head
trivernis 3 years ago
parent ae01ae9284
commit 52164db12e

@ -13,7 +13,7 @@
<div class="tag-input-list-inner"> <div class="tag-input-list-inner">
<div (click)="removeFilterExpression(filter)" <div (click)="removeFilterExpression(filter)"
(contextmenu)="this.contextMenuFilters.onContextMenu($event); this.contextMenuFilter = filter" (contextmenu)="this.contextMenuFilters.onContextMenu($event); this.contextMenuFilter = filter"
*ngFor="let filter of filters.getFilters()" *ngFor="let filter of this.displayedFilters"
class="tag-input-item" class="tag-input-item"
mat-ripple> mat-ripple>
<app-filter-expression-item [filter]="filter"></app-filter-expression-item> <app-filter-expression-item [filter]="filter"></app-filter-expression-item>

@ -12,6 +12,7 @@ import {SearchFilters} from "../../../../../api/models/SearchFilters";
import {FileStatus, FilterExpression,} from "../../../../../api/api-types/files"; import {FileStatus, FilterExpression,} from "../../../../../api/api-types/files";
import {filterExpressionToString} from "../../../../utils/filter-utils"; import {filterExpressionToString} from "../../../../utils/filter-utils";
import {MatCheckboxChange} from "@angular/material/checkbox"; import {MatCheckboxChange} from "@angular/material/checkbox";
import * as deepEqual from "fast-deep-equal";
@Component({ @Component({
@ -36,6 +37,7 @@ export class FileSearchComponent implements AfterViewChecked, OnInit {
public contextMenuTag: Tag | undefined; public contextMenuTag: Tag | undefined;
public contextMenuFilter: FilterExpression | undefined = undefined; public contextMenuFilter: FilterExpression | undefined = undefined;
public initialFilterInputValue: string | undefined; public initialFilterInputValue: string | undefined;
public displayedFilters: FilterExpression[] = [];
public displayImported = true; public displayImported = true;
public displayArchived = true; public displayArchived = true;
@ -47,14 +49,19 @@ export class FileSearchComponent implements AfterViewChecked, OnInit {
private errorBroker: ErrorBrokerService, private errorBroker: ErrorBrokerService,
public dialog: MatDialog public dialog: MatDialog
) { ) {
this.assignDisplayedFilters();
} }
public async ngOnInit() { public async ngOnInit() {
this.state.filters.subscribe(f => this.filters = f); this.state.filters.subscribe(f => {
this.filters = f;
this.assignDisplayedFilters();
});
this.state.sortKeys.subscribe(s => this.sortExpression = s); this.state.sortKeys.subscribe(s => this.sortExpression = s);
this.applyStatusFromFilters(); this.applyStatusFromFilters();
await this.searchForFiles(); await this.searchForFiles();
this.needsScroll = true; this.needsScroll = true;
this.assignDisplayedFilters();
} }
public ngAfterViewChecked(): void { public ngAfterViewChecked(): void {
@ -145,8 +152,8 @@ export class FileSearchComponent implements AfterViewChecked, OnInit {
filterDialog.afterClosed().subscribe(async (filterExpression) => { filterDialog.afterClosed().subscribe(async (filterExpression) => {
if (filterExpression !== undefined || filterExpression?.length > 0) { if (filterExpression !== undefined || filterExpression?.length > 0) {
this.filters = filterExpression; this.filters = filterExpression;
this.state.setTagFilters(this.filters);
this.applyStatusFromFilters(); this.applyStatusFromFilters();
this.state.setTagFilters(this.filters);
this.needsScroll = true; this.needsScroll = true;
} }
}); });
@ -175,6 +182,15 @@ export class FileSearchComponent implements AfterViewChecked, OnInit {
this.updateStatusFilters(); this.updateStatusFilters();
} }
public isTagFilter(filter: FilterExpression): boolean {
const tagFilter = this.buildFilterForDisplayProperty();
return deepEqual(tagFilter, filter);
}
private assignDisplayedFilters() {
this.displayedFilters = this.filters.getFilters().filter(f => !this.isTagFilter(f));
}
private applyStatusFromFilters() { private applyStatusFromFilters() {
const filterImported = FilterQueryBuilder.status("Imported"); const filterImported = FilterQueryBuilder.status("Imported");
const filterArchived = FilterQueryBuilder.status("Archived"); const filterArchived = FilterQueryBuilder.status("Archived");

Loading…
Cancel
Save