Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Remove unused components

Oliver Günther14237bdad95d
diff --git a/frontend/src/app/features/work-packages/components/wp-timer-button/wp-timer-button.component.ts b/frontend/src/app/features/work-packages/components/wp-timer-button/wp-timer-button.component.ts
index 93209049eda..ee7ff7d2739 100644
--- a/frontend/src/app/features/work-packages/components/wp-timer-button/wp-timer-button.component.ts
+++ b/frontend/src/app/features/work-packages/components/wp-timer-button/wp-timer-button.component.ts
@@ -103,6 +103,6 @@ export class WorkPackageTimerButtonComponent extends UntilDestroyedMixin {
}
stop():void {
- this.timeEntryService.stop();
+ void this.timeEntryService.stop();
}
}
diff --git a/frontend/src/app/features/work-packages/directives/query-space/wp-isolated-query-space.directive.ts b/frontend/src/app/features/work-packages/directives/query-space/wp-isolated-query-space.directive.ts
index 530dc88d444..11760dc0498 100644
--- a/frontend/src/app/features/work-packages/directives/query-space/wp-isolated-query-space.directive.ts
+++ b/frontend/src/app/features/work-packages/directives/query-space/wp-isolated-query-space.directive.ts
@@ -123,7 +123,6 @@ import { HalResourceNotificationService } from 'core-app/features/hal/services/h
import {
WorkPackageNotificationService,
} from 'core-app/features/work-packages/services/notifications/work-package-notification.service';
-import { TimeEntryCreateService } from 'core-app/shared/components/time_entries/create/create.service';
import {
WorkPackageViewCollapsedGroupsService,
} from 'core-app/features/work-packages/routing/wp-view-base/view-services/wp-view-collapsed-groups.service';
@@ -131,7 +130,6 @@ import { WorkPackageService } from 'core-app/features/work-packages/services/wor
import {
WorkPackageViewBaselineService,
} from 'core-app/features/work-packages/routing/wp-view-base/view-services/wp-view-baseline.service';
-import { TimeEntryEditService } from 'core-app/shared/components/time_entries/edit/edit.service';
/**
* Directive to open a work package query 'space', an isolated injector hierarchy
@@ -189,8 +187,6 @@ import { TimeEntryEditService } from 'core-app/shared/components/time_entries/ed
WorkPackageCardViewService,
HalResourceEditingService,
- TimeEntryCreateService,
- TimeEntryEditService,
WorkPackageCreateService,
WorkPackageStatesInitializationService,
diff --git a/frontend/src/app/shared/components/grids/widgets/time-entries/project/time-entries-project.component.ts b/frontend/src/app/shared/components/grids/widgets/time-entries/project/time-entries-project.component.ts
index aeca314da4f..e91a4e515d1 100644
--- a/frontend/src/app/shared/components/grids/widgets/time-entries/project/time-entries-project.component.ts
+++ b/frontend/src/app/shared/components/grids/widgets/time-entries/project/time-entries-project.component.ts
@@ -11,14 +11,12 @@ import { CurrentProjectService } from 'core-app/core/current-project/current-pro
import { FilterOperator } from 'core-app/shared/helpers/api-v3/api-v3-filter-builder';
import { TimezoneService } from 'core-app/core/datetime/timezone.service';
import { ConfirmDialogService } from 'core-app/shared/components/modals/confirm-dialog/confirm-dialog.service';
-import { TimeEntryEditService } from 'core-app/shared/components/time_entries/edit/edit.service';
import { HalResourceEditingService } from 'core-app/shared/components/fields/edit/services/hal-resource-editing.service';
@Component({
templateUrl: '../list/time-entries-list.component.html',
providers: [
HalResourceEditingService,
- TimeEntryEditService,
],
standalone: false,
})
diff --git a/frontend/src/app/shared/components/op-context-menu/wp-context-menu/wp-single-context-menu.ts b/frontend/src/app/shared/components/op-context-menu/wp-context-menu/wp-single-context-menu.ts
index b6ab7dd3373..f1125bede6b 100644
--- a/frontend/src/app/shared/components/op-context-menu/wp-context-menu/wp-single-context-menu.ts
+++ b/frontend/src/app/shared/components/op-context-menu/wp-context-menu/wp-single-context-menu.ts
@@ -5,13 +5,18 @@ import { AuthorisationService } from 'core-app/core/model-auth/model-auth.servic
import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';
import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';
import { HookService } from 'core-app/features/plugins/hook-service';
-import { OpContextMenuTrigger } from 'core-app/shared/components/op-context-menu/handlers/op-context-menu-trigger.directive';
-import { OPContextMenuService } from 'core-app/shared/components/op-context-menu/op-context-menu.service';
+import {
+ OpContextMenuTrigger,
+} from 'core-app/shared/components/op-context-menu/handlers/op-context-menu-trigger.directive';
import { OpContextMenuItem } from 'core-app/shared/components/op-context-menu/op-context-menu.types';
-import { PERMITTED_CONTEXT_MENU_ACTIONS } from 'core-app/shared/components/op-context-menu/wp-context-menu/wp-static-context-menu-actions';
+import {
+ PERMITTED_CONTEXT_MENU_ACTIONS,
+} from 'core-app/shared/components/op-context-menu/wp-context-menu/wp-static-context-menu-actions';
import { OpModalService } from 'core-app/shared/components/modal/modal.service';
import { CopyToClipboardService } from 'core-app/shared/components/copy-to-clipboard/copy-to-clipboard.service';
-import { WorkPackageAction } from 'core-app/features/work-packages/components/wp-table/context-menu-helper/wp-context-menu-helper.service';
+import {
+ WorkPackageAction,
+} from 'core-app/features/work-packages/components/wp-table/context-menu-helper/wp-context-menu-helper.service';
import { WpDestroyModalComponent } from 'core-app/shared/components/modals/wp-destroy-modal/wp-destroy.modal';
import { WorkPackageAuthorization } from 'core-app/features/work-packages/services/work-package-authorization.service';
import { TurboRequestsService } from 'core-app/core/turbo/turbo-requests.service';
@@ -20,31 +25,27 @@ import { TimeEntryTimerService } from 'core-app/shared/components/time_entries/s
import { TimeEntryResource } from 'core-app/features/hal/resources/time-entry-resource';
@Directive({
+ // eslint-disable-next-line @angular-eslint/directive-selector
selector: '[wpSingleContextMenu]',
standalone: false,
})
export class WorkPackageSingleContextMenuDirective extends OpContextMenuTrigger implements AfterViewInit, OnDestroy {
+ // eslint-disable-next-line @angular-eslint/no-input-rename
@Input('wpSingleContextMenu-workPackage') public workPackage:WorkPackageResource;
private currentTimer:TimeEntryResource|null = null;
-
- constructor(
- readonly HookService:HookService,
- readonly $state:StateService,
- readonly injector:Injector,
- readonly PathHelper:PathHelperService,
- readonly elementRef:ElementRef,
- readonly opModalService:OpModalService,
- readonly turboRequests:TurboRequestsService,
- readonly apiV3Service:ApiV3Service,
- readonly opContextMenuService:OPContextMenuService,
- readonly authorisationService:AuthorisationService,
- readonly timeEntryService:TimeEntryTimerService,
- protected copyToClipboardService:CopyToClipboardService,
- ) {
- super(elementRef, opContextMenuService);
- }
+ readonly HookService = inject(HookService);
+ readonly $state = inject(StateService);
+ readonly injector = inject(Injector);
+ readonly PathHelper = inject(PathHelperService);
+ readonly elementRef = inject(ElementRef);
+ readonly opModalService = inject(OpModalService);
+ readonly turboRequests = inject(TurboRequestsService);
+ readonly apiV3Service = inject(ApiV3Service);
+ readonly authorisationService = inject(AuthorisationService);
+ readonly timeEntryService = inject(TimeEntryTimerService);
+ protected copyToClipboardService = inject(CopyToClipboardService);
private closeDialogHandler:EventListener = this.handleTimeEntryDialogClose.bind(this);
@@ -78,13 +79,14 @@ export class WorkPackageSingleContextMenuDirective extends OpContextMenuTrigger
switch (key) {
case 'copy_to_other_project':
- window.location.href = `${this.PathHelper.staticBase}/work_packages/move/new?copy=true&ids[]=${this.workPackage.id as string}`;
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ window.location.href = `${this.PathHelper.staticBase}/work_packages/move/new?copy=true&ids[]=${this.workPackage.id!}`;
break;
case 'start_timer':
this.timeEntryService.start(this.workPackage);
break;
case 'stop_timer':
- this.timeEntryService.stop();
+ void this.timeEntryService.stop();
break;
case 'copy':
this.$state.go('work-packages.copy', { copiedFromWorkPackageId: this.workPackage.id });
diff --git a/frontend/src/app/shared/components/op-context-menu/wp-context-menu/wp-view-context-menu.directive.ts b/frontend/src/app/shared/components/op-context-menu/wp-context-menu/wp-view-context-menu.directive.ts
index 727102d3249..7bc4ad54316 100644
--- a/frontend/src/app/shared/components/op-context-menu/wp-context-menu/wp-view-context-menu.directive.ts
+++ b/frontend/src/app/shared/components/op-context-menu/wp-context-menu/wp-view-context-menu.directive.ts
@@ -4,8 +4,12 @@ import {
WorkPackageContextMenuHelperService,
} from 'core-app/features/work-packages/components/wp-table/context-menu-helper/wp-context-menu-helper.service';
import { States } from 'core-app/core/states/states.service';
-import { WorkPackageRelationsHierarchyService } from 'core-app/features/work-packages/components/wp-relations/wp-relations-hierarchy/wp-relations-hierarchy.service';
-import { WorkPackageViewSelectionService } from 'core-app/features/work-packages/routing/wp-view-base/view-services/wp-view-selection.service';
+import {
+ WorkPackageRelationsHierarchyService,
+} from 'core-app/features/work-packages/components/wp-relations/wp-relations-hierarchy/wp-relations-hierarchy.service';
+import {
+ WorkPackageViewSelectionService,
+} from 'core-app/features/work-packages/routing/wp-view-base/view-services/wp-view-selection.service';
import { isClickedWithModifier } from 'core-app/shared/helpers/link-handling/link-handling';
import { OpContextMenuHandler } from 'core-app/shared/components/op-context-menu/op-context-menu-handler';
import { OPContextMenuService } from 'core-app/shared/components/op-context-menu/op-context-menu.service';
@@ -13,12 +17,13 @@ import {
OpContextMenuItem,
OpContextMenuLocalsMap,
} from 'core-app/shared/components/op-context-menu/op-context-menu.types';
-import { PERMITTED_CONTEXT_MENU_ACTIONS } from 'core-app/shared/components/op-context-menu/wp-context-menu/wp-static-context-menu-actions';
+import {
+ PERMITTED_CONTEXT_MENU_ACTIONS,
+} from 'core-app/shared/components/op-context-menu/wp-context-menu/wp-static-context-menu-actions';
import { OpModalService } from 'core-app/shared/components/modal/modal.service';
import { StateService } from '@uirouter/core';
import { InjectField } from 'core-app/shared/helpers/angular/inject-field.decorator';
import { CopyToClipboardService } from 'core-app/shared/components/copy-to-clipboard/copy-to-clipboard.service';
-import { TimeEntryCreateService } from 'core-app/shared/components/time_entries/create/create.service';
import { splitViewRoute } from 'core-app/features/work-packages/routing/split-view-routes.helper';
import { WpDestroyModalComponent } from 'core-app/shared/components/modals/wp-destroy-modal/wp-destroy.modal';
import isNewResource from 'core-app/features/hal/helpers/is-new-resource';
@@ -38,8 +43,6 @@ export class WorkPackageViewContextMenu extends OpContextMenuHandler {
@InjectField() protected WorkPackageContextMenuHelper!:WorkPackageContextMenuHelperService;
- @InjectField() protected timeEntryCreateService:TimeEntryCreateService;
-
@InjectField() protected pathHelper:PathHelperService;
@InjectField() protected turboRequests:TurboRequestsService;
diff --git a/frontend/src/app/shared/components/time_entries/create/create.modal.ts b/frontend/src/app/shared/components/time_entries/create/create.modal.ts
deleted file mode 100644
index 378351d076a..00000000000
--- a/frontend/src/app/shared/components/time_entries/create/create.modal.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import { ChangeDetectionStrategy, Component } from '@angular/core';
-import { HalResourceEditingService } from 'core-app/shared/components/fields/edit/services/hal-resource-editing.service';
-import { TimeEntryResource } from 'core-app/features/hal/resources/time-entry-resource';
-import { HalResource } from 'core-app/features/hal/resources/hal-resource';
-import { TimeEntryBaseModal } from '../shared/modal/base.modal';
-
-@Component({
- templateUrl: '../shared/modal/base.modal.html',
- changeDetection: ChangeDetectionStrategy.OnPush,
- providers: [
- HalResourceEditingService,
- ],
- standalone: false,
-})
-export class TimeEntryCreateModalComponent extends TimeEntryBaseModal {
- public createdEntry:TimeEntryResource;
-
- public get deleteAllowed() {
- return false;
- }
-
- public setModifiedEntry($event:{ savedResource:HalResource, isInital:boolean }) {
- this.createdEntry = $event.savedResource as TimeEntryResource;
- this.reloadWorkPackageAndClose();
- }
-}
diff --git a/frontend/src/app/shared/components/time_entries/create/create.service.ts b/frontend/src/app/shared/components/time_entries/create/create.service.ts
deleted file mode 100644
index c9bcc7f8fb5..00000000000
--- a/frontend/src/app/shared/components/time_entries/create/create.service.ts
+++ /dev/null
@@ -1,83 +0,0 @@
-import {
- Injectable,
- Injector,
-} from '@angular/core';
-import { OpModalService } from 'core-app/shared/components/modal/modal.service';
-import { HalResourceService } from 'core-app/features/hal/services/hal-resource.service';
-import { I18nService } from 'core-app/core/i18n/i18n.service';
-import { FormResource } from 'core-app/features/hal/resources/form-resource';
-import { ResourceChangeset } from 'core-app/shared/components/fields/changeset/resource-changeset';
-import { HalResourceEditingService } from 'core-app/shared/components/fields/edit/services/hal-resource-editing.service';
-import { Moment } from 'moment';
-import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';
-import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';
-import { SchemaCacheService } from 'core-app/core/schemas/schema-cache.service';
-import { TimeEntryResource } from 'core-app/features/hal/resources/time-entry-resource';
-import { HalResource } from 'core-app/features/hal/resources/hal-resource';
-import { Observable, of } from 'rxjs';
-
-@Injectable()
-export class TimeEntryCreateService {
- constructor(
- readonly opModalService:OpModalService,
- readonly injector:Injector,
- readonly halResource:HalResourceService,
- readonly apiV3Service:ApiV3Service,
- readonly schemaCache:SchemaCacheService,
- protected halEditing:HalResourceEditingService,
- readonly i18n:I18nService,
- ) {
- }
-
- public createNewTimeEntry(date:Moment, wp:WorkPackageResource, ongoing:boolean):Observable<ResourceChangeset> {
- const resource:FormResource = this.halResource.createHalResourceOfType(
- 'Form',
- {
- payload: {
- spentOn: date.format('YYYY-MM-DD'),
- hours: null,
- ongoing,
- _links: {
- workPackage: {
- href: wp.href,
- },
- },
- },
- },
- );
-
- return of(this.fromCreateForm(resource));
- }
-
- public fromCreateForm(form:FormResource):ResourceChangeset {
- const entry = this.initializeNewResource(form);
-
- return this.halEditing.edit<TimeEntryResource, ResourceChangeset<TimeEntryResource>>(entry, form);
- }
-
- private initializeNewResource(form:FormResource):TimeEntryResource {
- const entry = this.halResource.createHalResourceOfType<TimeEntryResource>(
- 'TimeEntry',
- (form.payload as HalResource).$plain(),
- );
-
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
- entry.$links.schema = { href: 'new' };
-
- entry._type = 'TimeEntry';
- entry.id = 'new';
- entry.hours = 'PT1H';
-
- // Use POST /work_packages for saving link
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,no-multi-assign
- entry.updateImmediately = entry.$links.updateImmediately = (payload:Record<string, unknown>) => this
- .apiV3Service
- .time_entries
- .post(payload)
- .toPromise();
-
- entry.state.putValue(entry);
-
- return entry;
- }
-}
diff --git a/frontend/src/app/shared/components/time_entries/edit/edit.modal.ts b/frontend/src/app/shared/components/time_entries/edit/edit.modal.ts
deleted file mode 100644
index e300f71b782..00000000000
--- a/frontend/src/app/shared/components/time_entries/edit/edit.modal.ts
+++ /dev/null
@@ -1,46 +0,0 @@
-import {
- ChangeDetectionStrategy,
- Component,
- OnInit,
-} from '@angular/core';
-import { TimeEntryResource } from 'core-app/features/hal/resources/time-entry-resource';
-import { HalResource } from 'core-app/features/hal/resources/hal-resource';
-import { TimeEntryBaseModal } from 'core-app/shared/components/time_entries/shared/modal/base.modal';
-
-@Component({
- templateUrl: '../shared/modal/base.modal.html',
- changeDetection: ChangeDetectionStrategy.OnPush,
- standalone: false,
-})
-export class TimeEntryEditModalComponent extends TimeEntryBaseModal implements OnInit {
- public modifiedEntry:TimeEntryResource;
-
- public destroyedEntry:TimeEntryResource;
-
- ngOnInit() {
- super.ngOnInit();
- }
-
- public setModifiedEntry($event:{ savedResource:HalResource, isInital:boolean }) {
- this.modifiedEntry = $event.savedResource as TimeEntryResource;
- this.reloadWorkPackageAndClose();
- }
-
- public get saveAllowed() {
- return !!this.entry.update;
- }
-
- public get deleteAllowed() {
- return !!this.entry.delete;
- }
-
- public destroy() {
- // eslint-disable-next-line no-alert
- if (!window.confirm(this.text.areYouSure)) {
- return;
- }
-
- this.destroyedEntry = this.entry;
- this.service.close();
- }
-}
diff --git a/frontend/src/app/shared/components/time_entries/edit/edit.service.ts b/frontend/src/app/shared/components/time_entries/edit/edit.service.ts
deleted file mode 100644
index 17024e66c85..00000000000
--- a/frontend/src/app/shared/components/time_entries/edit/edit.service.ts
+++ /dev/null
@@ -1,109 +0,0 @@
-import {
- Injectable,
- Injector,
-} from '@angular/core';
-import { OpModalService } from 'core-app/shared/components/modal/modal.service';
-import { HalResourceService } from 'core-app/features/hal/services/hal-resource.service';
-import { I18nService } from 'core-app/core/i18n/i18n.service';
-import { take } from 'rxjs/operators';
-import { HalResourceEditingService } from 'core-app/shared/components/fields/edit/services/hal-resource-editing.service';
-import { ResourceChangeset } from 'core-app/shared/components/fields/changeset/resource-changeset';
-import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';
-import { TimeEntryResource } from 'core-app/features/hal/resources/time-entry-resource';
-import { TimeEntryEditModalComponent } from './edit.modal';
-import moment from 'moment';
-import { SchemaCacheService } from 'core-app/core/schemas/schema-cache.service';
-import { TimezoneService } from 'core-app/core/datetime/timezone.service';
-import { TimeEntryTimerService } from 'core-app/shared/components/time_entries/services/time-entry-timer.service';
-
-export interface TimeEntryModalOptions {
- showWorkPackageField?:boolean;
- showUserField?:boolean;
-}
-
-export interface TimeEntryUpdate {
- entry:TimeEntryResource,
- action:'update'|'destroy'|'unchanged';
-}
-
-@Injectable()
-export class TimeEntryEditService {
- constructor(
- readonly opModalService:OpModalService,
- readonly injector:Injector,
- readonly apiV3Service:ApiV3Service,
- readonly halResource:HalResourceService,
- readonly schemaCache:SchemaCacheService,
- readonly timezoneService:TimezoneService,
- readonly timeEntryService:TimeEntryTimerService,
- protected halEditing:HalResourceEditingService,
- readonly i18n:I18nService,
- ) {
- }
-
- public edit(
- entry:TimeEntryResource,
- options:TimeEntryModalOptions = {},
- ):Promise<TimeEntryUpdate> {
- return this
- .createChangeset(entry)
- .then((changeset) => this.editChange(changeset, options));
- }
-
- public editChange(changeset:ResourceChangeset<TimeEntryResource>, options:TimeEntryModalOptions = {}) {
- return new Promise<TimeEntryUpdate>((resolve, _) => {
- this
- .opModalService
- .show(
- TimeEntryEditModalComponent,
- this.injector,
- { ...options, changeset },
- ).subscribe((modal) => {
- modal
- .closingEvent
- .pipe(take(1))
- .subscribe(() => {
- if (modal.destroyedEntry) {
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
- void modal.destroyedEntry.delete().then(() => {
- resolve({ entry: modal.destroyedEntry, action: 'destroy' });
- });
- } else if (modal.modifiedEntry) {
- resolve({ entry: modal.modifiedEntry, action: 'update' });
- } else {
- resolve({ entry: modal.entry, action: 'unchanged' });
- }
- });
- });
- });
- }
-
- public async stopTimerAndEdit(activeTimer:TimeEntryResource):Promise<unknown> {
- await this.schemaCache.ensureLoaded(activeTimer);
-
- const change = this.halEditing.edit(activeTimer);
- const hours = moment().diff(moment(activeTimer.createdAt as string), 'hours', true);
- const formatted = this.timezoneService.toISODuration(hours, 'hours');
- change.setValue('hours', formatted);
- change.setValue('ongoing', false);
-
- return this
- .editChange(change)
- .then((update) => {
- if (update.action !== 'unchanged') {
- this.timeEntryService.timer$.next(null);
- }
- });
- }
-
- public createChangeset(entry:TimeEntryResource):Promise<ResourceChangeset<TimeEntryResource>> {
- return this
- .apiV3Service
- .time_entries
- .id(entry)
- .form
- .post(entry)
- .toPromise()
- .then((form) => this.halEditing.edit<TimeEntryResource, ResourceChangeset<TimeEntryResource>>(entry, form));
- }
-}
diff --git a/frontend/src/app/shared/components/time_entries/form/form.component.html b/frontend/src/app/shared/components/time_entries/form/form.component.html
deleted file mode 100644
index 1e36f04786c..00000000000
--- a/frontend/src/app/shared/components/time_entries/form/form.component.html
+++ /dev/null
@@ -1,92 +0,0 @@
-<edit-form
- #editForm
- [resource]="entry"
- [inEditMode]="inEditMode"
- (onSaved)="signalModifiedEntry($event)"
->
- <div class="attributes-map">
- <ng-container *ngIf="showUserField && schema.user.writable">
- <div class="attributes-map--key"
- [ngClass]="{'-required': isRequired('user')}"
- [textContent]="schema.user.name">
- </div>
- <div class="attributes-map--value">
- <op-editable-attribute-field [resource]="entry"
- [wrapperClasses]="'-tiny'"
- [fieldName]="'user'">
- </op-editable-attribute-field>
- </div>
- </ng-container>
-
- <div class="attributes-map--key"
- [ngClass]="{'-required': isRequired('spentOn')}"
- [textContent]="schema.spentOn.name">
- </div>
- <div class="attributes-map--value attributes-map--value_overflow">
- <op-editable-attribute-field [resource]="entry"
- [wrapperClasses]="'-tiny'"
- [fieldName]="'spentOn'">
- </op-editable-attribute-field>
- </div>
-
- <div class="attributes-map--key"
- [ngClass]="{'-required': isRequired('hours')}"
- [textContent]="schema.hours.name">
- </div>
- <div class="attributes-map--value">
- <op-editable-attribute-field [resource]="entry"
- [wrapperClasses]="'-tiny'"
- [fieldName]="'hours'">
- </op-editable-attribute-field>
- </div>
-
- <ng-container *ngIf="showWorkPackageField">
- <div class="attributes-map--key"
- [ngClass]="{'-required': isRequired('workPackage')}"
- [textContent]="schema.workPackage.name">
- </div>
- <div class="attributes-map--value">
- <op-editable-attribute-field [resource]="entry"
- [fieldName]="'workPackage'">
- </op-editable-attribute-field>
- </div>
- </ng-container>
-
- <div class="attributes-map--key"
- [ngClass]="{'-required': isRequired('activity')}"
- [textContent]="schema.activity.name">
- </div>
- <div class="attributes-map--value">
- <op-editable-attribute-field *ngIf="workPackageSelected"
- [resource]="entry"
- [fieldName]="'activity'">
- </op-editable-attribute-field>
- <i *ngIf="!workPackageSelected"
- [textContent]="text.wpRequired">
- </i>
- </div>
-
- <div class="attributes-map--key"
- [ngClass]="{'-required': isRequired('comment')}"
- [textContent]="schema.comment.name">
- </div>
- <div class="attributes-map--value">
- <op-editable-attribute-field [resource]="entry"
- [fieldName]="'comment'">
- </op-editable-attribute-field>
- </div>
-
- <ng-container *ngFor="let cf of customFields">
- <div class="attributes-map--key"
- [ngClass]="{'-required': isRequired(cf.key)}"
- [textContent]="cf.label">
- </div>
- <div class="attributes-map--value">
- <op-editable-attribute-field [resource]="entry"
- [fieldName]="cf.key"
- [wrapperClasses]="cf.type === 'Date' ? '-tiny' : null">
- </op-editable-attribute-field>
- </div>
- </ng-container>
- </div>
-</edit-form>
diff --git a/frontend/src/app/shared/components/time_entries/form/form.component.ts b/frontend/src/app/shared/components/time_entries/form/form.component.ts
deleted file mode 100644
index 43ee291061d..00000000000
--- a/frontend/src/app/shared/components/time_entries/form/form.component.ts
+++ /dev/null
@@ -1,114 +0,0 @@
-import { HalResourceEditingService } from 'core-app/shared/components/fields/edit/services/hal-resource-editing.service';
-import { TimeEntryResource } from 'core-app/features/hal/resources/time-entry-resource';
-import { I18nService } from 'core-app/core/i18n/i18n.service';
-import {
- ChangeDetectionStrategy,
- ChangeDetectorRef,
- Component,
- EventEmitter,
- Input,
- OnDestroy,
- OnInit,
- Output,
- ViewChild,
- ViewEncapsulation,
-} from '@angular/core';
-import { HalResource } from 'core-app/features/hal/resources/hal-resource';
-import { EditFormComponent } from 'core-app/shared/components/fields/edit/edit-form/edit-form.component';
-import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';
-import { ResourceChangeset } from 'core-app/shared/components/fields/changeset/resource-changeset';
-import { SchemaResource } from 'core-app/features/hal/resources/schema-resource';
-
-@Component({
- templateUrl: './form.component.html',
- selector: 'te-form',
- encapsulation: ViewEncapsulation.None,
- changeDetection: ChangeDetectionStrategy.OnPush,
- standalone: false,
-})
-export class TimeEntryFormComponent extends UntilDestroyedMixin implements OnInit, OnDestroy {
- @Input() changeset:ResourceChangeset<TimeEntryResource>;
-
- @Input() showWorkPackageField = true;
-
- @Input() showUserField = true;
-
- @Output() modifiedEntry = new EventEmitter<{ savedResource:TimeEntryResource, isInital:boolean }>();
-
- @ViewChild('editForm', { static: true }) editForm:EditFormComponent;
-
- text = {
- wpRequired: this.i18n.t('js.time_entry.work_package_required'),
- };
-
- public workPackageSelected = false;
-
- public schema:SchemaResource;
-
- public customFields:{ key:string, label:string, type:string }[] = [];
-
- constructor(readonly halEditing:HalResourceEditingService,
- readonly cdRef:ChangeDetectorRef,
- readonly i18n:I18nService) {
- super();
- }
-
- ngOnInit() {
- this.halEditing
- .temporaryEditResource(this.changeset.projectedResource)
- .values$()
- .pipe(
- this.untilDestroyed(),
- )
- .subscribe((changeset) => {
- if (changeset && changeset.workPackage) {
- this.workPackageSelected = true;
- this.cdRef.markForCheck();
- }
- });
-
- this.schema = this.changeset.schema;
- this.workPackageSelected = !!this.changeset?.value('workPackage');
- this.setCustomFields();
- this.cdRef.detectChanges();
- }
-
- public get entry() {
- return this.changeset.projectedResource;
- }
-
- public signalModifiedEntry($event:{ savedResource:HalResource, isInital:boolean }) {
- this.modifiedEntry.emit($event as { savedResource:TimeEntryResource, isInital:boolean });
- }
-
- public save() {
- return this.editForm.submit();
- }
-
- public get inEditMode() {
- // For now, we always want the form in edit mode.
- // Alternatively, this.entry.isNew can be used.
- return true;
- }
-
- public isRequired(field:string) {
- // Other than defined in the schema, we consider the work package to be required.
- // Remove once the schema requires it explicitly.
- if (field === 'workPackage') {
- return true;
- }
- return this.schema.ofProperty(field).required;
- }
-
- private setCustomFields() {
- Object.entries(this.schema).forEach(([key, keySchema]) => {
- if (/customField\d+/.exec(key) && this.isACustomField(keySchema)) {
- this.customFields.push({ key, label: keySchema.name || '', type: keySchema.type });
- }
- });
- }
-
- private isACustomField(obj:unknown):obj is IOPFieldSchema {
- return !!(obj as IOPFieldSchema).type;
- }
-}
diff --git a/frontend/src/app/shared/components/time_entries/openproject-time-entries.module.ts b/frontend/src/app/shared/components/time_entries/openproject-time-entries.module.ts
index cd391370222..8aee47a784b 100644
--- a/frontend/src/app/shared/components/time_entries/openproject-time-entries.module.ts
+++ b/frontend/src/app/shared/components/time_entries/openproject-time-entries.module.ts
@@ -29,19 +29,15 @@
import { NgModule } from '@angular/core';
import { OpSharedModule } from 'core-app/shared/shared.module';
import { OpenprojectModalModule } from 'core-app/shared/components/modal/modal.module';
-import { OpenprojectFieldsModule } from 'core-app/shared/components/fields/openproject-fields.module';
-import { TimeEntryCreateModalComponent } from 'core-app/shared/components/time_entries/create/create.modal';
-import { TimeEntryEditModalComponent } from 'core-app/shared/components/time_entries/edit/edit.modal';
-import { TimeEntryFormComponent } from 'core-app/shared/components/time_entries/form/form.component';
-import { TriggerActionsEntryComponent } from 'core-app/shared/components/time_entries/edit/trigger-actions-entry.component';
+import {
+ TriggerActionsEntryComponent,
+} from 'core-app/shared/components/time_entries/edit/trigger-actions-entry.component';
import { TimeEntryTimerService } from 'core-app/shared/components/time_entries/services/time-entry-timer.service';
import { CommonModule } from '@angular/common';
import { TimerAccountMenuComponent } from 'core-app/shared/components/time_entries/timer/timer-account-menu.component';
-import { StopExistingTimerModalComponent } from 'core-app/shared/components/time_entries/timer/stop-existing-timer-modal.component';
-import { TimeEntryCreateService } from 'core-app/shared/components/time_entries/create/create.service';
import {
- HalResourceEditingService
-} from 'core-app/shared/components/fields/edit/services/hal-resource-editing.service';
+ StopExistingTimerModalComponent,
+} from 'core-app/shared/components/time_entries/timer/stop-existing-timer-modal.component';
@NgModule({
imports: [
@@ -49,20 +45,13 @@ import {
CommonModule,
OpSharedModule,
OpenprojectModalModule,
-
- // Editable fields e.g. for modals
- OpenprojectFieldsModule,
],
declarations: [
- TimeEntryEditModalComponent,
- TimeEntryCreateModalComponent,
- TimeEntryFormComponent,
TriggerActionsEntryComponent,
TimerAccountMenuComponent,
StopExistingTimerModalComponent,
],
providers: [
- TimeEntryCreateService,
TimeEntryTimerService,
],
})
diff --git a/frontend/src/app/shared/components/time_entries/shared/modal/base.modal.html b/frontend/src/app/shared/components/time_entries/shared/modal/base.modal.html
deleted file mode 100644
index 90655e678e5..00000000000
--- a/frontend/src/app/shared/components/time_entries/shared/modal/base.modal.html
+++ /dev/null
@@ -1,50 +0,0 @@
-<div
- class="spot-modal spot-modal_allow-overflow loading-indicator--location"
- data-indicator-name="modal"
->
- <div class="spot-modal--header">
- <span class="spot-icon spot-icon_time"></span>
- <span id="spotModalTitle" [textContent]="text.title"></span>
- </div>
-
- <div class="spot-divider"></div>
-
- <div class="spot-modal--body spot-container">
- <te-form
- #editForm
- [changeset]="changeset"
- [showWorkPackageField]="showWorkPackageField"
- [showUserField]="showUserField"
- (modifiedEntry)="setModifiedEntry($event)"
- ></te-form>
- </div>
-
- <div class="spot-action-bar">
- <div class="spot-action-bar--left">
- <button
- class="button button_no-margin -danger spot-action-bar--action"
- *ngIf="deleteAllowed"
- (click)="destroy()"
- [textContent]="text.delete"
- [attr.title]="text.delete"
- ></button>
- </div>
- <div class="spot-action-bar--right">
- <button
- class="button button_no-margin spot-modal--cancel-button spot-action-bar--action"
- *ngIf="saveAllowed"
- (click)="closeMe($event)"
- [textContent]="text.cancel"
- [attr.title]="text.cancel"
- ></button>
- <button
- class="button -primary button_no-margin spot-action-bar--action"
- *ngIf="saveAllowed"
- (click)="saveEntry()"
- [attr.title]="text.save"
- [textContent]="text.save"
- [disabled]="formInFlight"
- ></button>
- </div>
- </div>
-</div>
diff --git a/frontend/src/app/shared/components/time_entries/shared/modal/base.modal.ts b/frontend/src/app/shared/components/time_entries/shared/modal/base.modal.ts
deleted file mode 100644
index abf373d0ac7..00000000000
--- a/frontend/src/app/shared/components/time_entries/shared/modal/base.modal.ts
+++ /dev/null
@@ -1,100 +0,0 @@
-import {
- ChangeDetectorRef,
- Directive,
- ElementRef,
- Inject,
- Injector,
- OnInit,
- ViewChild,
-} from '@angular/core';
-import { OpModalComponent } from 'core-app/shared/components/modal/modal.component';
-import { OpModalLocalsToken } from 'core-app/shared/components/modal/modal.service';
-import { OpModalLocalsMap } from 'core-app/shared/components/modal/modal.types';
-import { I18nService } from 'core-app/core/i18n/i18n.service';
-import { TimeEntryFormComponent } from 'core-app/shared/components/time_entries/form/form.component';
-import { HalResource } from 'core-app/features/hal/resources/hal-resource';
-import { InjectField } from 'core-app/shared/helpers/angular/inject-field.decorator';
-import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';
-import { TimeEntryResource } from 'core-app/features/hal/resources/time-entry-resource';
-import { ResourceChangeset } from 'core-app/shared/components/fields/changeset/resource-changeset';
-
-@Directive()
-export abstract class TimeEntryBaseModal extends OpModalComponent implements OnInit {
- @ViewChild('editForm', { static: true }) editForm:TimeEntryFormComponent;
-
- public text:{ [key:string]:string } = {
- title: this.i18n.t('js.time_entry.title'),
- cancel: this.i18n.t('js.button_cancel'),
- close: this.i18n.t('js.button_close'),
- save: this.i18n.t('js.button_save'),
- delete: this.i18n.t('js.button_delete'),
- areYouSure: this.i18n.t('js.text_are_you_sure'),
- };
-
- public formInFlight:boolean;
-
- public changeset:ResourceChangeset<TimeEntryResource>;
-
- @InjectField() apiV3Service:ApiV3Service;
-
- constructor(readonly elementRef:ElementRef,
- @Inject(OpModalLocalsToken) readonly locals:OpModalLocalsMap,
- readonly cdRef:ChangeDetectorRef,
- readonly i18n:I18nService,
- readonly injector:Injector) {
- super(locals, cdRef, elementRef);
- }
-
- ngOnInit() {
- super.ngOnInit();
- this.changeset = this.locals.changeset as ResourceChangeset<TimeEntryResource>;
- }
-
- public abstract setModifiedEntry($event:{ savedResource:HalResource, isInital:boolean }):void;
-
- public get entry():TimeEntryResource {
- return this.changeset.projectedResource;
- }
-
- public get showWorkPackageField():boolean {
- return this.locals.showWorkPackageField !== false;
- }
-
- public get showUserField():boolean {
- return this.locals.showUserField !== false;
- }
-
- public saveEntry():void {
- this.formInFlight = true;
-
- this.editForm.save()
- .then(() => this.reloadWorkPackageAndClose())
- .catch(() => {
- this.formInFlight = false;
- this.cdRef.detectChanges();
- });
- }
-
- public get saveAllowed():boolean {
- return true;
- }
-
- public get deleteAllowed():boolean {
- return true;
- }
-
- protected reloadWorkPackageAndClose():void {
- this.service.close();
- this.formInFlight = false;
- // reload workPackage
- if (this.entry.workPackage) {
- void this
- .apiV3Service
- .work_packages
- .id(this.entry.workPackage)
- .refresh();
- }
-
- this.cdRef.detectChanges();
- }
-}
diff --git a/frontend/src/app/shared/components/time_entries/timer/timer-account-menu.component.ts b/frontend/src/app/shared/components/time_entries/timer/timer-account-menu.component.ts
index 6f9c85a3304..46fe5833f81 100644
--- a/frontend/src/app/shared/components/time_entries/timer/timer-account-menu.component.ts
+++ b/frontend/src/app/shared/components/time_entries/timer/timer-account-menu.component.ts
@@ -11,22 +11,10 @@ import {
import { TimeEntryTimerService } from 'core-app/shared/components/time_entries/services/time-entry-timer.service';
import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';
import { TimeEntryResource } from 'core-app/features/hal/resources/time-entry-resource';
-import {
- firstValueFrom,
- Observable,
- switchMap,
- timer,
-} from 'rxjs';
-import {
- filter,
- map,
-} from 'rxjs/operators';
+import { firstValueFrom, Observable, switchMap, timer } from 'rxjs';
+import { filter, map } from 'rxjs/operators';
import { formatElapsedTime } from 'core-app/features/work-packages/components/wp-timer-button/time-formatter.helper';
import { I18nService } from 'core-app/core/i18n/i18n.service';
-import { TimeEntryEditService } from '../edit/edit.service';
-import { HalResourceEditingService } from '../../fields/edit/services/hal-resource-editing.service';
-import { SchemaCacheService } from 'core-app/core/schemas/schema-cache.service';
-import { TimezoneService } from 'core-app/core/datetime/timezone.service';
import { ToastService } from 'core-app/shared/components/toaster/toast.service';
import { InjectField } from 'core-app/shared/helpers/angular/inject-field.decorator';
import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';
@@ -40,8 +28,6 @@ export const timerAccountSelector = 'op-timer-account-menu';
styleUrls: ['./timer-account-menu.component.sass'],
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
- providers: [TimeEntryEditService,
- HalResourceEditingService],
standalone: false,
})
export class TimerAccountMenuComponent extends UntilDestroyedMixin implements OnInit {
@@ -70,10 +56,6 @@ export class TimerAccountMenuComponent extends UntilDestroyedMixin implements On
readonly timeEntryService:TimeEntryTimerService,
readonly cdRef:ChangeDetectorRef,
readonly I18n:I18nService,
- readonly timeEntryEditService:TimeEntryEditService,
- readonly halEditing:HalResourceEditingService,
- readonly schemaCache:SchemaCacheService,
- readonly timezoneService:TimezoneService,
readonly toastService:ToastService,
) {
super();
@@ -98,7 +80,8 @@ export class TimerAccountMenuComponent extends UntilDestroyedMixin implements On
}
return this.TurboRequests.request(
- `${this.PathHelper.timeEntryEditDialog(active.id as string)}`,
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ this.PathHelper.timeEntryEditDialog(active.id!),
{ method: 'GET' },
);
}