From 4b5f1ddae2e0c8c13fdff792d3bcc6faf93063ed Mon Sep 17 00:00:00 2001 From: doliinyk Date: Thu, 16 Nov 2023 16:30:08 +0200 Subject: [PATCH] Changed application request showBlocked mode & its behaviour for All tab --- src/app/shared/models/application.model.ts | 6 +++--- .../applications/application.service.ts | 17 +++++++++-------- .../provider-applications.component.ts | 1 - .../applications/applications.component.ts | 17 ++++++++++------- 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/app/shared/models/application.model.ts b/src/app/shared/models/application.model.ts index 7b9910381c..d1a1f45a87 100644 --- a/src/app/shared/models/application.model.ts +++ b/src/app/shared/models/application.model.ts @@ -1,9 +1,9 @@ -import { ApplicationStatuses } from './../enum/statuses'; import { ApplicationEntityType } from '../enum/applications'; +import { ApplicationStatuses } from './../enum/statuses'; import { Child } from './child.model'; import { ParentWithContactInfo } from './parent.model'; -import { Workshop, WorkshopCard } from './workshop.model'; import { PaginationParameters } from './queryParameters.model'; +import { Workshop, WorkshopCard } from './workshop.model'; export class Application { id: string; @@ -46,7 +46,7 @@ export interface ApplicationFilterParameters extends PaginationParameters { searchString?: string; property?: ApplicationEntityType; statuses: ApplicationStatuses[]; - showBlocked: boolean; + showBlocked?: boolean; orderByDateAscending?: boolean; orderByAlphabetically?: boolean; orderByStatus?: boolean; diff --git a/src/app/shared/services/applications/application.service.ts b/src/app/shared/services/applications/application.service.ts index 0db2e1ea9c..b7208f43d2 100644 --- a/src/app/shared/services/applications/application.service.ts +++ b/src/app/shared/services/applications/application.service.ts @@ -12,7 +12,7 @@ import { SearchResponse } from '../../models/search.model'; export class ApplicationService { constructor(private http: HttpClient) {} - getAllApplications(parameters: ApplicationFilterParameters): Observable> { + public getAllApplications(parameters: ApplicationFilterParameters): Observable> { const options = { params: this.setParams(parameters) }; return this.http.get>('/api/v1/applications', options); } @@ -22,7 +22,7 @@ export class ApplicationService { * @param id string * @param parameters ApplicationFilterParameters */ - getApplicationsByPropertyId(id: string, parameters: ApplicationFilterParameters): Observable> { + public getApplicationsByPropertyId(id: string, parameters: ApplicationFilterParameters): Observable> { const options = { params: this.setParams(parameters) }; return this.http.get>(`/api/v1/${parameters.property}/${id}/applications`, options); @@ -33,7 +33,7 @@ export class ApplicationService { * @param parentId string * @param workshopId string */ - getApplicationsAllowedToReview(parentId: string, workshopId: string): Observable { + public getApplicationsAllowedToReview(parentId: string, workshopId: string): Observable { return this.http.get(`/api/v1/applications/reviewable/parents/${parentId}/workshops/${workshopId}`); } @@ -41,7 +41,7 @@ export class ApplicationService { * This method create Application * @param application Application */ - createApplication(application: Application): Observable> { + public createApplication(application: Application): Observable> { return this.http.post('/api/v1/applications', application, { observe: 'response' }); } @@ -49,7 +49,7 @@ export class ApplicationService { * This method update Application * @param application ApplicationUpdate */ - updateApplication(application: ApplicationUpdate): Observable { + public updateApplication(application: ApplicationUpdate): Observable { return this.http.put('/api/v1/applications', application); } @@ -58,7 +58,7 @@ export class ApplicationService { * @param childId string * @param workshopId string */ - getStatusIsAllowToApply(childId: string, workshopId: string): Observable { + public getStatusIsAllowToApply(childId: string, workshopId: string): Observable { return this.http.get(`/api/v1/applications/allowed/workshops/${workshopId}/children/${childId}`); } @@ -84,8 +84,9 @@ export class ApplicationService { if (parameters.from) { params = params.set('From', parameters.from.toString()); } - - params = params.set('ShowBlocked', parameters.showBlocked.toString()); + if (parameters.showBlocked !== undefined && parameters.showBlocked !== null) { + params = params.set('ShowBlocked', parameters.showBlocked.toString()); + } } params = params.set('OrderByDateAscending', 'true').set('OrderByAlphabetically', 'true').set('OrderByStatus', 'true'); diff --git a/src/app/shell/personal-cabinet/provider/provider-applications/provider-applications.component.ts b/src/app/shell/personal-cabinet/provider/provider-applications/provider-applications.component.ts index fe191211fd..f295290b79 100644 --- a/src/app/shell/personal-cabinet/provider/provider-applications/provider-applications.component.ts +++ b/src/app/shell/personal-cabinet/provider/provider-applications/provider-applications.component.ts @@ -44,7 +44,6 @@ export class ProviderApplicationsComponent extends CabinetDataComponent implemen statuses: [], workshops: [], children: [], - showBlocked: false, size: PaginationConstants.APPLICATIONS_PER_PAGE, from: 0 }; diff --git a/src/app/shell/personal-cabinet/shared-cabinet/applications/applications.component.ts b/src/app/shell/personal-cabinet/shared-cabinet/applications/applications.component.ts index cfe47f280a..fa3bc30452 100644 --- a/src/app/shell/personal-cabinet/shared-cabinet/applications/applications.component.ts +++ b/src/app/shell/personal-cabinet/shared-cabinet/applications/applications.component.ts @@ -6,13 +6,12 @@ import { Actions, ofActionCompleted, Select, Store } from '@ngxs/store'; import { Observable, Subject } from 'rxjs'; import { debounceTime, filter, takeUntil } from 'rxjs/operators'; -import { NotificationType } from 'shared/enum/notifications'; -import { GetDirections } from 'shared/store/meta-data.actions'; import { PaginationConstants } from 'shared/constants/constants'; import { ApplicationStatusTabParams } from 'shared/enum/applications'; import { ChildDeclination, WorkshopDeclination } from 'shared/enum/enumUA/declinations/declination'; import { NoResultsTitle } from 'shared/enum/enumUA/no-results'; import { ApplicationTitles } from 'shared/enum/enumUA/statuses'; +import { NotificationType } from 'shared/enum/notifications'; import { Role } from 'shared/enum/role'; import { ApplicationStatuses } from 'shared/enum/statuses'; import { Application, ApplicationFilterParameters } from 'shared/models/application.model'; @@ -20,6 +19,7 @@ import { Child } from 'shared/models/child.model'; import { PaginationElement } from 'shared/models/paginationElement.model'; import { SearchResponse } from 'shared/models/search.model'; import { Workshop } from 'shared/models/workshop.model'; +import { GetDirections } from 'shared/store/meta-data.actions'; import { ReadUsersNotificationsByType } from 'shared/store/notifications.actions'; import { OnUpdateApplicationSuccess } from 'shared/store/shared-user.actions'; import { SharedUserState } from 'shared/store/shared-user.state'; @@ -39,7 +39,6 @@ export class ApplicationsComponent implements OnInit, OnDestroy, AfterViewInit { @Select(SharedUserState.applications) private applicationCards$: Observable>; - public applicationCards: SearchResponse; @Select(SharedUserState.isLoading) public isLoadingCabinet$: Observable; @@ -62,6 +61,7 @@ export class ApplicationsComponent implements OnInit, OnDestroy, AfterViewInit { private destroy$: Subject = new Subject(); + public applicationCards: SearchResponse; public isActiveInfoButton = false; public currentPage: PaginationElement = PaginationConstants.firstPage; public isMobileView: boolean; @@ -115,7 +115,7 @@ export class ApplicationsComponent implements OnInit, OnDestroy, AfterViewInit { /** * This method get the list of application according to the selected tab - * @param workshopsId: number[] + * @param event */ public onTabChange(event: MatTabChangeEvent): void { this.router.navigate(['./'], { @@ -140,9 +140,12 @@ export class ApplicationsComponent implements OnInit, OnDestroy, AfterViewInit { } private setFilterParams(applicationStatus: string, tabIndex?: number): void { - const statuses = ApplicationStatuses[applicationStatus] ? [ApplicationStatuses[applicationStatus]] : []; - this.applicationParams.statuses = statuses; - this.applicationParams.showBlocked = tabIndex === ApplicationStatusTabParams.Blocked; + this.applicationParams.statuses = ApplicationStatuses[applicationStatus] ? [ApplicationStatuses[applicationStatus]] : []; + if (tabIndex === ApplicationStatusTabParams.All) { + delete this.applicationParams.showBlocked; + } else { + this.applicationParams.showBlocked = tabIndex === ApplicationStatusTabParams.Blocked; + } } private getApplicationData(): void {