From 8d8e4658b52fd9c259224310e23e2a93b8fbfee2 Mon Sep 17 00:00:00 2001 From: pshahsancsoft Date: Thu, 22 Aug 2024 10:27:21 -0400 Subject: [PATCH 1/3] Show Current Only --- ...lient-details-search-filter.component.html | 25 ++++++++++++++++++- .../client-details-search-filter.component.ts | 16 +++++++++++- .../client-details/client-details.service.ts | 5 ++-- .../client-project-list.service.ts | 6 +++++ .../hq/src/app/enums/project-status.ts | 1 + .../project-list/project-list.component.html | 22 +++++++++++++++- .../project-list/project-list.component.ts | 10 ++++++++ .../project-list/project-list.service.ts | 3 ++- .../Enumerations/ProjectStatus.cs | 1 + .../HQ.Server/Services/ProjectServiceV1.cs | 10 +++++++- 10 files changed, 92 insertions(+), 7 deletions(-) diff --git a/src/angular/hq/src/app/clients/client-details/client-details-search-filter/client-details-search-filter.component.html b/src/angular/hq/src/app/clients/client-details/client-details-search-filter/client-details-search-filter.component.html index bfb78427..2c3fa08c 100644 --- a/src/angular/hq/src/app/clients/client-details/client-details-search-filter/client-details-search-filter.component.html +++ b/src/angular/hq/src/app/clients/client-details/client-details-search-filter/client-details-search-filter.component.html @@ -9,7 +9,10 @@ class="w-52" > All - @for (status of projectStatusEnum$ | async; track status.id) { + @for ( + status of projectStatusEnum$ | async | slice: 0 : 9; + track status.id + ) { } + +
+
+ Show current only +
+ +
On
+
} diff --git a/src/angular/hq/src/app/clients/client-details/client-details-search-filter/client-details-search-filter.component.ts b/src/angular/hq/src/app/clients/client-details/client-details-search-filter/client-details-search-filter.component.ts index 00556f1f..cd27889e 100644 --- a/src/angular/hq/src/app/clients/client-details/client-details-search-filter/client-details-search-filter.component.ts +++ b/src/angular/hq/src/app/clients/client-details/client-details-search-filter/client-details-search-filter.component.ts @@ -7,7 +7,9 @@ import { SelectInputComponent } from '../../../core/components/select-input/sele import { SelectInputOptionDirective } from '../../../core/directives/select-input-option.directive'; import { enumToArrayObservable } from '../../../core/functions/enum-to-array'; import { ProjectStatus } from '../../../enums/project-status'; +import { enumToArray } from '../../../core/functions/enum-to-array'; +import { ClientProjectListService } from '../client-project-list/client-project-list.service'; @Component({ selector: 'hq-client-details-search-filter', standalone: true, @@ -22,6 +24,18 @@ import { ProjectStatus } from '../../../enums/project-status'; templateUrl: './client-details-search-filter.component.html', }) export class ClientDetailsSearchFilterComponent { + projectStatus = enumToArray(ProjectStatus); + public projectStatusEnum$ = enumToArrayObservable(ProjectStatus); - constructor(public clientDetailService: ClientDetailsService) {} + constructor( + public clientDetailService: ClientDetailsService, + public clientProjectListService: ClientProjectListService, + ) {} + + onToggleChange(event: Event) { + const isChecked = (event.target as HTMLInputElement).checked; + const newStatus = isChecked ? 10 : null; + this.clientDetailService.projectStatus.setValue(newStatus); + this.clientDetailService.toggleStatus.setValue(isChecked); + } } diff --git a/src/angular/hq/src/app/clients/client-details/client-details.service.ts b/src/angular/hq/src/app/clients/client-details/client-details.service.ts index 651fea27..7985a18a 100644 --- a/src/angular/hq/src/app/clients/client-details/client-details.service.ts +++ b/src/angular/hq/src/app/clients/client-details/client-details.service.ts @@ -20,7 +20,8 @@ export class ClientDetailsService { ProjectStatus = ProjectStatus; search = new FormControl(null); - projectStatus = new FormControl(null); + public projectStatus = new FormControl(10); + public toggleStatus = new FormControl(true); showProjectStatus$: Observable; @@ -55,7 +56,7 @@ export class ClientDetailsService { resetFilters() { this.search.reset(); - this.projectStatus.reset(); + this.projectStatus.reset(10); } showProjectStatus() { diff --git a/src/angular/hq/src/app/clients/client-details/client-project-list/client-project-list.service.ts b/src/angular/hq/src/app/clients/client-details/client-project-list/client-project-list.service.ts index 15cd0fb5..ccccc3dc 100644 --- a/src/angular/hq/src/app/clients/client-details/client-project-list/client-project-list.service.ts +++ b/src/angular/hq/src/app/clients/client-details/client-project-list/client-project-list.service.ts @@ -28,6 +28,12 @@ export class ClientProjectListService extends BaseListService< GetProjectRecordV1, SortColumn > { + public projectStatus$ = formControlChanges( + this.clientDetailsService.projectStatus, + ).pipe( + tap(() => this.goToPage(1)), + shareReplay({ bufferSize: 1, refCount: false }), + ); // Enums public ProjectStatus = ProjectStatus; public Period = Period; diff --git a/src/angular/hq/src/app/enums/project-status.ts b/src/angular/hq/src/app/enums/project-status.ts index 3fb4dc92..5fded497 100644 --- a/src/angular/hq/src/app/enums/project-status.ts +++ b/src/angular/hq/src/app/enums/project-status.ts @@ -9,4 +9,5 @@ export enum ProjectStatus { Completed = 7, Closed = 8, Lost = 9, + CurrentOnly = 10, } diff --git a/src/angular/hq/src/app/projects/project-list/project-list.component.html b/src/angular/hq/src/app/projects/project-list/project-list.component.html index bcf25252..cb47b749 100644 --- a/src/angular/hq/src/app/projects/project-list/project-list.component.html +++ b/src/angular/hq/src/app/projects/project-list/project-list.component.html @@ -40,7 +40,7 @@

