Skip to content

409 feedback 2025 01 27 #412

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

Merged
merged 20 commits into from
Feb 10, 2025
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
2 changes: 1 addition & 1 deletion src/angular/hq/src/app/enums/staff-status.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const StaffStatus = [
'In The Office',
'At Customer',
'At The Client',
'WFH',
'WFH AM',
'WFH PM',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { Component, OnInit } from '@angular/core';
/* eslint-disable rxjs-angular/prefer-takeuntil */
/* eslint-disable rxjs-angular/prefer-async-pipe */

import { Component, OnDestroy, OnInit } from '@angular/core';
import {
FormGroup,
FormControl,
Expand All @@ -7,7 +10,7 @@ import {
ReactiveFormsModule,
} from '@angular/forms';
import { Router, ActivatedRoute, RouterLink } from '@angular/router';
import { BehaviorSubject, firstValueFrom } from 'rxjs';
import { BehaviorSubject, firstValueFrom, Subject, takeUntil } from 'rxjs';
import { APIError } from '../../errors/apierror';
import { HQService } from '../../services/hq.service';
import { CommonModule } from '@angular/common';
Expand Down Expand Up @@ -42,7 +45,7 @@ interface Form {
],
templateUrl: './staff-edit.component.html',
})
export class StaffEditComponent implements OnInit {
export class StaffEditComponent implements OnDestroy, OnInit {
staffId?: string;
apiErrors: string[] = [];
showStaffMembers$ = new BehaviorSubject<boolean | null>(null);
Expand Down Expand Up @@ -81,6 +84,23 @@ export class StaffEditComponent implements OnInit {
await firstValueFrom(this.route.paramMap.pipe())
).get('staffId')) ?? undefined;
await this.getStaff();

this.form.controls.endDate.valueChanges
.pipe(takeUntil(this.destroy))
.subscribe({
next: (endDate) => {
if (typeof endDate == 'string' && endDate == '') {
this.form.controls.endDate.setValue(null, { emitEvent: false });
}
},
error: console.error,
});
}

private destroy = new Subject<void>();
ngOnDestroy() {
this.destroy.next();
this.destroy.complete();
}

constructor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export class StaffDashboardService implements OnDestroy {
public sortDirection$ = new BehaviorSubject<SortDirection>(
SortDirection.Desc,
);
localIsoDate = localISODate;

constructor(
private hqService: HQService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,22 @@
</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) {
@if (
(this.staffDashboardService.canEdit$ | async) && date.canCreateTime
) {
<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 (time of date.times; track time.id) {
<tr
hq-staff-dashboard-time-entry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,13 @@
</div>
<div class="w-full">
<div class="mt-4">
<hq-button (click)="staffDashboardService.resetFilters()"
>Reset</hq-button
<hq-button
[disabled]="
staffDashboardService.date.value ===
staffDashboardService.localIsoDate()
"
(click)="staffDashboardService.resetFilters()"
>Today</hq-button
>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ export class StaffDashboardTimeEntryComponent
next: (id) => {
const chargeCode = this.chargeCodes?.find((t) => t.id === id);
const maxTimeEntryHours = chargeCode?.maximumTimeEntryHours ?? 0;
console.log(chargeCode, this.chargeCodes, id);
this.setMaximumHours(maxTimeEntryHours);
if (chargeCode) {
this.form.patchValue(
Expand Down Expand Up @@ -219,6 +218,16 @@ export class StaffDashboardTimeEntryComponent
}).pipe(
map((t) => t.activities.filter((x) => x.projectId === t.form.projectId)),
);
this.filteredActivities$.pipe(takeUntil(this.destroyed$)).subscribe({
next: (activities) => {
if (activities.length > 0) {
this.form.controls.activityId.addValidators(Validators.required);
} else {
this.form.controls.activityId.removeValidators(Validators.required);
}
},
error: console.error,
});

const hours$ = form$.pipe(
map((t) => t.hours),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,13 @@
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"
>
Hrs
</th>
<th
width="80"
class="bg-blue-900 border-steel-blue-600 border-y py-3 pl-3 text-nowrap"
></th>
<th
width="160"
class="bg-blue-900 border-steel-blue-600 border-y py-3 pl-2"
Expand Down Expand Up @@ -411,9 +411,19 @@
></th>
<th
width="80"
class="bg-blue-900 border-steel-blue-600 border-y py-3 pl-3 text-nowrap"
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"
Expand All @@ -423,21 +433,51 @@
</th>
<th
width="160"
class="bg-blue-900 border-steel-blue-600 border-y py-3 pl-5"
class="bg-blue-900 border-steel-blue-600 border-y py-3 pl-5 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"
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"
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"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { SortIconComponent } from './../common/sort-icon/sort-icon.component';
/* eslint-disable rxjs-angular/prefer-async-pipe */
import { StaffDashboardPlanningPointComponent } from './staff-dashboard-planning-point/staff-dashboard-planning-point.component';
import { MonacoEditorModule } from 'ngx-monaco-editor-v2';
Expand Down Expand Up @@ -65,6 +66,8 @@ import { GetPrevPlanResponseV1 } from '../models/Plan/get-previous-PSR-v1';
import { ButtonState } from '../enums/button-state';
import { StaffDashboardMonthViewComponent } from './staff-dashboard-month-view/staff-dashboard-month-view.component';
import { StaffStatus } from '../enums/staff-status';
import { SortColumn } from '../models/times/get-time-v1';
import { SortDirection } from '../models/common/sort-direction';

export interface PointForm {
id: FormControl<string | null>;
Expand Down Expand Up @@ -96,6 +99,7 @@ export interface PointForm {
ButtonComponent,
StaffDashboardPlanningComponent,
StaffDashboardMonthViewComponent,
SortIconComponent,
],
providers: [StaffDashboardService],
templateUrl: './staff-dashboard.component.html',
Expand All @@ -115,6 +119,7 @@ export class StaffDashboardComponent implements OnInit, OnDestroy, OnChanges {
plan$ = this.plan.valueChanges;

ButtonState = ButtonState;
sortColumn = SortColumn;
currentDate = new Date();
previousPlan: string | null = null;
planResponse$: Observable<GetPlanResponseV1>;
Expand Down Expand Up @@ -323,6 +328,19 @@ export class StaffDashboardComponent implements OnInit, OnDestroy, OnChanges {
}
}

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);
}
}

insertTextAtCursor() {
const selection = this.editorInstance.getSelection();
const id = { major: 1, minor: 1 };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div>
<div class="flex justify-between items-center px-5 mb-2">
<div class="flex-col flex-wrap content-between space-y-12">
<div class="text-2xl text-white">Timesheets</div>
<div class="text-2xl text-white">Staff</div>
<div>
<input
type="text"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ <h1 class="font-rajdhani font-semibold text-3xl">Create Time</h1>
</ng-template>
}
</hq-select-input>
@if (
form.get("ActivityId")?.touched &&
form.get("ActivityId")?.errors?.["required"]
) {
<span
class="text-red-700 text-xs leading-normal inline-block"
>Activity is required.</span
>
}
} @else {
<hq-form-label>Task</hq-form-label>
<input
Expand Down
11 changes: 11 additions & 0 deletions src/angular/hq/src/app/times/time-create/time-create.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,17 @@ export class TimeCreateComponent implements OnDestroy {
},
error: console.error,
});

this.activities$.pipe(takeUntil(this.destroyed$)).subscribe({
next: (activities) => {
if (activities && activities.length > 0) {
this.form.controls.ActivityId.addValidators(Validators.required);
} else {
this.form.controls.ActivityId.removeValidators(Validators.required);
}
},
error: console.error,
});
}
ngOnDestroy() {
this.destroyed$.next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@ <h1 class="font-rajdhani font-semibold text-3xl">Edit Time</h1>
</ng-template>
}
</hq-select-input>
@if (
form.get("ActivityId")?.touched &&
form.get("ActivityId")?.errors?.["required"]
) {
<span
class="text-red-700 text-xs leading-normal inline-block"
>Activity is required.</span
>
}
} @else {
<hq-form-label>Task</hq-form-label>
<input
Expand Down
10 changes: 10 additions & 0 deletions src/angular/hq/src/app/times/time-edit/time-edit.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,16 @@ export class TimeEditComponent implements OnInit, OnDestroy {
},
error: console.error,
});
this.activities$.pipe(takeUntil(this.destroyed$)).subscribe({
next: (activities) => {
if (activities && activities.length > 0) {
this.form.controls.ActivityId.addValidators(Validators.required);
} else {
this.form.controls.ActivityId.removeValidators(Validators.required);
}
},
error: console.error,
});
}

async submit() {
Expand Down
4 changes: 4 additions & 0 deletions src/angular/hq/src/app/times/time-list/time-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ export class TimeListComponent implements OnDestroy {
const invoiced$ = this.listService.invoiced.valueChanges.pipe(
startWith(this.listService.invoiced.value),
);
const billable$ = this.listService.billable.valueChanges.pipe(
startWith(this.listService.billable.value),
);
const timeStatus$ = this.listService.timeStatus.valueChanges.pipe(
startWith(this.listService.timeStatus.value),
);
Expand All @@ -123,6 +126,7 @@ export class TimeListComponent implements OnDestroy {
endDate: endDate$,
period: period$,
invoiced: invoiced$,
billable: billable$,
timeStatus: timeStatus$,
sortDirection: this.listService.sortDirection$,
};
Expand Down
Loading