From 77e4d8b0cfafde7a6f009397123c2a6e86fc6dde Mon Sep 17 00:00:00 2001 From: Johannes Millan Date: Fri, 30 Aug 2024 14:09:02 +0200 Subject: [PATCH] feat: adjust context menu for planner and schedule --- .../schedule-event.component.ts | 25 +++++++++++++------ .../task-context-menu-inner.component.html | 13 +++++----- .../task-context-menu-inner.component.ts | 4 ++- .../task-context-menu.component.html | 1 + .../task-context-menu.component.ts | 1 + .../features/tasks/task/task.component.html | 1 + 6 files changed, 31 insertions(+), 14 deletions(-) diff --git a/src/app/features/schedule/schedule-event/schedule-event.component.ts b/src/app/features/schedule/schedule-event/schedule-event.component.ts index e6e8770d9e..e76507b13b 100644 --- a/src/app/features/schedule/schedule-event/schedule-event.component.ts +++ b/src/app/features/schedule/schedule-event/schedule-event.component.ts @@ -13,7 +13,7 @@ import { } from '@angular/core'; import { ScheduleEvent, ScheduleFromCalendarEvent } from '../schedule.model'; import { MatIcon } from '@angular/material/icon'; -import { delay, first } from 'rxjs/operators'; +import { delay, first, switchMap } from 'rxjs/operators'; import { Store } from '@ngrx/store'; import { selectProjectById } from '../../project/store/project.selectors'; import { MatMiniFabButton } from '@angular/material/button'; @@ -47,6 +47,7 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { DialogTaskDetailPanelComponent } from '../../tasks/dialog-task-additional-info-panel/dialog-task-detail-panel.component'; import { CalendarIntegrationService } from '../../calendar-integration/calendar-integration.service'; import { TaskContextMenuComponent } from '../../tasks/task-context-menu/task-context-menu.component'; +import { BehaviorSubject, of } from 'rxjs'; @Component({ selector: 'schedule-event', @@ -97,6 +98,7 @@ export class ScheduleEventComponent implements OnInit { protected readonly SVEType = SVEType; destroyRef = inject(DestroyRef); private _isBeingSubmitted: boolean = false; + private _projectId$ = new BehaviorSubject(null); @Input({ required: true }) set event(event: ScheduleEvent) { @@ -127,6 +129,7 @@ export class ScheduleEventComponent implements OnInit { this.se.type === SVEType.ScheduledTask ) { this.task = this.se.data as TaskCopy; + this._projectId$.next(this.task.projectId); if ( (this.se.type === SVEType.Task || this.se.type === SVEType.TaskPlannedForDay) && @@ -246,13 +249,21 @@ export class ScheduleEventComponent implements OnInit { ) {} ngOnInit(): void { - const pid = (this.se?.data as any)?.projectId; - if (pid) { - this._store - .select(selectProjectById, { id: pid }) - .pipe(takeUntilDestroyed(this.destroyRef)) + if (this.task) { + this._projectId$ + .pipe( + switchMap((projectId) => + projectId + ? this._store.select(selectProjectById, { id: projectId }) + : of(null), + ), + takeUntilDestroyed(this.destroyRef), + ) .subscribe((p) => { - this._elRef.nativeElement.style.setProperty('--project-color', p.theme.primary); + this._elRef.nativeElement.style.setProperty( + '--project-color', + p ? p.theme.primary : '', + ); }); } } diff --git a/src/app/features/tasks/task-context-menu/task-context-menu-inner/task-context-menu-inner.component.html b/src/app/features/tasks/task-context-menu/task-context-menu-inner/task-context-menu-inner.component.html index 0926a7051d..f1b0f54964 100644 --- a/src/app/features/tasks/task-context-menu/task-context-menu-inner/task-context-menu-inner.component.html +++ b/src/app/features/tasks/task-context-menu/task-context-menu-inner/task-context-menu-inner.component.html @@ -13,7 +13,7 @@ +