From ae6f2c1c2d5e4c62f6708e090995e93cd86ed4d3 Mon Sep 17 00:00:00 2001 From: josephatJ Date: Mon, 11 Jul 2022 12:11:40 +0300 Subject: [PATCH] fix: fix rejected request list --- .../feedback-container.component.ts | 14 ++++---- .../feedbacks-list.component.html | 34 +++++++++++-------- .../feedbacks-list.component.ts | 19 +++++++++++ src/app/shared/pipes/filter-requests.pipe.ts | 15 ++++++++ src/app/shared/shared.module.ts | 9 ++++- 5 files changed, 68 insertions(+), 23 deletions(-) create mode 100644 src/app/shared/pipes/filter-requests.pipe.ts diff --git a/src/app/pages/reporting-tools-assignment/components/feedback-container/feedback-container.component.ts b/src/app/pages/reporting-tools-assignment/components/feedback-container/feedback-container.component.ts index fb22400..9919cb5 100644 --- a/src/app/pages/reporting-tools-assignment/components/feedback-container/feedback-container.component.ts +++ b/src/app/pages/reporting-tools-assignment/components/feedback-container/feedback-container.component.ts @@ -45,13 +45,13 @@ export class FeedbackContainerComponent implements OnInit { }; this.orgUnitLevels$ = this.orgUnitsProvisionalService.getOrgUnitLevels(); this.userSupportKeys$ = this.dataStoreService.getDataStoreKeys(); - // this.isFeedbackRecepient = - // ( - // this.currentUser?.userGroups.filter( - // (userGroup) => - // userGroup?.id === this.systemConfigs?.feedbackRecipients?.id - // ) || [] - // )?.length > 0; + this.isFeedbackRecepient = + ( + this.currentUser?.userGroups.filter( + (userGroup) => + userGroup?.id === this.systemConfigs?.feedbackRecipients?.id + ) || [] + )?.length > 0; } changeTab(val) { diff --git a/src/app/pages/reporting-tools-assignment/components/feedbacks-list/feedbacks-list.component.html b/src/app/pages/reporting-tools-assignment/components/feedbacks-list/feedbacks-list.component.html index 5fd891d..2945852 100644 --- a/src/app/pages/reporting-tools-assignment/components/feedbacks-list/feedbacks-list.component.html +++ b/src/app/pages/reporting-tools-assignment/components/feedbacks-list/feedbacks-list.component.html @@ -21,7 +21,8 @@ @@ -34,6 +35,7 @@ {{ count + 1 }} + {{ dataRow?.status }} {{ dataRow?.action }} @@ -81,20 +83,22 @@ This is alerting request. Approve only when you have confirmed

- - +
+ + +
diff --git a/src/app/pages/reporting-tools-assignment/components/feedbacks-list/feedbacks-list.component.ts b/src/app/pages/reporting-tools-assignment/components/feedbacks-list/feedbacks-list.component.ts index 2b12b1f..26f4999 100644 --- a/src/app/pages/reporting-tools-assignment/components/feedbacks-list/feedbacks-list.component.ts +++ b/src/app/pages/reporting-tools-assignment/components/feedbacks-list/feedbacks-list.component.ts @@ -75,4 +75,23 @@ export class FeedbacksListComponent implements OnInit { } }); } + + onDelete(event: Event, data: any): void { + event.stopPropagation(); + this.dialog + .open(RespondFeedbackComponent, { + width: '30%', + data: { ...data, actionType: 'REJECTED' }, + }) + .afterClosed() + .subscribe((shouldReload) => { + if (shouldReload) { + this.allDataForUserSupport$ = + this.dataStoreService.getAllFromNameSpace( + 'dataStore/dhis2-user-support', + this.configurations + ); + } + }); + } } diff --git a/src/app/shared/pipes/filter-requests.pipe.ts b/src/app/shared/pipes/filter-requests.pipe.ts new file mode 100644 index 0000000..f2169ce --- /dev/null +++ b/src/app/shared/pipes/filter-requests.pipe.ts @@ -0,0 +1,15 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ + name: 'FilterFormRequests', +}) +export class FilterFormRequestsPipe implements PipeTransform { + transform(values: any[], filteringKey: string, filteringValue: string): any { + if (!filteringKey || !filteringValue) { + return values; + } + return ( + values.filter((value) => value[filteringKey] != filteringValue) || [] + ); + } +} diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index 153d3dc..e83c7a3 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -7,6 +7,7 @@ import { materialModules } from './materials.module'; import { sharedComponents, sharedEntryComponents } from './components'; import { FormModule } from './modules/form/form.module'; import { SearchItemPipe } from './pipes/search-item.pipe'; +import { FilterFormRequestsPipe } from './pipes/filter-requests.pipe'; @NgModule({ imports: [ @@ -25,7 +26,13 @@ import { SearchItemPipe } from './pipes/search-item.pipe'; NgxDhis2DataFilterModule, NgxDhis2PeriodFilterModule, SearchItemPipe, + FilterFormRequestsPipe, + ], + declarations: [ + ...sharedComponents, + ...sharedEntryComponents, + SearchItemPipe, + FilterFormRequestsPipe, ], - declarations: [...sharedComponents, ...sharedEntryComponents, SearchItemPipe], }) export class SharedModule {}