Skip to content

Commit

Permalink
use the new dialog in the costs report as well
Browse files Browse the repository at this point in the history
  • Loading branch information
klaustopher committed Dec 17, 2024
1 parent 5d2ec6c commit 022e6d8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 23 deletions.
4 changes: 4 additions & 0 deletions frontend/src/app/core/path-helper/path-helper.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -106,8 +104,6 @@ const ADD_ENTRY_PROHIBITED_CLASS_NAME = '-prohibited';
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [
OpCalendarService,
TimeEntryEditService,
TimeEntryCreateService,
HalResourceEditingService,
TurboRequestsService,
PathHelperService,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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' },
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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',
Expand All @@ -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;
Expand All @@ -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'),
Expand All @@ -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() {
Expand Down

0 comments on commit 022e6d8

Please sign in to comment.