Projects

> All @for ( - status of listService.projectStatusEnum$ | async; + status of listService.projectStatusEnum$ | async | slice: 0 : 9; track status.id ) { Projects } + +
+
+ Show current only +
+ +
On
+
diff --git a/src/angular/hq/src/app/projects/project-list/project-list.component.ts b/src/angular/hq/src/app/projects/project-list/project-list.component.ts index f0b615a1..cfef648a 100644 --- a/src/angular/hq/src/app/projects/project-list/project-list.component.ts +++ b/src/angular/hq/src/app/projects/project-list/project-list.component.ts @@ -11,6 +11,8 @@ import { InRolePipe } from '../../pipes/in-role.pipe'; import { CoreModule } from '../../core/core.module'; import { ProjectListService } from './project-list.service'; import { BaseListService } from '../../core/services/base-list.service'; +import { ProjectStatus } from '../../enums/project-status'; +import { enumToArray } from '../../core/functions/enum-to-array'; @Component({ selector: 'hq-project-list', @@ -36,6 +38,7 @@ import { BaseListService } from '../../core/services/base-list.service'; export class ProjectListComponent { HQRole = HQRole; Math = Math; + projectStatus = enumToArray(ProjectStatus); constructor( private hqService: HQService, @@ -44,4 +47,11 @@ export class ProjectListComponent { ) { this.listService.refresh(); } + + onToggleChange(event: Event) { + const isChecked = (event.target as HTMLInputElement).checked; + const newStatus = isChecked ? 10 : null; + this.listService.projectStatus.setValue(newStatus); + this.listService.toggleStatus.setValue(isChecked); + } } diff --git a/src/angular/hq/src/app/projects/project-list/project-list.service.ts b/src/angular/hq/src/app/projects/project-list/project-list.service.ts index 643ff6da..5ba6d28d 100644 --- a/src/angular/hq/src/app/projects/project-list/project-list.service.ts +++ b/src/angular/hq/src/app/projects/project-list/project-list.service.ts @@ -40,11 +40,12 @@ export class ProjectListService extends BaseListService< public projectStatusEnum$ = enumToArrayObservable(ProjectStatus); // Filters - public projectStatus = new FormControl(null); + public projectStatus = new FormControl(10); public projectStatus$ = formControlChanges(this.projectStatus).pipe( tap(() => this.goToPage(1)), shareReplay({ bufferSize: 1, refCount: false }), ); + public toggleStatus = new FormControl(true); public projectManagerId = new FormControl(null); public projectManagerId$ = formControlChanges(this.projectManagerId).pipe( diff --git a/src/dotnet/HQ.Abstractions/Enumerations/ProjectStatus.cs b/src/dotnet/HQ.Abstractions/Enumerations/ProjectStatus.cs index feb7bf3d..887c037c 100644 --- a/src/dotnet/HQ.Abstractions/Enumerations/ProjectStatus.cs +++ b/src/dotnet/HQ.Abstractions/Enumerations/ProjectStatus.cs @@ -12,4 +12,5 @@ public enum ProjectStatus Completed = 7, Closed = 8, Lost = 9, + CurrentOnly = 10 } \ No newline at end of file diff --git a/src/dotnet/HQ.Server/Services/ProjectServiceV1.cs b/src/dotnet/HQ.Server/Services/ProjectServiceV1.cs index b08515f7..834251f5 100644 --- a/src/dotnet/HQ.Server/Services/ProjectServiceV1.cs +++ b/src/dotnet/HQ.Server/Services/ProjectServiceV1.cs @@ -235,7 +235,15 @@ public ProjectServiceV1(ChargeCodeServiceV1 chargeCodeServiceV1, HQDbContext con if (request.ProjectStatus.HasValue && request.ProjectStatus != null) { - records = records.Where(t => t.Status == request.ProjectStatus); + if (request.ProjectStatus.Value == ProjectStatus.CurrentOnly) + { + records = records.Where(t => t.Status == ProjectStatus.InProduction || t.Status == ProjectStatus.Ongoing); + } + else + { + records = records.Where(t => t.Status == request.ProjectStatus); + } + } var bookingStartDate = DateOnly.FromDateTime(DateTime.Today).GetPeriodStartDate(Period.Month); var bookingEndDate = DateOnly.FromDateTime(DateTime.Today).GetPeriodEndDate(Period.Month); From 3efcc866ef28e12dff81c083a13645984c0b87fe Mon Sep 17 00:00:00 2001 From: pshahsancsoft Date: Tue, 10 Sep 2024 17:02:42 -0400 Subject: [PATCH 2/3] Revert "Show Current Only" This reverts commit 8d8e4658b52fd9c259224310e23e2a93b8fbfee2. --- ...lient-details-search-filter.component.html | 25 +------------------ .../client-details-search-filter.component.ts | 16 +----------- .../client-details/client-details.service.ts | 5 ++-- .../client-project-list.service.ts | 6 ----- .../hq/src/app/enums/project-status.ts | 1 - .../project-list/project-list.component.html | 22 +--------------- .../project-list/project-list.component.ts | 10 -------- .../project-list/project-list.service.ts | 3 +-- .../Enumerations/ProjectStatus.cs | 1 - .../HQ.Server/Services/ProjectServiceV1.cs | 10 +------- 10 files changed, 7 insertions(+), 92 deletions(-) diff --git a/src/angular/hq/src/app/clients/client-details/client-details-search-filter/client-details-search-filter.component.html b/src/angular/hq/src/app/clients/client-details/client-details-search-filter/client-details-search-filter.component.html index 2c3fa08c..bfb78427 100644 --- a/src/angular/hq/src/app/clients/client-details/client-details-search-filter/client-details-search-filter.component.html +++ b/src/angular/hq/src/app/clients/client-details/client-details-search-filter/client-details-search-filter.component.html @@ -9,10 +9,7 @@ class="w-52" > All - @for ( - status of projectStatusEnum$ | async | slice: 0 : 9; - track status.id - ) { + @for (status of projectStatusEnum$ | async; track status.id) { } - -
-
- Show current only -
- -
On
-
} diff --git a/src/angular/hq/src/app/clients/client-details/client-details-search-filter/client-details-search-filter.component.ts b/src/angular/hq/src/app/clients/client-details/client-details-search-filter/client-details-search-filter.component.ts index cd27889e..00556f1f 100644 --- a/src/angular/hq/src/app/clients/client-details/client-details-search-filter/client-details-search-filter.component.ts +++ b/src/angular/hq/src/app/clients/client-details/client-details-search-filter/client-details-search-filter.component.ts @@ -7,9 +7,7 @@ import { SelectInputComponent } from '../../../core/components/select-input/sele import { SelectInputOptionDirective } from '../../../core/directives/select-input-option.directive'; import { enumToArrayObservable } from '../../../core/functions/enum-to-array'; import { ProjectStatus } from '../../../enums/project-status'; -import { enumToArray } from '../../../core/functions/enum-to-array'; -import { ClientProjectListService } from '../client-project-list/client-project-list.service'; @Component({ selector: 'hq-client-details-search-filter', standalone: true, @@ -24,18 +22,6 @@ import { ClientProjectListService } from '../client-project-list/client-project- templateUrl: './client-details-search-filter.component.html', }) export class ClientDetailsSearchFilterComponent { - projectStatus = enumToArray(ProjectStatus); - public projectStatusEnum$ = enumToArrayObservable(ProjectStatus); - constructor( - public clientDetailService: ClientDetailsService, - public clientProjectListService: ClientProjectListService, - ) {} - - onToggleChange(event: Event) { - const isChecked = (event.target as HTMLInputElement).checked; - const newStatus = isChecked ? 10 : null; - this.clientDetailService.projectStatus.setValue(newStatus); - this.clientDetailService.toggleStatus.setValue(isChecked); - } + constructor(public clientDetailService: ClientDetailsService) {} } diff --git a/src/angular/hq/src/app/clients/client-details/client-details.service.ts b/src/angular/hq/src/app/clients/client-details/client-details.service.ts index 7985a18a..651fea27 100644 --- a/src/angular/hq/src/app/clients/client-details/client-details.service.ts +++ b/src/angular/hq/src/app/clients/client-details/client-details.service.ts @@ -20,8 +20,7 @@ export class ClientDetailsService { ProjectStatus = ProjectStatus; search = new FormControl(null); - public projectStatus = new FormControl(10); - public toggleStatus = new FormControl(true); + projectStatus = new FormControl(null); showProjectStatus$: Observable; @@ -56,7 +55,7 @@ export class ClientDetailsService { resetFilters() { this.search.reset(); - this.projectStatus.reset(10); + this.projectStatus.reset(); } showProjectStatus() { diff --git a/src/angular/hq/src/app/clients/client-details/client-project-list/client-project-list.service.ts b/src/angular/hq/src/app/clients/client-details/client-project-list/client-project-list.service.ts index ccccc3dc..15cd0fb5 100644 --- a/src/angular/hq/src/app/clients/client-details/client-project-list/client-project-list.service.ts +++ b/src/angular/hq/src/app/clients/client-details/client-project-list/client-project-list.service.ts @@ -28,12 +28,6 @@ export class ClientProjectListService extends BaseListService< GetProjectRecordV1, SortColumn > { - public projectStatus$ = formControlChanges( - this.clientDetailsService.projectStatus, - ).pipe( - tap(() => this.goToPage(1)), - shareReplay({ bufferSize: 1, refCount: false }), - ); // Enums public ProjectStatus = ProjectStatus; public Period = Period; diff --git a/src/angular/hq/src/app/enums/project-status.ts b/src/angular/hq/src/app/enums/project-status.ts index 5fded497..3fb4dc92 100644 --- a/src/angular/hq/src/app/enums/project-status.ts +++ b/src/angular/hq/src/app/enums/project-status.ts @@ -9,5 +9,4 @@ export enum ProjectStatus { Completed = 7, Closed = 8, Lost = 9, - CurrentOnly = 10, } diff --git a/src/angular/hq/src/app/projects/project-list/project-list.component.html b/src/angular/hq/src/app/projects/project-list/project-list.component.html index cb47b749..bcf25252 100644 --- a/src/angular/hq/src/app/projects/project-list/project-list.component.html +++ b/src/angular/hq/src/app/projects/project-list/project-list.component.html @@ -40,7 +40,7 @@

Projects

> All @for ( - status of listService.projectStatusEnum$ | async | slice: 0 : 9; + status of listService.projectStatusEnum$ | async; track status.id ) { Projects } - -
-
- Show current only -
- -
On
-
diff --git a/src/angular/hq/src/app/projects/project-list/project-list.component.ts b/src/angular/hq/src/app/projects/project-list/project-list.component.ts index cfef648a..f0b615a1 100644 --- a/src/angular/hq/src/app/projects/project-list/project-list.component.ts +++ b/src/angular/hq/src/app/projects/project-list/project-list.component.ts @@ -11,8 +11,6 @@ import { InRolePipe } from '../../pipes/in-role.pipe'; import { CoreModule } from '../../core/core.module'; import { ProjectListService } from './project-list.service'; import { BaseListService } from '../../core/services/base-list.service'; -import { ProjectStatus } from '../../enums/project-status'; -import { enumToArray } from '../../core/functions/enum-to-array'; @Component({ selector: 'hq-project-list', @@ -38,7 +36,6 @@ import { enumToArray } from '../../core/functions/enum-to-array'; export class ProjectListComponent { HQRole = HQRole; Math = Math; - projectStatus = enumToArray(ProjectStatus); constructor( private hqService: HQService, @@ -47,11 +44,4 @@ export class ProjectListComponent { ) { this.listService.refresh(); } - - onToggleChange(event: Event) { - const isChecked = (event.target as HTMLInputElement).checked; - const newStatus = isChecked ? 10 : null; - this.listService.projectStatus.setValue(newStatus); - this.listService.toggleStatus.setValue(isChecked); - } } diff --git a/src/angular/hq/src/app/projects/project-list/project-list.service.ts b/src/angular/hq/src/app/projects/project-list/project-list.service.ts index 5ba6d28d..643ff6da 100644 --- a/src/angular/hq/src/app/projects/project-list/project-list.service.ts +++ b/src/angular/hq/src/app/projects/project-list/project-list.service.ts @@ -40,12 +40,11 @@ export class ProjectListService extends BaseListService< public projectStatusEnum$ = enumToArrayObservable(ProjectStatus); // Filters - public projectStatus = new FormControl(10); + public projectStatus = new FormControl(null); public projectStatus$ = formControlChanges(this.projectStatus).pipe( tap(() => this.goToPage(1)), shareReplay({ bufferSize: 1, refCount: false }), ); - public toggleStatus = new FormControl(true); public projectManagerId = new FormControl(null); public projectManagerId$ = formControlChanges(this.projectManagerId).pipe( diff --git a/src/dotnet/HQ.Abstractions/Enumerations/ProjectStatus.cs b/src/dotnet/HQ.Abstractions/Enumerations/ProjectStatus.cs index 887c037c..feb7bf3d 100644 --- a/src/dotnet/HQ.Abstractions/Enumerations/ProjectStatus.cs +++ b/src/dotnet/HQ.Abstractions/Enumerations/ProjectStatus.cs @@ -12,5 +12,4 @@ public enum ProjectStatus Completed = 7, Closed = 8, Lost = 9, - CurrentOnly = 10 } \ No newline at end of file diff --git a/src/dotnet/HQ.Server/Services/ProjectServiceV1.cs b/src/dotnet/HQ.Server/Services/ProjectServiceV1.cs index 834251f5..b08515f7 100644 --- a/src/dotnet/HQ.Server/Services/ProjectServiceV1.cs +++ b/src/dotnet/HQ.Server/Services/ProjectServiceV1.cs @@ -235,15 +235,7 @@ public ProjectServiceV1(ChargeCodeServiceV1 chargeCodeServiceV1, HQDbContext con if (request.ProjectStatus.HasValue && request.ProjectStatus != null) { - if (request.ProjectStatus.Value == ProjectStatus.CurrentOnly) - { - records = records.Where(t => t.Status == ProjectStatus.InProduction || t.Status == ProjectStatus.Ongoing); - } - else - { - records = records.Where(t => t.Status == request.ProjectStatus); - } - + records = records.Where(t => t.Status == request.ProjectStatus); } var bookingStartDate = DateOnly.FromDateTime(DateTime.Today).GetPeriodStartDate(Period.Month); var bookingEndDate = DateOnly.FromDateTime(DateTime.Today).GetPeriodEndDate(Period.Month); From 03b2c633ef963b5871c9f341dc6def8fc64dfa86 Mon Sep 17 00:00:00 2001 From: pshahsancsoft Date: Wed, 11 Sep 2024 15:23:24 -0400 Subject: [PATCH 3/3] PR Commit/Push --- ...client-details-search-filter.component.html | 15 +++++++++++++++ .../client-details.component.html | 4 ++-- .../client-details/client-details.component.ts | 2 +- .../client-details/client-details.service.ts | 11 +++++++++++ .../client-project-list.service.ts | 17 +++++++++++++++-- .../project-list/project-list.component.html | 14 ++++++++++++++ .../project-list/project-list.service.ts | 18 ++++++++++++++++-- .../HQ.Abstractions/Projects/GetProjectsV1.cs | 1 + .../HQ.Server/Services/ProjectServiceV1.cs | 7 +++++++ 9 files changed, 82 insertions(+), 7 deletions(-) diff --git a/src/angular/hq/src/app/clients/client-details/client-details-search-filter/client-details-search-filter.component.html b/src/angular/hq/src/app/clients/client-details/client-details-search-filter/client-details-search-filter.component.html index bfb78427..7423b202 100644 --- a/src/angular/hq/src/app/clients/client-details/client-details-search-filter/client-details-search-filter.component.html +++ b/src/angular/hq/src/app/clients/client-details/client-details-search-filter/client-details-search-filter.component.html @@ -19,4 +19,19 @@ } } + @if(clientDetailService.showCurrentOnly$ | async){ +
+
+ Show current only +
+ +
On
+
+} diff --git a/src/angular/hq/src/app/clients/client-details/client-details.component.html b/src/angular/hq/src/app/clients/client-details/client-details.component.html index 6a1fa697..0ea845a2 100644 --- a/src/angular/hq/src/app/clients/client-details/client-details.component.html +++ b/src/angular/hq/src/app/clients/client-details/client-details.component.html @@ -6,8 +6,8 @@
- Projects - Quotes + Projects + Quotes
diff --git a/src/angular/hq/src/app/clients/client-details/client-details.component.ts b/src/angular/hq/src/app/clients/client-details/client-details.component.ts index 54531511..81067a12 100644 --- a/src/angular/hq/src/app/clients/client-details/client-details.component.ts +++ b/src/angular/hq/src/app/clients/client-details/client-details.component.ts @@ -37,7 +37,7 @@ export class ClientDetailsComponent { private subscriptions: Subscription[] = []; constructor( - private clientDetailsService: ClientDetailsService, + public clientDetailsService: ClientDetailsService, private route: ActivatedRoute, ) { const clientId$ = route.paramMap.pipe(map((t) => t.get('clientId'))); diff --git a/src/angular/hq/src/app/clients/client-details/client-details.service.ts b/src/angular/hq/src/app/clients/client-details/client-details.service.ts index 651fea27..3159d908 100644 --- a/src/angular/hq/src/app/clients/client-details/client-details.service.ts +++ b/src/angular/hq/src/app/clients/client-details/client-details.service.ts @@ -18,21 +18,25 @@ import { GetClientInvoiceSummaryV1Response } from '../../models/clients/get-clie }) export class ClientDetailsService { ProjectStatus = ProjectStatus; + currentOnly = new FormControl(true); search = new FormControl(null); projectStatus = new FormControl(null); showProjectStatus$: Observable; + showCurrentOnly$: Observable; clientId$: Observable; client$: Observable; clientInvoiceSummary$: Observable; + private showCurrentOnlySubject = new BehaviorSubject(true); private showProjectStatusSubject = new BehaviorSubject(true); private clientIdSubject = new BehaviorSubject(null); constructor(private hqService: HQService) { this.showProjectStatus$ = this.showProjectStatusSubject.asObservable(); + this.showCurrentOnly$ = this.showCurrentOnlySubject.asObservable(); this.clientId$ = this.clientIdSubject.asObservable().pipe( filter((clientId) => clientId != null), @@ -71,4 +75,11 @@ export class ClientDetailsService { this.clientIdSubject.next(clientId); } } + showCurrentOnly(){ + this.showCurrentOnlySubject.next(true); + } + hideCurrentOnly(){ + this.showCurrentOnlySubject.next(false); + + } } diff --git a/src/angular/hq/src/app/clients/client-details/client-project-list/client-project-list.service.ts b/src/angular/hq/src/app/clients/client-details/client-project-list/client-project-list.service.ts index 15cd0fb5..d7eef66d 100644 --- a/src/angular/hq/src/app/clients/client-details/client-project-list/client-project-list.service.ts +++ b/src/angular/hq/src/app/clients/client-details/client-project-list/client-project-list.service.ts @@ -11,7 +11,7 @@ import { shareReplay, combineLatest, debounceTime, - switchMap, + switchMap,startWith } from 'rxjs'; import { formControlChanges } from '../../../core/functions/form-control-changes'; import { BaseListService } from '../../../core/services/base-list.service'; @@ -43,9 +43,21 @@ export class ClientProjectListService extends BaseListService< this.clientDetailsService.projectStatus, ).pipe( tap(() => this.goToPage(1)), + tap((status)=> { + if(status != null){ + this.clientDetailsService.currentOnly.setValue(false); + } + }), shareReplay({ bufferSize: 1, refCount: false }), ); - + const currentOnly$ = formControlChanges(this.clientDetailsService.currentOnly).pipe( + startWith(this.clientDetailsService.currentOnly.value), + tap(value => { + if (value){ + this.clientDetailsService.projectStatus.setValue(null); + } + }) + ); const result$ = combineLatest({ search: search$, clientId: this.clientDetailsService.clientId$, @@ -54,6 +66,7 @@ export class ClientProjectListService extends BaseListService< sortBy: this.sortOption$, projectStatus: projectStatus$, sortDirection: this.sortDirection$, + currentOnly: currentOnly$ }).pipe( debounceTime(500), tap(() => this.loadingSubject.next(true)), diff --git a/src/angular/hq/src/app/projects/project-list/project-list.component.html b/src/angular/hq/src/app/projects/project-list/project-list.component.html index bcf25252..ae5143f4 100644 --- a/src/angular/hq/src/app/projects/project-list/project-list.component.html +++ b/src/angular/hq/src/app/projects/project-list/project-list.component.html @@ -52,6 +52,20 @@

Projects

}
+ @if(listService){} +
+
+ Show current only +
+ +
On
+
diff --git a/src/angular/hq/src/app/projects/project-list/project-list.service.ts b/src/angular/hq/src/app/projects/project-list/project-list.service.ts index 643ff6da..03794f46 100644 --- a/src/angular/hq/src/app/projects/project-list/project-list.service.ts +++ b/src/angular/hq/src/app/projects/project-list/project-list.service.ts @@ -15,7 +15,7 @@ import { Observable, shareReplay, switchMap, - tap, + tap, startWith } from 'rxjs'; import { SortDirection } from '../../models/common/sort-direction'; import { HQService } from '../../services/hq.service'; @@ -43,6 +43,11 @@ export class ProjectListService extends BaseListService< public projectStatus = new FormControl(null); public projectStatus$ = formControlChanges(this.projectStatus).pipe( tap(() => this.goToPage(1)), + tap((status)=> { + if(status != null){ + this.currentOnly.setValue(false); + } + }), shareReplay({ bufferSize: 1, refCount: false }), ); @@ -53,7 +58,15 @@ export class ProjectListService extends BaseListService< ); projectManagers$: Observable; - + currentOnly = new FormControl(true); + public currentOnly$ = formControlChanges(this.currentOnly).pipe( + startWith(this.currentOnly.value), + tap(value => { + if (value){ + this.projectStatus.setValue(null); + } + }) + ); protected override getResponse(): Observable { return combineLatest({ search: this.search$, @@ -63,6 +76,7 @@ export class ProjectListService extends BaseListService< projectStatus: this.projectStatus$, sortDirection: this.sortDirection$, projectManagerId: this.projectManagerId$, + currentOnly: this.currentOnly$, }).pipe( debounceTime(500), tap(() => this.loadingSubject.next(true)), diff --git a/src/dotnet/HQ.Abstractions/Projects/GetProjectsV1.cs b/src/dotnet/HQ.Abstractions/Projects/GetProjectsV1.cs index 9b12fbce..bf5f8732 100644 --- a/src/dotnet/HQ.Abstractions/Projects/GetProjectsV1.cs +++ b/src/dotnet/HQ.Abstractions/Projects/GetProjectsV1.cs @@ -22,6 +22,7 @@ public class Request : PagedRequestV1 public SortColumn SortBy { get; set; } = SortColumn.ProjectName; public SortDirection SortDirection { get; set; } = SortDirection.Asc; public ProjectStatus? ProjectStatus { get; set; } + public bool? CurrentOnly { get; set; } = true; } public enum SortColumn diff --git a/src/dotnet/HQ.Server/Services/ProjectServiceV1.cs b/src/dotnet/HQ.Server/Services/ProjectServiceV1.cs index b08515f7..9ac5b978 100644 --- a/src/dotnet/HQ.Server/Services/ProjectServiceV1.cs +++ b/src/dotnet/HQ.Server/Services/ProjectServiceV1.cs @@ -237,6 +237,13 @@ public ProjectServiceV1(ChargeCodeServiceV1 chargeCodeServiceV1, HQDbContext con { records = records.Where(t => t.Status == request.ProjectStatus); } + if (request.CurrentOnly.HasValue) + { + if (request.CurrentOnly.Value) + { + records = records.Where(t => t.Status == ProjectStatus.InProduction || t.Status == ProjectStatus.Ongoing); + } + } var bookingStartDate = DateOnly.FromDateTime(DateTime.Today).GetPeriodStartDate(Period.Month); var bookingEndDate = DateOnly.FromDateTime(DateTime.Today).GetPeriodEndDate(Period.Month);