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 event lookup service

Oliver Günther3ea9016040db
diff --git a/frontend/src/app/features/team-planner/team-planner/planner/event-view-lookup.service.ts b/frontend/src/app/features/team-planner/team-planner/planner/event-view-lookup.service.ts
deleted file mode 100644
index 94612f91490..00000000000
--- a/frontend/src/app/features/team-planner/team-planner/planner/event-view-lookup.service.ts
+++ /dev/null
@@ -1,123 +0,0 @@
-import {
- EmbeddedViewRef,
- Injectable,
- OnDestroy,
- TemplateRef,
- ViewContainerRef,
-} from '@angular/core';
-import { debugLog } from 'core-app/shared/helpers/debug_output';
-
-/**
- * View lookup service for injecting angular templates
- * as fullcalendar event content.
- *
- * Based on the suggestion from Daniel Goldsmith
- * in https://github.com/fullcalendar/fullcalendar-angular/issues/204
- *
- */
-@Injectable()
-export class EventViewLookupService implements OnDestroy {
- /** Active templates currently rendered */
- private readonly activeViews = new Map<string, EmbeddedViewRef<unknown>>();
-
- /** Remember detached views to be destroyed on destroyAll */
- private readonly detachedViews:EmbeddedViewRef<unknown>[] = [];
-
- constructor(private viewContainerRef:ViewContainerRef) {
- }
-
- /**
- * Gets the view for the given ID, or creates one if there isn't one
- * already. The template's context is set (or updated to, if the
- * view has already been created) the given context values.
- * @param template The template ref (get this from a @ViewChild of an
- * <ng-template>)
- * @param id The unique ID for this instance of the view. Use this so that
- * you don't keep around views for the same event.
- * @param context The available variables for the <ng-template>. For
- * example, if it looks like this: <ng-template let-localVar="value"> then
- * your context should be an object with a `value` key.
- */
- getView(
- template:TemplateRef<unknown>, id:string, context:unknown,
- ):EmbeddedViewRef<unknown> {
- let view = this.activeViews.get(id);
- if (view) {
- debugLog('Returning active view %O', id);
- view.detectChanges();
- return view;
- }
-
- // Create a new view and move to active
- debugLog('CREATING new view %O', id);
- view = this.viewContainerRef.createEmbeddedView(template, context);
- this.activeViews.set(id, view);
- view.detectChanges();
-
- return view;
- }
-
- ngOnDestroy():void {
- this.destroyAll();
- }
-
- /**
- * Call this method if all views need to be cleaned up. This will happen
- * when your parent component is destroyed (e.g., in ngOnDestroy),
- * but it may also be needed if you are clearing just the area where the
- * views have been placed.
- */
- public destroyAll():void {
- debugLog('Destroying all views');
-
- Array
- .from(this.activeViews.values())
- .forEach(this.destroyView.bind(this));
-
- debugLog('Destroying %O active views', this.activeViews.size);
- this.activeViews.clear();
-
- this.destroyDetached();
- }
-
- /**
- * Call this method if you want to clean detached views.
- * This is safe to call outside of drag & drop operations.
- *
- */
- public destroyDetached():void {
- debugLog('Destroying %O detached views', this.detachedViews.length);
-
- while (this.detachedViews.length) {
- this.destroyView(this.detachedViews.pop() as EmbeddedViewRef<unknown>);
- }
- }
-
- /**
- * Mark a view to be destroyed.
- * It will only be destroyed once +destroyAll+ is called.
- *
- * Ensure that destroyAll is called when, e.g., refreshing the calendar.
- *
- * @param id View ID
- */
- public markForDestruction(id:string):void {
- const view = this.activeViews.get(id);
- if (!view) {
- return;
- }
-
- debugLog('Marking view %O to be destroyed', id);
- this.activeViews.delete(id);
- this.detachedViews.push(view);
- }
-
- private destroyView(view:EmbeddedViewRef<unknown>) {
- const index = this.viewContainerRef.indexOf(view);
- if (index !== -1) {
- this.viewContainerRef.remove(index);
- }
-
- view.destroy();
- }
-}
diff --git a/frontend/src/app/features/team-planner/team-planner/planner/team-planner.component.ts b/frontend/src/app/features/team-planner/team-planner/planner/team-planner.component.ts
index 108e5ea5cf1..eaa450035e4 100644
--- a/frontend/src/app/features/team-planner/team-planner/planner/team-planner.component.ts
+++ b/frontend/src/app/features/team-planner/team-planner/planner/team-planner.component.ts
@@ -37,18 +37,8 @@ import {
TemplateRef,
ViewChild,
} from '@angular/core';
-import {
- CalendarOptions,
- DateSelectArg,
- EventApi,
- EventDropArg,
- EventInput,
-} from '@fullcalendar/core';
-import {
- BehaviorSubject,
- combineLatest,
- Subject,
-} from 'rxjs';
+import { CalendarOptions, DateSelectArg, EventApi, EventDropArg, EventInput } from '@fullcalendar/core';
+import { BehaviorSubject, combineLatest, Subject } from 'rxjs';
import {
debounceTime,
distinctUntilChanged,
@@ -73,29 +63,31 @@ import interactionPlugin, {
import { FullCalendarComponent } from '@fullcalendar/angular';
import { I18nService } from 'core-app/core/i18n/i18n.service';
import { ConfigurationService } from 'core-app/core/config/configuration.service';
-import { EventViewLookupService } from 'core-app/features/team-planner/team-planner/planner/event-view-lookup.service';
-import { WorkPackageViewFiltersService } from 'core-app/features/work-packages/routing/wp-view-base/view-services/wp-view-filters.service';
+import {
+ WorkPackageViewFiltersService,
+} from 'core-app/features/work-packages/routing/wp-view-base/view-services/wp-view-filters.service';
import { IsolatedQuerySpace } from 'core-app/features/work-packages/directives/query-space/isolated-query-space';
import { CurrentProjectService } from 'core-app/core/current-project/current-project.service';
import { splitViewRoute } from 'core-app/features/work-packages/routing/split-view-routes.helper';
import { QueryFilterInstanceResource } from 'core-app/features/hal/resources/query-filter-instance-resource';
import { PrincipalsResourceService } from 'core-app/core/state/principals/principals.service';
-import {
- ApiV3ListFilter,
- ApiV3ListParameters,
-} from 'core-app/core/apiv3/paths/apiv3-list-resource.interface';
+import { ApiV3ListFilter, ApiV3ListParameters } from 'core-app/core/apiv3/paths/apiv3-list-resource.interface';
import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';
import { HalResource } from 'core-app/features/hal/resources/hal-resource';
import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';
import { OpCalendarService } from 'core-app/features/calendar/op-calendar.service';
-import { HalResourceEditingService } from 'core-app/shared/components/fields/edit/services/hal-resource-editing.service';
+import {
+ HalResourceEditingService,
+} from 'core-app/shared/components/fields/edit/services/hal-resource-editing.service';
import { HalResourceNotificationService } from 'core-app/features/hal/services/hal-resource-notification.service';
import { SchemaCacheService } from 'core-app/core/schemas/schema-cache.service';
import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';
import { CalendarDragDropService } from 'core-app/features/team-planner/team-planner/calendar-drag-drop.service';
import { StatusResource } from 'core-app/features/hal/resources/status-resource';
import { ResourceChangeset } from 'core-app/shared/components/fields/changeset/resource-changeset';
-import { KeepTabService } from 'core-app/features/work-packages/components/wp-single-view-tabs/keep-tab/keep-tab.service';
+import {
+ KeepTabService,
+} from 'core-app/features/work-packages/components/wp-single-view-tabs/keep-tab/keep-tab.service';
import { HalError } from 'core-app/features/hal/services/hal-error';
import { ActionsService } from 'core-app/core/state/actions/actions.service';
import {
@@ -104,10 +96,7 @@ import {
teamPlannerPageRefresh,
} from 'core-app/features/team-planner/team-planner/planner/team-planner.actions';
import { imagePath } from 'core-app/shared/helpers/images/path-helper';
-import {
- skeletonEvents,
- skeletonResources,
-} from './loading-skeleton-data';
+import { skeletonEvents, skeletonResources } from './loading-skeleton-data';
import { CapabilitiesResourceService } from 'core-app/core/state/capabilities/capabilities.service';
import { ICapability } from 'core-app/core/state/capabilities/capability.model';
import { ToastService } from 'core-app/shared/components/toaster/toast.service';
@@ -118,10 +107,7 @@ import { RawOptionsFromRefiners } from '@fullcalendar/core/internal';
import { ViewOptionRefiners } from '@fullcalendar/common';
import { ResourceApi } from '@fullcalendar/resource';
import { DeviceService } from 'core-app/core/browser/device.service';
-import {
- EffectCallback,
- registerEffectCallbacks,
-} from 'core-app/core/state/effects/effect-handler.decorator';
+import { EffectCallback, registerEffectCallbacks } from 'core-app/core/state/effects/effect-handler.decorator';
import {
addBackgroundEvents,
removeBackgroundEvents,
@@ -136,9 +122,6 @@ export type TeamPlannerViewOptions = { [K in TeamPlannerViewOptionKey]:RawOption
templateUrl: './team-planner.component.html',
styleUrls: ['./team-planner.component.sass'],
changeDetection: ChangeDetectionStrategy.OnPush,
- providers: [
- EventViewLookupService,
- ],
})
export class TeamPlannerComponent extends UntilDestroyedMixin implements OnInit, OnDestroy {
@ViewChild(FullCalendarComponent) ucCalendar:FullCalendarComponent;
@@ -377,7 +360,6 @@ export class TeamPlannerComponent extends UntilDestroyedMixin implements OnInit,
private wpTableFilters:WorkPackageViewFiltersService,
private querySpace:IsolatedQuerySpace,
private currentProject:CurrentProjectService,
- private viewLookup:EventViewLookupService,
private I18n:I18nService,
readonly injector:Injector,
readonly calendar:OpCalendarService,
@@ -602,8 +584,6 @@ export class TeamPlannerComponent extends UntilDestroyedMixin implements OnInit,
([workPackages, projectAssignables]) => {
const events = this.mapToCalendarEvents(workPackages.elements, projectAssignables);
- this.viewLookup.destroyDetached();
-
this.removeExternalEvents();
successCallback(events);