Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oliinyk / PR2296 Improvement #2301

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/app/shared/models/application.model.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
Expand Down
17 changes: 9 additions & 8 deletions src/app/shared/services/applications/application.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { SearchResponse } from '../../models/search.model';
export class ApplicationService {
constructor(private http: HttpClient) {}

getAllApplications(parameters: ApplicationFilterParameters): Observable<SearchResponse<Application[]>> {
public getAllApplications(parameters: ApplicationFilterParameters): Observable<SearchResponse<Application[]>> {
const options = { params: this.setParams(parameters) };
return this.http.get<SearchResponse<Application[]>>('/api/v1/applications', options);
}
Expand All @@ -22,7 +22,7 @@ export class ApplicationService {
* @param id string
* @param parameters ApplicationFilterParameters
*/
getApplicationsByPropertyId(id: string, parameters: ApplicationFilterParameters): Observable<SearchResponse<Application[]>> {
public getApplicationsByPropertyId(id: string, parameters: ApplicationFilterParameters): Observable<SearchResponse<Application[]>> {
const options = { params: this.setParams(parameters) };

return this.http.get<SearchResponse<Application[]>>(`/api/v1/${parameters.property}/${id}/applications`, options);
Expand All @@ -33,23 +33,23 @@ export class ApplicationService {
* @param parentId string
* @param workshopId string
*/
getApplicationsAllowedToReview(parentId: string, workshopId: string): Observable<boolean> {
public getApplicationsAllowedToReview(parentId: string, workshopId: string): Observable<boolean> {
return this.http.get<boolean>(`/api/v1/applications/reviewable/parents/${parentId}/workshops/${workshopId}`);
}

/**
* This method create Application
* @param application Application
*/
createApplication(application: Application): Observable<HttpResponse<Application>> {
public createApplication(application: Application): Observable<HttpResponse<Application>> {
return this.http.post<Application>('/api/v1/applications', application, { observe: 'response' });
}

/**
* This method update Application
* @param application ApplicationUpdate
*/
updateApplication(application: ApplicationUpdate): Observable<Application> {
public updateApplication(application: ApplicationUpdate): Observable<Application> {
return this.http.put<Application>('/api/v1/applications', application);
}

Expand All @@ -58,7 +58,7 @@ export class ApplicationService {
* @param childId string
* @param workshopId string
*/
getStatusIsAllowToApply(childId: string, workshopId: string): Observable<boolean> {
public getStatusIsAllowToApply(childId: string, workshopId: string): Observable<boolean> {
return this.http.get<boolean>(`/api/v1/applications/allowed/workshops/${workshopId}/children/${childId}`);
}

Expand All @@ -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');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export class ProviderApplicationsComponent extends CabinetDataComponent implemen
statuses: [],
workshops: [],
children: [],
showBlocked: false,
size: PaginationConstants.APPLICATIONS_PER_PAGE,
from: 0
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ 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';
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';
Expand All @@ -39,7 +39,6 @@ export class ApplicationsComponent implements OnInit, OnDestroy, AfterViewInit {

@Select(SharedUserState.applications)
private applicationCards$: Observable<SearchResponse<Application[]>>;
public applicationCards: SearchResponse<Application[]>;
@Select(SharedUserState.isLoading)
public isLoadingCabinet$: Observable<boolean>;

Expand All @@ -62,6 +61,7 @@ export class ApplicationsComponent implements OnInit, OnDestroy, AfterViewInit {

private destroy$: Subject<boolean> = new Subject<boolean>();

public applicationCards: SearchResponse<Application[]>;
public isActiveInfoButton = false;
public currentPage: PaginationElement = PaginationConstants.firstPage;
public isMobileView: boolean;
Expand Down Expand Up @@ -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(['./'], {
Expand All @@ -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 {
Expand Down