Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/162-timesheet-month-view'
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 6970fc2 + dae2aa4 commit c851dac
Show file tree
Hide file tree
Showing 10 changed files with 415 additions and 160 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { SortColumn } from './../../models/times/get-time-v1';
import { Injectable, OnDestroy } from '@angular/core';
import { FormControl } from '@angular/forms';
import { HQService } from '../../services/hq.service';
Expand Down Expand Up @@ -26,9 +27,10 @@ import { Period } from '../../enums/period';
import { HQRole } from '../../enums/hqrole';
import {
GetChargeCodeRecordV1,
SortColumn,
SortColumn as ChargeCodeSortColumn,
} from '../../models/charge-codes/get-chargecodes-v1';
import { GetProjectActivityRecordV1 } from '../../models/projects/get-project-activity-v1';
import { SortDirection } from '../../models/common/sort-direction';

@Injectable({
providedIn: 'root',
Expand Down Expand Up @@ -60,6 +62,10 @@ export class StaffDashboardService implements OnDestroy {
refresh$ = new Subject<void>();
canEdit$: Observable<boolean>;
canEditPoints$: Observable<boolean>;
public sortOption$ = new BehaviorSubject<SortColumn>(SortColumn.Date);
public sortDirection$ = new BehaviorSubject<SortDirection>(
SortDirection.Desc,
);

constructor(
private hqService: HQService,
Expand Down Expand Up @@ -97,7 +103,7 @@ export class StaffDashboardService implements OnDestroy {
this.hqService.getChargeCodeseV1({
active: true,
staffId,
sortBy: SortColumn.IsProjectMember,
sortBy: ChargeCodeSortColumn.IsProjectMember,
}),
),
);
Expand Down Expand Up @@ -143,6 +149,8 @@ export class StaffDashboardService implements OnDestroy {
search: search$,
date: date$,
status: timeStatus$,
sortBy: this.sortOption$,
sortDirection: this.sortDirection$,
}).pipe(shareReplay({ bufferSize: 1, refCount: false }));

const time$ = request$.pipe(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<table class="w-full border-spacing-0 border-separate">
<thead class="z-[100] sticky top-0">
<tr class="text-left">
<th
scope="col"
class="bg-blue-900 border-steel-blue-600 border-y py-3 pr-2 text-nowrap w-3"
></th>
<th
width="28"
scope="col"
class="bg-blue-900 border-steel-blue-600 border-y py-3 pr-2 text-nowrap"
></th>
<th
width="80"
class="bg-blue-900 border-steel-blue-600 border-y py-3 pl-3 text-nowrap cursor-pointer"
(click)="onSortClick(sortColumn.Hours)"
>
Hrs
<hq-sort-icon
[column]="sortColumn.Hours"
[activeColumn]="staffDashboardService.sortOption$ | async"
[activeSortDirection]="staffDashboardService.sortDirection$ | async"
/>
</th>
<th
width="160"
class="bg-blue-900 border-steel-blue-600 border-y py-3 pl-2 cursor-pointer"
(click)="onSortClick(sortColumn.Date)"
>
Date
<hq-sort-icon
[column]="sortColumn.Date"
[activeColumn]="staffDashboardService.sortOption$ | async"
[activeSortDirection]="staffDashboardService.sortDirection$ | async"
/>
</th>
<th
class="bg-blue-900 border-steel-blue-600 border-y py-3 pl-5 text-nowrap cursor-pointer"
(click)="onSortClick(sortColumn.ChargeCode)"
>
Chrg Code
<hq-sort-icon
[column]="sortColumn.ChargeCode"
[activeColumn]="staffDashboardService.sortOption$ | async"
[activeSortDirection]="staffDashboardService.sortDirection$ | async"
/>
</th>
<th
width="160"
class="bg-blue-900 border-steel-blue-600 border-y py-3 pl-2 cursor-pointer"
(click)="onSortClick(sortColumn.ClientName)"
>
Client
<hq-sort-icon
[column]="sortColumn.ClientName"
[activeColumn]="staffDashboardService.sortOption$ | async"
[activeSortDirection]="staffDashboardService.sortDirection$ | async"
/>
</th>
<th
width="160"
class="bg-blue-900 border-steel-blue-600 border-y py-3 pl-2 cursor-pointer"
(click)="onSortClick(sortColumn.ProjectName)"
>
Project
<hq-sort-icon
[column]="sortColumn.ProjectName"
[activeColumn]="staffDashboardService.sortOption$ | async"
[activeSortDirection]="staffDashboardService.sortDirection$ | async"
/>
</th>
<th
width="160"
class="bg-blue-900 border-steel-blue-600 border-y py-3 pl-2 text-nowrap"
>
Activity / Task
</th>
<th class="bg-blue-900 border-steel-blue-600 border-y py-3 pl-2">
Description
</th>
<th width="40" class="bg-blue-900 border-steel-blue-600 border-y"></th>
</tr>
</thead>
<tbody>
@if (this.staffDashboardService.canEdit$ | async) {
<tr
hq-staff-dashboard-time-entry
(hqTimeChange)="upsertTime($event)"
[enableChooseDate]="true"
[chargeCodes]="chargeCodes"
[time]="{
date: localISODate,
timeStatus: timeStatus.Unsubmitted,
}"
class="relative z-[1]"
></tr>
}
@for (date of dashboard.dates; track date.date) {
@for (time of date.times; track time.id) {
<tr
hq-staff-dashboard-time-entry
[chargeCodes]="chargeCodes"
(hqTimeChange)="upsertTime($event)"
(hqTimeDelete)="deleteTime($event)"
(hqTimeDuplicate)="duplicateTime($event)"
[time]="time"
class="relative z-[1]"
></tr>
}
}
</tbody>
</table>
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { StaffDashboardService } from './../service/staff-dashboard.service';
import { CommonModule } from '@angular/common';
import {
Component,
EventEmitter,
Input,
OnDestroy,
Output,
} from '@angular/core';
import { GetChargeCodeRecordV1 } from '../../models/charge-codes/get-chargecodes-v1';
import { GetDashboardTimeV1Response } from '../../models/staff-dashboard/get-dashboard-time-v1';
import { TimeStatus } from '../../enums/time-status';
import {
HQTimeChangeEvent,
HQTimeDeleteEvent,
StaffDashboardTimeEntryComponent,
} from '../staff-dashboard-time-entry/staff-dashboard-time-entry.component';
import { SortColumn } from '../../models/times/get-time-v1';
import { SortDirection } from '../../models/common/sort-direction';
import { ReplaySubject } from 'rxjs';
import { SortIconComponent } from '../../common/sort-icon/sort-icon.component';
import { localISODate } from '../../common/functions/local-iso-date';

@Component({
selector: 'hq-staff-dashboard-month-view',
standalone: true,
imports: [CommonModule, StaffDashboardTimeEntryComponent, SortIconComponent],
templateUrl: './staff-dashboard-month-view.component.html',
})
export class StaffDashboardMonthViewComponent implements OnDestroy {
@Input() dashboard!: GetDashboardTimeV1Response;
@Input() chargeCodes: GetChargeCodeRecordV1[] | null = [];
@Input() showAllRejectedTimes: boolean | null = false;
@Input() canEdit: boolean | null = false;

timeStatus = TimeStatus;
sortColumn = SortColumn;
localISODate = localISODate(); // represent current day

@Output() timeChange = new EventEmitter<HQTimeChangeEvent>();
@Output() timeDelete = new EventEmitter<HQTimeDeleteEvent>();
@Output() timeDuplicate = new EventEmitter<HQTimeChangeEvent>();
private destroyed$: ReplaySubject<boolean> = new ReplaySubject(1);

constructor(public staffDashboardService: StaffDashboardService) {}

ngOnDestroy(): void {
this.destroyed$.next(true);
this.destroyed$.complete();
}

upsertTime(event: HQTimeChangeEvent) {
this.timeChange.emit(event);
}

deleteTime(event: HQTimeDeleteEvent) {
this.timeDelete.emit(event);
}

duplicateTime(event: HQTimeChangeEvent) {
this.timeDuplicate.emit(event);
}

onSortClick(sortColumn: SortColumn) {
if (this.staffDashboardService.sortOption$.value === sortColumn) {
this.staffDashboardService.sortDirection$.next(
this.staffDashboardService.sortDirection$.value === SortDirection.Asc
? SortDirection.Desc
: SortDirection.Asc,
);
} else {
this.staffDashboardService.sortOption$.next(sortColumn);
this.staffDashboardService.sortDirection$.next(SortDirection.Asc);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
>
<option [ngValue]="staffDashboardService.Period.Today">Day</option>
<option [ngValue]="staffDashboardService.Period.Week">Week</option>
<!-- <option [ngValue]="staffDashboardService.Period.Month">Month</option> -->
<option [ngValue]="staffDashboardService.Period.Month">Month</option>
</select>
<span
[ngClass]="{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
[tabindex]="-1"
(click)="chooseDate()"
title="Change date"
[disabled]="!(form.value.id && form.valid)"
[disabled]="!(form.value.id && form.valid) && !enableChooseDate"
class="flex items-center justify-center h-full pointer-events-auto cursor-pointer z-10 right-0 relative col-start-1 row-start-1 self-center justify-self-end w-[36px] after:block after:w-[1px] after:absolute after:left-[1px] after:top-[7px] after:bottom-[7px] after:bg-gray-100"
>
<i class="bi bi-calendar text-[14px] bg-blue-900"></i>
Expand Down Expand Up @@ -211,29 +211,16 @@
<td class="border-b border-black py-2 px-4 text-gray-450">
{{ time?.date }}
</td>
<td class="border-b border-black py-2 pl-2 text-center text-gray-450">
<div class="px-3">
<hq-select-input
[readonly]="true"
[formControlName]="'chargeCodeId'"
[autocomplete]="true"
variant="pill"
[inline]="true"
<td class="border-b border-black py-2 text-center text-gray-450">
<div class="px-4">
<button
type="button"
disabled
class="flex items-center border justify-between bg-blue-900 select-none overflow-hidden border-transparent text-center font-semibold rounded-full px-3 py-1"
[style.background-color]="chargeCodeToColor(time?.chargeCode ?? '')"
>
<ng-template [hqSelectInputOption]="null">Chrge</ng-template>
@for (code of chargeCodes; track code.id) {
<ng-template
[hqSelectInputOption]="code.id"
[hqSelectInputOptionSelectedDisplay]="code.code"
[hqSelectInputOptionSearch]="
code.code + ': ' + code.clientName + ': ' + code.projectName
"
>{{
code.code + ": " + code.clientName + ": " + code.projectName
}}</ng-template
>
}
</hq-select-input>
{{ time?.chargeCode }}
</button>
</div>
</td>
<td class="border-b border-black py-2 pl-2 text-gray-450">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ export class StaffDashboardTimeEntryComponent
time?: Partial<GetDashboardTimeV1TimeForDateTimes>;
@Input()
chargeCodes: GetChargeCodeRecordV1[] | null = [];

@Input()
enableChooseDate: boolean = false;
@Output()
hqTimeChange = new EventEmitter<HQTimeChangeEvent>();

Expand Down Expand Up @@ -354,7 +355,7 @@ export class StaffDashboardTimeEntryComponent
this.form.reset({ date: this.form.controls.date.value });
}
async chooseDate() {
if (!this.form.value.id || !this.form.valid) {
if (!(this.form.value.id && this.form.valid) && !this.enableChooseDate) {
return;
}

Expand Down
Loading

0 comments on commit c851dac

Please sign in to comment.