Update plugin and rename filter dialog to sort dialog
Signed-off-by: trivernis <trivernis@protonmail.com>pull/4/head
parent
f706032c7a
commit
4a0a946deb
@ -1,20 +1,20 @@
|
||||
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {FilterDialogComponent} from './filter-dialog.component';
|
||||
import {SortDialogComponent} from './sort-dialog.component';
|
||||
|
||||
describe('FilterDialogComponent', () => {
|
||||
let component: FilterDialogComponent;
|
||||
let fixture: ComponentFixture<FilterDialogComponent>;
|
||||
let component: SortDialogComponent;
|
||||
let fixture: ComponentFixture<SortDialogComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [FilterDialogComponent]
|
||||
declarations: [SortDialogComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(FilterDialogComponent);
|
||||
fixture = TestBed.createComponent(SortDialogComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
@ -0,0 +1,54 @@
|
||||
import {TagQuery} from "./TagQuery";
|
||||
|
||||
export interface FilterExpression {
|
||||
filter_type: "OrExpression" | "Query";
|
||||
filter: TagQuery[] | TagQuery;
|
||||
|
||||
eq(value: any): boolean;
|
||||
|
||||
partiallyEq(value: any): boolean;
|
||||
|
||||
getDisplayName(): string;
|
||||
}
|
||||
|
||||
export class OrFilterExpression implements FilterExpression{
|
||||
public filter_type: "OrExpression" = "OrExpression";
|
||||
public filter: TagQuery[] = [];
|
||||
|
||||
constructor(tags: TagQuery[]) {
|
||||
this.filter = tags;
|
||||
}
|
||||
|
||||
public eq(value: any): boolean {
|
||||
return this == value
|
||||
}
|
||||
|
||||
public partiallyEq(value: any): boolean {
|
||||
return this == value;
|
||||
}
|
||||
|
||||
public getDisplayName(): string {
|
||||
return this.filter.map(t => t.getNormalizedTag()).join(" OR ");
|
||||
}
|
||||
}
|
||||
|
||||
export class SingleFilterExpression implements FilterExpression {
|
||||
public filter_type: "Query" = "Query";
|
||||
public filter: TagQuery;
|
||||
|
||||
constructor(tag: TagQuery) {
|
||||
this.filter = tag;
|
||||
}
|
||||
|
||||
public eq(value: any): boolean {
|
||||
return (this.filter.tag === value?.name && this.filter.negate === value?.negate) || this.filter.getNormalizedTag() === value;
|
||||
}
|
||||
|
||||
public partiallyEq(value: any): boolean {
|
||||
return this.filter.tag === value || this.filter.tag === value?.name;
|
||||
}
|
||||
|
||||
public getDisplayName(): string {
|
||||
return this.filter.getNormalizedTag();
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
export class TagQuery {
|
||||
constructor(public name: string, public negate: boolean) {
|
||||
constructor(public tag: string, public negate: boolean) {
|
||||
}
|
||||
|
||||
public getNormalizedTag(): string {
|
||||
return this.negate ? "-" + this.name : this.name;
|
||||
return this.negate ? "-" + this.tag : this.tag;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue