diff --git a/src/ipa-bcfier-ui/src/app/components/bcf-file/bcf-file.component.ts b/src/ipa-bcfier-ui/src/app/components/bcf-file/bcf-file.component.ts index 9a13a06..a7c6969 100644 --- a/src/ipa-bcfier-ui/src/app/components/bcf-file/bcf-file.component.ts +++ b/src/ipa-bcfier-ui/src/app/components/bcf-file/bcf-file.component.ts @@ -150,11 +150,22 @@ export class BcfFileComponent { } filterIssues(filters: FormGroup): void { - const { status, type, users, issueRange } = filters.value; + const { + withoutStatus, + status, + withoutType, + type, + withoutUser, + users, + issueRange, + } = filters.value; if ( - status === undefined || - type === undefined || - users === undefined || + withoutStatus === undefined || + (!withoutStatus && status === undefined) || + withoutType === undefined || + (!withoutType && type === undefined) || + withoutUser === undefined || + (!withoutUser && users === undefined) || issueRange === undefined || issueRange?.start === undefined || issueRange?.end === undefined @@ -163,15 +174,25 @@ export class BcfFileComponent { } const isValuePresentInFilters = - !!status || !!type || !!users || !!issueRange.start || !!issueRange.end; + withoutStatus || + withoutType || + withoutUser || + !!status || + !!type || + !!users || + !!issueRange.start || + !!issueRange.end; this.filteredTopics = isValuePresentInFilters ? [ ...this.issueFilterService.filterIssue( this.bcfFile.topics, - status, - type, - users, + withoutStatus, + status || '', + withoutType, + type || '', + withoutUser, + users || [], issueRange?.start, issueRange?.end ), diff --git a/src/ipa-bcfier-ui/src/app/components/issue-filters/issue-filters.component.html b/src/ipa-bcfier-ui/src/app/components/issue-filters/issue-filters.component.html index 07c7a06..690559b 100644 --- a/src/ipa-bcfier-ui/src/app/components/issue-filters/issue-filters.component.html +++ b/src/ipa-bcfier-ui/src/app/components/issue-filters/issue-filters.component.html @@ -1,5 +1,6 @@
+ Without Status Status @@ -8,6 +9,7 @@ } + Without Type Type @@ -16,6 +18,9 @@ } + Without Responsible Responsible ; status: FormControl; + withoutType: FormControl; type: FormControl; + withoutUser: FormControl; users: FormControl; issueRange: FormGroup<{ start: FormControl; @@ -42,6 +46,7 @@ export interface IFilters { AsyncPipe, ReactiveFormsModule, MatDatepickerModule, + MatCheckboxModule, ], styleUrl: './issue-filters.component.scss', templateUrl: './issue-filters.component.html', @@ -72,14 +77,46 @@ export class IssueFiltersComponent { filtersForm: FormGroup; constructor() { this.filtersForm = this.fb.group({ + withoutStatus: new FormControl(false, { nonNullable: true }), status: new FormControl('', { nonNullable: true }), + withoutType: new FormControl(false, { nonNullable: true }), type: new FormControl('', { nonNullable: true }), + withoutUser: new FormControl(false, { nonNullable: true }), users: new FormControl([], { nonNullable: true }), issueRange: new FormGroup({ start: new FormControl(null), end: new FormControl(null), }), }); + + this.filtersForm.valueChanges.subscribe((value) => { + if (value.withoutStatus && this.filtersForm.controls.status.enabled) { + this.filtersForm.controls.status.disable(); + } else if ( + !value.withoutStatus && + this.filtersForm.controls.status.disabled + ) { + this.filtersForm.controls.status.enable(); + } + + if (value.withoutType && this.filtersForm.controls.type.enabled) { + this.filtersForm.controls.type.disable(); + } else if ( + !value.withoutType && + this.filtersForm.controls.type.disabled + ) { + this.filtersForm.controls.type.enable(); + } + + if (value.withoutUser && this.filtersForm.controls.users.enabled) { + this.filtersForm.controls.users.disable(); + } else if ( + !value.withoutUser && + this.filtersForm.controls.users.disabled + ) { + this.filtersForm.controls.users.enable(); + } + }); } acceptFilters(): void { diff --git a/src/ipa-bcfier-ui/src/app/services/issue-filter.service.ts b/src/ipa-bcfier-ui/src/app/services/issue-filter.service.ts index 7b41916..e097623 100644 --- a/src/ipa-bcfier-ui/src/app/services/issue-filter.service.ts +++ b/src/ipa-bcfier-ui/src/app/services/issue-filter.service.ts @@ -8,8 +8,11 @@ import { BcfTopic } from '../generated-client/generated-client'; export class IssueFilterService { filterIssue( issues: BcfTopic[], + withoutStatus: boolean, status: string, + withoutType: boolean, type: string, + withoutUser: boolean, users: string[], dateStart: Date | null, dateEnd: Date | null @@ -23,15 +26,21 @@ export class IssueFilterService { let passesUsers = true; let passesDate = true; - if (status && issue.topicStatus !== status) { + if (withoutStatus) { + passesStatus = !issue.topicStatus; + } else if (status && issue.topicStatus !== status) { passesStatus = false; } - if (type && issue.topicType !== type) { + if (withoutType) { + passesType = !issue.topicType; + } else if (type && issue.topicType !== type) { passesType = false; } - if ( + if (withoutUser) { + passesUsers = !issue.assignedTo; + } else if ( (users && users.length > 0 && issue.assignedTo && @@ -60,7 +69,6 @@ export class IssueFilterService { if ((dateStart || dateEnd) && !issue.dueDate) { passesDate = false; } - return passesStatus && passesType && passesDate && passesUsers; }); }