Skip to content

Commit

Permalink
fix: fix rejected request list
Browse files Browse the repository at this point in the history
  • Loading branch information
josephatJ committed Jul 11, 2022
1 parent 3e5f9ea commit ae6f2c1
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
<tbody>
<ng-container
*ngFor="
let dataRow of params?.allDataForUserSupport?.data;
let dataRow of params?.allDataForUserSupport?.data
| FilterFormRequests: 'status':'REJECTED';
let count = index
"
>
Expand All @@ -34,6 +35,7 @@
<tr>
<td>{{ count + 1 }}</td>
<td>
{{ dataRow?.status }}
{{ dataRow?.action }}
</td>
<td>
Expand Down Expand Up @@ -81,20 +83,22 @@
This is alerting request. Approve only when you have
confirmed
</p>
<button
mat-stroked-button
(click)="onApprove($event, dataRow)"
class="btn-success float-right mt-5 ml-2"
>
Approve
</button>
<button
mat-stroked-button
(click)="onReject($event, dataRow)"
class="btn-danger float-right mt-5 ml-2"
>
Reject
</button>
<div class="d-flex justify-content-end">
<button
mat-stroked-button
(click)="onApprove($event, dataRow)"
class="btn-success mt-5 ml-2"
>
Approve
</button>
<button
mat-stroked-button
(click)="onReject($event, dataRow)"
class="btn-danger mt-5 ml-2"
>
Reject
</button>
</div>
</div>
</div>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
});
}
}
15 changes: 15 additions & 0 deletions src/app/shared/pipes/filter-requests.pipe.ts
Original file line number Diff line number Diff line change
@@ -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) || []
);
}
}
9 changes: 8 additions & 1 deletion src/app/shared/shared.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -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 {}

0 comments on commit ae6f2c1

Please sign in to comment.