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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Provide different configuration services depending on the module to show/hide the "Gantt" option in the configuration modal of the WP module
Henriette Darge1604c698f568
diff --git a/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/wp-table-configuration.modal.ts b/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/wp-table-configuration.modal.tsindex 73622309730..077d8c52525 100644--- a/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/wp-table-configuration.modal.ts+++ b/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/wp-table-configuration.modal.ts@@ -34,6 +34,7 @@ import { WorkPackageNotificationService } from 'core-app/features/work-packages/import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';import { QueryFormResource } from 'core-app/features/hal/resources/query-form-resource';import { QueryResource } from 'core-app/features/hal/resources/query-resource';+import { WpTableWithGanttConfigurationService } from 'core-app/features/work-packages/components/wp-table/configuration-modal/wp-table-with-gantt-configuration.service';export const WpTableConfigurationModalPrependToken = new InjectionToken<ComponentType<any>>('WpTableConfigurationModalPrependComponent');@@ -66,10 +67,13 @@ export class WpTableConfigurationModalComponent extends OpModalComponent implemepublic tabPortalHost:TabPortalOutlet;// Try to load an optional provided configuration service, and fall back to the default one- private wpTableConfigurationService:WpTableConfigurationService =- this.injector.get(WpTableConfigurationService, new WpTableConfigurationService(this.I18n));+ private wpTableConfigurationService:WpTableConfigurationService = this.injector.get(+ WpTableConfigurationService,+ new WpTableWithGanttConfigurationService(this.I18n),+ );- constructor(@Inject(OpModalLocalsToken) public locals:OpModalLocalsMap,+ constructor(+ @Inject(OpModalLocalsToken) public locals:OpModalLocalsMap,@Optional() @Inject(WpTableConfigurationModalPrependToken) public prependModalComponent:ComponentType<any>|null,readonly I18n:I18nService,readonly injector:Injector,@@ -83,7 +87,8 @@ export class WpTableConfigurationModalComponent extends OpModalComponent implemereadonly wpTableColumns:WorkPackageViewColumnsService,readonly cdRef:ChangeDetectorRef,readonly ConfigurationService:ConfigurationService,- readonly elementRef:ElementRef) {+ readonly elementRef:ElementRef,+ ) {super(locals, cdRef, elementRef);}diff --git a/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/wp-table-configuration.service.provider.ts b/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/wp-table-configuration.service.provider.tsnew file mode 100644index 00000000000..dc3d9bd5d5f--- /dev/null+++ b/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/wp-table-configuration.service.provider.ts@@ -0,0 +1,14 @@+import { I18nService } from 'core-app/core/i18n/i18n.service';+import { StateService } from '@uirouter/angular';+import { WpTableConfigurationService } from 'core-app/features/work-packages/components/wp-table/configuration-modal/wp-table-configuration.service';+import { WpTableWithGanttConfigurationService } from 'core-app/features/work-packages/components/wp-table/configuration-modal/wp-table-with-gantt-configuration.service';++export const WorkPackageTableConfigurationFactory = (i18n:I18nService, $state:StateService) => {+ // in the WP module we want the default table configuration options+ if ($state.current.name?.includes('work-packages')) {+ return new WpTableConfigurationService(i18n);+ }++ // In all others we want the Gantt option as well+ return new WpTableWithGanttConfigurationService(i18n);+};diff --git a/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/wp-table-configuration.service.ts b/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/wp-table-configuration.service.tsindex 8f8be966f24..4c13e52f772 100644--- a/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/wp-table-configuration.service.ts+++ b/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/wp-table-configuration.service.ts@@ -5,7 +5,6 @@ import { TabInterface } from 'core-app/features/work-packages/components/wp-tablimport { WpTableConfigurationColumnsTabComponent } from 'core-app/features/work-packages/components/wp-table/configuration-modal/tabs/columns-tab.component';import { WpTableConfigurationFiltersTab } from 'core-app/features/work-packages/components/wp-table/configuration-modal/tabs/filters-tab.component';import { WpTableConfigurationSortByTabComponent } from 'core-app/features/work-packages/components/wp-table/configuration-modal/tabs/sort-by-tab.component';-import { WpTableConfigurationTimelinesTabComponent } from 'core-app/features/work-packages/components/wp-table/configuration-modal/tabs/timelines-tab.component';import { WpTableConfigurationHighlightingTabComponent } from 'core-app/features/work-packages/components/wp-table/configuration-modal/tabs/highlighting-tab.component';import { OpBaselineComponent } from 'core-app/features/work-packages/components/wp-baseline/baseline/baseline.component';@@ -42,11 +41,6 @@ export class WpTableConfigurationService {name: this.I18n.t('js.work_packages.table_configuration.highlighting'),componentClass: WpTableConfigurationHighlightingTabComponent,},- {- id: 'timelines',- name: this.I18n.t('js.gantt_chart.label'),- componentClass: WpTableConfigurationTimelinesTabComponent,- },];constructor(readonly I18n:I18nService) {diff --git a/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/wp-table-with-gantt-configuration.service.ts b/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/wp-table-with-gantt-configuration.service.tsnew file mode 100644index 00000000000..8fce694a805--- /dev/null+++ b/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/wp-table-with-gantt-configuration.service.ts@@ -0,0 +1,15 @@+import { Injectable } from '@angular/core';+import { TabInterface } from 'core-app/features/work-packages/components/wp-table/configuration-modal/tab-portal-outlet';+import { WpTableConfigurationTimelinesTabComponent } from 'core-app/features/work-packages/components/wp-table/configuration-modal/tabs/timelines-tab.component';+import { WpTableConfigurationService } from 'core-app/features/work-packages/components/wp-table/configuration-modal/wp-table-configuration.service';++@Injectable()+export class WpTableWithGanttConfigurationService extends WpTableConfigurationService {+ protected _tabs:TabInterface[] = super.tabs.concat([+ {+ id: 'timelines',+ name: this.I18n.t('js.gantt_chart.label'),+ componentClass: WpTableConfigurationTimelinesTabComponent,+ },+ ]);+}diff --git a/frontend/src/app/features/work-packages/components/wp-table/external-configuration/restricted-wp-table-configuration.service.ts b/frontend/src/app/features/work-packages/components/wp-table/external-configuration/restricted-wp-table-configuration.service.tsindex 788576f6da4..4820bc0c4aa 100644--- a/frontend/src/app/features/work-packages/components/wp-table/external-configuration/restricted-wp-table-configuration.service.ts+++ b/frontend/src/app/features/work-packages/components/wp-table/external-configuration/restricted-wp-table-configuration.service.ts@@ -4,11 +4,14 @@ import { TabInterface } from 'core-app/features/work-packages/components/wp-tablimport { WpTableConfigurationService } from 'core-app/features/work-packages/components/wp-table/configuration-modal/wp-table-configuration.service';import { QueryConfigurationLocals } from 'core-app/features/work-packages/components/wp-table/external-configuration/external-query-configuration.component';import { OpQueryConfigurationLocalsToken } from 'core-app/features/work-packages/components/wp-table/external-configuration/external-query-configuration.constants';+import { WpTableWithGanttConfigurationService } from 'core-app/features/work-packages/components/wp-table/configuration-modal/wp-table-with-gantt-configuration.service';@Injectable()-export class RestrictedWpTableConfigurationService extends WpTableConfigurationService {- constructor(@Inject(OpQueryConfigurationLocalsToken) readonly locals:QueryConfigurationLocals,- readonly I18n:I18nService) {+export class RestrictedWpTableConfigurationService extends WpTableWithGanttConfigurationService {+ constructor(+ @Inject(OpQueryConfigurationLocalsToken) readonly locals:QueryConfigurationLocals,+ readonly I18n:I18nService,+ ) {super(I18n);}diff --git a/frontend/src/app/features/work-packages/routing/wp-view-page/wp-view-page.component.ts b/frontend/src/app/features/work-packages/routing/wp-view-page/wp-view-page.component.tsindex f24f68304d4..78db9d9aa51 100644--- a/frontend/src/app/features/work-packages/routing/wp-view-page/wp-view-page.component.ts+++ b/frontend/src/app/features/work-packages/routing/wp-view-page/wp-view-page.component.ts@@ -45,6 +45,10 @@ import { of } from 'rxjs';import { WorkPackageFoldToggleButtonComponent } from 'core-app/features/work-packages/components/wp-buttons/wp-fold-toggle-button/wp-fold-toggle-button.component';import { OpProjectIncludeComponent } from 'core-app/shared/components/project-include/project-include.component';import { OpBaselineModalComponent } from 'core-app/features/work-packages/components/wp-baseline/baseline-modal/baseline-modal.component';+import { WorkPackageTableConfigurationFactory } from 'core-app/features/work-packages/components/wp-table/configuration-modal/wp-table-configuration.service.provider';+import { StateService } from '@uirouter/core';+import { I18nService } from 'core-app/core/i18n/i18n.service';+import { WpTableConfigurationService } from 'core-app/features/work-packages/components/wp-table/configuration-modal/wp-table-configuration.service';@Component({selector: 'wp-view-page',@@ -57,6 +61,7 @@ import { OpBaselineModalComponent } from 'core-app/features/work-packages/componproviders: [/** We need to provide the wpNotification service here to get correct save notifications for WP resources */{ provide: HalResourceNotificationService, useClass: WorkPackageNotificationService },+ { provide: WpTableConfigurationService, useFactory: WorkPackageTableConfigurationFactory, deps: [I18nService, StateService] },QueryParamListenerService,],})