Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/305-dashboard-timesheet-updates'
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/angular/hq/src/app/staff-dashboard/staff-dashboard.component.ts
  • Loading branch information
rmaffitsancsoft committed Jan 13, 2025
2 parents 6a5906b + 92c882c commit 33ca0a2
Show file tree
Hide file tree
Showing 15 changed files with 112 additions and 218 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { PagedResponseV1 } from '../common/paged-response-v1';

export interface GetProjectActivityRequestV1 {
projectId: string | null;
projectId?: string | null;
}
export interface GetProjectActivityRecordV1 {
id: string;
name: string;
sequence: number;
projectId: string;
}

export interface GetProjectActivityRecordsV1 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ export interface GetDashboardTimeV1Response {
previousDate: string;
nextDate: string;
dates: GetDashboardTimeV1TimeForDate[];
chargeCodes: GetDashboardTimeV1ChargeCode[];
clients: GetDashboardTimeV1Client[];
rejectedCount: number;
canSubmit: boolean;
timeEntryCutoffDate: string;
}

export interface GetDashboardTimeV1TimeForDate {
Expand Down Expand Up @@ -54,29 +53,3 @@ export interface GetDashboardTimeV1TimeForDateTimes {
timeStatus: TimeStatus | null;
rejectionNotes: string | null;
}

export interface GetDashboardTimeV1ChargeCode {
id: string;
clientId: string;
projectId: string;
code: string;
}

export interface GetDashboardTimeV1Client {
id: string;
name: string;
projects: GetDashboardTimeV1Project[];
}

export interface GetDashboardTimeV1Project {
id: string;
chargeCodeId: string | null;
chargeCode: string | null;
name: string;
activities: GetDashboardTimeV1ProjectActivity[];
}

export interface GetDashboardTimeV1ProjectActivity {
id: string;
name: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ import {
takeUntil,
tap,
} from 'rxjs';
import {
GetDashboardTimeV1ChargeCode,
GetDashboardTimeV1Client,
GetDashboardTimeV1Response,
} from '../../models/staff-dashboard/get-dashboard-time-v1';
import { GetDashboardTimeV1Response } from '../../models/staff-dashboard/get-dashboard-time-v1';
import { localISODate } from '../../common/functions/local-iso-date';
import { TimeStatus } from '../../enums/time-status';
import { Period } from '../../enums/period';
import { HQRole } from '../../enums/hqrole';
import {
GetChargeCodeRecordV1,
SortColumn,
} from '../../models/charge-codes/get-chargecodes-v1';
import { GetProjectActivityRecordV1 } from '../../models/projects/get-project-activity-v1';

@Injectable({
providedIn: 'root',
Expand All @@ -48,18 +49,15 @@ export class StaffDashboardService implements OnDestroy {
private destroyed$: ReplaySubject<boolean> = new ReplaySubject(1);
canSubmitSubject = new BehaviorSubject<boolean>(false);
canSubmit$: Observable<boolean> = this.canSubmitSubject.asObservable();

timeEntryCutoffDate$: Observable<string>;
time$: Observable<GetDashboardTimeV1Response>;
chargeCodes$: Observable<GetDashboardTimeV1ChargeCode[]>;
clients$: Observable<GetDashboardTimeV1Client[]>;
chargeCodes$: Observable<GetChargeCodeRecordV1[]>;
showAllRejectedTimes$ = new BehaviorSubject<boolean>(false);
rejectedCount$: Observable<number>;

staffId$: Observable<string>;
activities$: Observable<GetProjectActivityRecordV1[]>;
private staffIdSubject = new BehaviorSubject<string | null>(null);

refresh$ = new Subject<void>();

canEdit$: Observable<boolean>;
canEditPoints$: Observable<boolean>;

Expand Down Expand Up @@ -94,6 +92,19 @@ export class StaffDashboardService implements OnDestroy {
].some((role) => t.roles.includes(role)),
),
);
const chargeCodeResponse$ = this.staffId$.pipe(
switchMap((staffId) =>
this.hqService.getChargeCodeseV1({
active: true,
staffId,
sortBy: SortColumn.IsProjectMember,
}),
),
);
this.chargeCodes$ = chargeCodeResponse$.pipe(
map((chargeCode) => chargeCode.records),
shareReplay({ bufferSize: 1, refCount: false }),
);

this.canEdit$ = combineLatest({
staffId: this.staffId$,
Expand Down Expand Up @@ -141,6 +152,12 @@ export class StaffDashboardService implements OnDestroy {
this.date.setValue(response.startDate, { emitEvent: false }),
),
);
this.activities$ = this.hqService
.getprojectActivitiesV1({ projectId: null })
.pipe(
map((t) => t.records),
shareReplay({ bufferSize: 1, refCount: false }),
);

const refreshTime$ = this.refresh$.pipe(switchMap(() => time$));

Expand All @@ -152,11 +169,12 @@ export class StaffDashboardService implements OnDestroy {
next: (t) => this.canSubmitSubject.next(t.canSubmit),
error: console.error,
});
this.timeEntryCutoffDate$ = this.time$.pipe(
map((t) => t.timeEntryCutoffDate),
shareReplay({ bufferSize: 1, refCount: false }),
);

this.rejectedCount$ = this.time$.pipe(map((t) => t.rejectedCount));

this.chargeCodes$ = this.time$.pipe(map((t) => t.chargeCodes));
this.clients$ = this.time$.pipe(map((t) => t.clients));
}

refresh() {
Expand All @@ -166,6 +184,11 @@ export class StaffDashboardService implements OnDestroy {
setStaffId(staffId: string) {
this.staffIdSubject.next(staffId);
}
resetFilters() {
this.period.setValue(Period.Today);
this.search.setValue('');
this.date.setValue(localISODate());
}

ngOnDestroy(): void {
this.destroyed$.next(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
hq-staff-dashboard-planning-point
[editMode]="editPlanButton$ | async"
[point]="point"
[chargeCodes]="chargeCodes$ | async"
[chargeCodes]="staffDashboardService.chargeCodes$ | async"
class="even:bg-gray-850 odd:bg-black-alt"
cdkDrag
></tr>
Expand All @@ -63,7 +63,7 @@
hq-staff-dashboard-planning-point
[point]="point"
[editMode]="editPlanButton$ | async"
[chargeCodes]="chargeCodes$ | async"
[chargeCodes]="staffDashboardService.chargeCodes$ | async"
class="even:bg-gray-850 odd:bg-black-alt"
></tr>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ import {
PlanningPoint,
} from '../../models/Points/get-points-v1';
import { PointForm } from '../staff-dashboard.component';
import {
GetChargeCodeRecordV1,
SortColumn,
} from '../../models/charge-codes/get-chargecodes-v1';
import { localISODate } from '../../common/functions/local-iso-date';
import { OidcSecurityService } from 'angular-auth-oidc-client';
import { HQService } from '../../services/hq.service';
Expand Down Expand Up @@ -89,7 +85,6 @@ export class StaffDashboardPlanningComponent implements OnInit, OnDestroy {
planningPointsChildren!: QueryList<StaffDashboardPlanningPointComponent>;
planningPoints$: Observable<getPointsResponseV1 | null>;
points: PlanningPoint[] = [];
chargeCodes$: Observable<GetChargeCodeRecordV1[]>;
private staffId$: Observable<string>;
private planningPointsRequest$: Observable<GetPlanRequestV1>;
private planningPointsRequestTrigger$ = new Subject<void>();
Expand Down Expand Up @@ -138,20 +133,6 @@ export class StaffDashboardPlanningComponent implements OnInit, OnDestroy {
trigger: this.planningPointsRequestTrigger$.pipe(startWith(0)),
}).pipe(shareReplay({ bufferSize: 1, refCount: true }));

const chargeCodeResponse$ = this.staffDashboardService.staffId$.pipe(
switchMap((staffId) =>
this.hqService.getChargeCodeseV1({
active: true,
staffId,
sortBy: SortColumn.IsProjectMember,
}),
),
);

this.chargeCodes$ = chargeCodeResponse$.pipe(
map((chargeCode) => chargeCode.records),
shareReplay({ bufferSize: 1, refCount: false }),
);
this.planningPoints$ = this.planningPointsRequest$.pipe(
switchMap(({ date, staffId }) => {
return this.hqService.getPlanningPointsV1({ date, staffId }).pipe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,11 @@
</span>
</div>
</div>
<div class="w-full">
<div class="mt-4">
<hq-button (click)="staffDashboardService.resetFilters()"
>Reset</hq-button
>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import { CommonModule } from '@angular/common';
import { Component } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { StaffDashboardService } from '../service/staff-dashboard.service';
import { ButtonComponent } from '../../core/components/button/button.component';

@Component({
selector: 'hq-staff-dashboard-search-filter',
standalone: true,
imports: [CommonModule, ReactiveFormsModule, FormsModule],
imports: [CommonModule, ReactiveFormsModule, FormsModule, ButtonComponent],
templateUrl: './staff-dashboard-search-filter.component.html',
})
export class StaffDashboardSearchFilterComponent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
</td>

<td class="border-b border-black py-2 pl-2">
@if (activities$ | async; as activities) {
@if (filteredActivities$ | async; as activities) {
@if (activities.length > 0) {
<div class="grid relative w-full max-w-[220px]">
<select
Expand All @@ -124,7 +124,10 @@
(keydown.enter)="onEnter($event.target)"
>
<option [ngValue]="null" class="text-gray-50">Activity</option>
@for (activity of activities$ | async; track activity.id) {
@for (
activity of filteredActivities$ | async;
track activity.id
) {
<option [ngValue]="activity.id">{{ activity.name }}</option>
}
</select>
Expand Down
Loading

0 comments on commit 33ca0a2

Please sign in to comment.