From 022e6d87dfad79673b6d07e2446460555d83ffc4 Mon Sep 17 00:00:00 2001 From: Klaus Zanders Date: Mon, 16 Dec 2024 16:02:26 +0100 Subject: [PATCH] use the new dialog in the costs report as well --- .../core/path-helper/path-helper.service.ts | 4 +++ .../te-calendar/te-calendar.component.ts | 8 +---- .../edit/trigger-actions-entry.component.ts | 31 +++++++++---------- 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/frontend/src/app/core/path-helper/path-helper.service.ts b/frontend/src/app/core/path-helper/path-helper.service.ts index 919c86e38c82..1cb5e3784357 100644 --- a/frontend/src/app/core/path-helper/path-helper.service.ts +++ b/frontend/src/app/core/path-helper/path-helper.service.ts @@ -342,6 +342,10 @@ export class PathHelperService { return `${this.staticBase}/time_entries/dialog`; } + public timeEntryEditDialog(timeEntryId:string) { + return `${this.timeEntryDialog()}?time_entry_id=${timeEntryId}`; + } + public timeEntryWorkPackageDialog(workPackageId:string) { return `${this.workPackagePath(workPackageId)}/time_entries/dialog`; } diff --git a/frontend/src/app/features/calendar/te-calendar/te-calendar.component.ts b/frontend/src/app/features/calendar/te-calendar/te-calendar.component.ts index 2e9020b352bb..877703847a18 100644 --- a/frontend/src/app/features/calendar/te-calendar/te-calendar.component.ts +++ b/frontend/src/app/features/calendar/te-calendar/te-calendar.component.ts @@ -35,8 +35,6 @@ import { TimeEntryResource } from 'core-app/features/hal/resources/time-entry-re import { CollectionResource } from 'core-app/features/hal/resources/collection-resource'; import interactionPlugin from '@fullcalendar/interaction'; import { HalResourceEditingService } from 'core-app/shared/components/fields/edit/services/hal-resource-editing.service'; -import { TimeEntryEditService } from 'core-app/shared/components/time_entries/edit/edit.service'; -import { TimeEntryCreateService } from 'core-app/shared/components/time_entries/create/create.service'; import { ColorsService } from 'core-app/shared/components/colors/colors.service'; import { BrowserDetector } from 'core-app/core/browser/browser-detector.service'; import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service'; @@ -106,8 +104,6 @@ const ADD_ENTRY_PROHIBITED_CLASS_NAME = '-prohibited'; changeDetection: ChangeDetectionStrategy.OnPush, providers: [ OpCalendarService, - TimeEntryEditService, - TimeEntryCreateService, HalResourceEditingService, TurboRequestsService, PathHelperService, @@ -213,8 +209,6 @@ export class TimeEntryCalendarComponent { private sanitizer:DomSanitizer, private configuration:ConfigurationService, private timezone:TimezoneService, - private timeEntryEdit:TimeEntryEditService, - private timeEntryCreate:TimeEntryCreateService, private schemaCache:SchemaCacheService, private colors:ColorsService, private browserDetector:BrowserDetector, @@ -486,7 +480,7 @@ export class TimeEntryCalendarComponent { private editEvent(entry:TimeEntryResource):void { void this.turboRequests.request( - `${this.pathHelper.timeEntryDialog()}?time_entry_id=${entry.id}`, + `${this.pathHelper.timeEntryEditDialog(entry.id as string)}`, { method: 'GET' }, ); } diff --git a/frontend/src/app/shared/components/time_entries/edit/trigger-actions-entry.component.ts b/frontend/src/app/shared/components/time_entries/edit/trigger-actions-entry.component.ts index 8f8a6b83795f..421a082af515 100644 --- a/frontend/src/app/shared/components/time_entries/edit/trigger-actions-entry.component.ts +++ b/frontend/src/app/shared/components/time_entries/edit/trigger-actions-entry.component.ts @@ -1,6 +1,5 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, Injector } from '@angular/core'; import { InjectField } from 'core-app/shared/helpers/angular/inject-field.decorator'; -import { TimeEntryEditService } from 'core-app/shared/components/time_entries/edit/edit.service'; import { I18nService } from 'core-app/core/i18n/i18n.service'; import { ToastService } from 'core-app/shared/components/toaster/toast.service'; import { @@ -9,6 +8,8 @@ import { import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service'; import { TimeEntryResource } from 'core-app/features/hal/resources/time-entry-resource'; import { Observable, switchMap } from 'rxjs'; +import { PathHelperService } from 'core-app/core/path-helper/path-helper.service'; +import { TurboRequestsService } from 'core-app/core/turbo/turbo-requests.service'; @Component({ selector: 'opce-time-entry-trigger-actions', @@ -27,12 +28,11 @@ import { Observable, switchMap } from 'rxjs'; changeDetection: ChangeDetectionStrategy.OnPush, providers: [ HalResourceEditingService, - TimeEntryEditService, + PathHelperService, + TurboRequestsService, ], }) export class TriggerActionsEntryComponent { - @InjectField() readonly timeEntryEditService:TimeEntryEditService; - @InjectField() readonly apiv3Service:ApiV3Service; @InjectField() readonly toastService:ToastService; @@ -43,6 +43,10 @@ export class TriggerActionsEntryComponent { @InjectField() readonly cdRef:ChangeDetectorRef; + @InjectField() readonly pathHelper:PathHelperService; + + @InjectField() readonly turboRequestService:TurboRequestsService; + public text = { edit: this.i18n.t('js.button_edit'), delete: this.i18n.t('js.button_delete'), @@ -54,18 +58,13 @@ export class TriggerActionsEntryComponent { } editTimeEntry() { - void this - .loadEntry() - .subscribe((entry) => { - this.timeEntryEditService - .edit(entry) - .then(() => { - window.location.reload(); - }) - .catch(() => { - // User canceled the modal - }); - }); + void this.loadEntry().subscribe((entry:TimeEntryResource) => { + // TODO: We need to reload here when the dialog is submitted ... How should we do this? + void this.turboRequestService.request( + this.pathHelper.timeEntryEditDialog(entry.id as string), + { method: 'GET' }, + ); + }); } deleteTimeEntry() {