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
Add subcomponent for the team planner sidemenu to take care of the create button specificities
Henriette Darge2d9bfb21d82f
diff --git a/config/locales/js-en.yml b/config/locales/js-en.ymlindex 2c7fa8998a8..d8ea90acd58 100644--- a/config/locales/js-en.yml+++ b/config/locales/js-en.yml@@ -497,7 +497,6 @@ en:label_starred_queries: "Favorite views"label_global_queries: "Public views"label_custom_queries: "Private views"- label_create_new_query: "Create new"label_columns: "Columns"label_attachments: Fileslabel_drop_files: Drop files herediff --git a/frontend/src/app/core/setup/global-dynamic-components.const.ts b/frontend/src/app/core/setup/global-dynamic-components.const.tsindex 123329403d7..4820c250ffb 100644--- a/frontend/src/app/core/setup/global-dynamic-components.const.ts+++ b/frontend/src/app/core/setup/global-dynamic-components.const.ts@@ -187,6 +187,10 @@ import {IanMenuComponent,ianMenuSelector,} from 'core-app/features/in-app-notifications/center/menu/menu.component';+import {+ opTeamPlannerSidemenuSelector,+ TeamPlannerSidemenuComponent,+} from 'core-app/features/team-planner/team-planner/sidemenu/team-planner-sidemenu.component';export const globalDynamicComponents:OptionalBootstrapDefinition[] = [{ selector: appBaseSelector, cls: ApplicationBaseComponent },@@ -229,6 +233,7 @@ export const globalDynamicComponents:OptionalBootstrapDefinition[] = [{ selector: remoteFieldUpdaterSelector, cls: RemoteFieldUpdaterComponent },{ selector: wpOverviewGraphSelector, cls: WorkPackageOverviewGraphComponent },{ selector: opViewSelectSelector, cls: ViewSelectComponent },+ { selector: opTeamPlannerSidemenuSelector, cls: TeamPlannerSidemenuComponent },{ selector: triggerActionsEntryComponentSelector, cls: TriggerActionsEntryComponent, embeddable: true },{ selector: backlogsPageComponentSelector, cls: BacklogsPageComponent },{ selector: attributeValueMacro, cls: AttributeValueMacroComponent, embeddable: true },diff --git a/frontend/src/app/features/team-planner/team-planner/sidemenu/team-planner-sidemenu.component.html b/frontend/src/app/features/team-planner/team-planner/sidemenu/team-planner-sidemenu.component.htmlnew file mode 100644index 00000000000..2475b5238b7--- /dev/null+++ b/frontend/src/app/features/team-planner/team-planner/sidemenu/team-planner-sidemenu.component.html@@ -0,0 +1,16 @@+<op-view-select+ [projectId]="projectId"+ [menuItems]="menuItems"+ baseRoute="team_planner.page.show"+ viewType="TeamPlanner"+>+</op-view-select>++<button+ *ngIf="(canAddTeamPlanner$ | async)"+ class="spot-button spot-button_outlined"+ [uiSref]="createButton.uiSref"+ [uiParams]="createButton.uiParams"+>+ {{createButton.title}}+</button>diff --git a/frontend/src/app/features/team-planner/team-planner/sidemenu/team-planner-sidemenu.component.ts b/frontend/src/app/features/team-planner/team-planner/sidemenu/team-planner-sidemenu.component.tsnew file mode 100644index 00000000000..db78b7a6225--- /dev/null+++ b/frontend/src/app/features/team-planner/team-planner/sidemenu/team-planner-sidemenu.component.ts@@ -0,0 +1,53 @@+import {+ Component,+ ChangeDetectionStrategy,+ Input,+ ElementRef,+} from '@angular/core';+import { DatasetInputs } from 'core-app/shared/components/dataset-inputs.decorator';+import { CurrentUserService } from 'core-app/core/current-user/current-user.service';+import { CurrentProjectService } from 'core-app/core/current-project/current-project.service';+import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';+import { I18nService } from 'core-app/core/i18n/i18n.service';++export const opTeamPlannerSidemenuSelector = 'op-team-planner-sidemenu';++@DatasetInputs+@Component({+ selector: opTeamPlannerSidemenuSelector,+ templateUrl: './team-planner-sidemenu.component.html',+ changeDetection: ChangeDetectionStrategy.OnPush,+})+export class TeamPlannerSidemenuComponent extends UntilDestroyedMixin {+ @Input() menuItems:string[] = [];++ @Input() projectId:string|undefined;++ canAddTeamPlanner$ = this.currentUserService.hasCapabilities$(+ 'team_planners/create',+ this.currentProjectService.id || undefined,+ )+ .pipe(this.untilDestroyed());++ text = {+ create_new_team_planner: this.I18n.t('js.team_planner.create_new'),+ };++ createButton = {+ title: this.text.create_new_team_planner,+ uiSref: 'team_planner.page.show',+ uiParams: {+ query_id: null,+ query_props: '',+ },+ };++ constructor(+ readonly elementRef:ElementRef,+ readonly currentUserService:CurrentUserService,+ readonly currentProjectService:CurrentProjectService,+ readonly I18n:I18nService,+ ) {+ super();+ }+}diff --git a/frontend/src/app/features/team-planner/team-planner/team-planner.module.ts b/frontend/src/app/features/team-planner/team-planner/team-planner.module.tsindex e33ac17a176..a1734e8ceaf 100644--- a/frontend/src/app/features/team-planner/team-planner/team-planner.module.ts+++ b/frontend/src/app/features/team-planner/team-planner/team-planner.module.ts@@ -14,6 +14,7 @@ import { TeamPlannerPageComponent } from 'core-app/features/team-planner/team-plimport { OPSharedModule } from 'core-app/shared/shared.module';import { AddExistingPaneComponent } from './add-work-packages/add-existing-pane.component';import { OpenprojectContentLoaderModule } from 'core-app/shared/components/op-content-loader/openproject-content-loader.module';+import { TeamPlannerSidemenuComponent } from 'core-app/features/team-planner/team-planner/sidemenu/team-planner-sidemenu.component';@NgModule({declarations: [@@ -21,6 +22,7 @@ import { OpenprojectContentLoaderModule } from 'core-app/shared/components/op-coTeamPlannerPageComponent,AddAssigneeComponent,AddExistingPaneComponent,+ TeamPlannerSidemenuComponent],imports: [OPSharedModule,diff --git a/frontend/src/app/shared/components/op-view-select/op-static-queries.service.ts b/frontend/src/app/shared/components/op-view-select/op-static-queries.service.tsindex a2fdd1a6496..d025b50cf33 100644--- a/frontend/src/app/shared/components/op-view-select/op-static-queries.service.ts+++ b/frontend/src/app/shared/components/op-view-select/op-static-queries.service.ts@@ -66,7 +66,6 @@ export class StaticQueriesService {recently_created: this.I18n.t('js.work_packages.default_queries.recently_created'),all_open: this.I18n.t('js.work_packages.default_queries.all_open'),summary: this.I18n.t('js.work_packages.default_queries.summary'),- create_new_team_planner: this.I18n.t('js.team_planner.create_new'),};public getStaticName(query:QueryResource):string {@@ -184,23 +183,6 @@ export class StaticQueriesService {.filter((query) => query.view === view);}- public getCreateNewQueryForView(view:ViewType):IOpSidemenuItem[] {- return this.buildCreateNewQuery()- .filter((query) => query.view === view);- }-- private buildCreateNewQuery():IStaticQuery[] {- return [{- title: this.text.create_new_team_planner,- uiSref: 'team_planner.page.show',- uiParams: {- query_id: null,- query_props: '',- },- view: 'TeamPlanner',- }];- }-private projectDependentQueries(projectIdentifier:string):IStaticQuery[] {return [{diff --git a/frontend/src/app/shared/components/op-view-select/op-view-select.component.ts b/frontend/src/app/shared/components/op-view-select/op-view-select.component.tsindex 6d24a2c3fa3..d2e144ed0b3 100644--- a/frontend/src/app/shared/components/op-view-select/op-view-select.component.ts+++ b/frontend/src/app/shared/components/op-view-select/op-view-select.component.ts@@ -52,8 +52,6 @@ import { ViewsResourceService } from 'core-app/core/state/views/views.service';import { IView } from 'core-app/core/state/views/view.model';import idFromLink from 'core-app/features/hal/helpers/id-from-link';import { ApiV3ListParameters } from 'core-app/core/apiv3/paths/apiv3-list-resource.interface';-import { CurrentUserService } from 'core-app/core/current-user/current-user.service';-import { CurrentProjectService } from 'core-app/core/current-project/current-project.service';export type ViewType = 'WorkPackagesTable'|'Bim'|'TeamPlanner'|'WorkPackagesCalendar';@@ -104,8 +102,6 @@ export class ViewSelectComponent extends UntilDestroyedMixin implements OnInit {readonly mainMenuService:MainMenuNavigationService,readonly cdRef:ChangeDetectorRef,readonly viewsService:ViewsResourceService,- readonly currentUserService:CurrentUserService,- readonly currentProjectService:CurrentProjectService,) {super();}@@ -187,15 +183,9 @@ export class ViewSelectComponent extends UntilDestroyedMixin implements OnInit {);}- combineLatest(- this.viewsService.fetchViews(params),- this.currentUserService.hasCapabilities$(- 'team_planners/create',- this.currentProjectService.id || undefined,- ),- )+ this.viewsService.fetchViews(params).pipe(this.untilDestroyed())- .subscribe(([queryCollection, canAddTeamPlanners]) => {+ .subscribe((queryCollection) => {queryCollection._embedded.elements@@ -213,7 +203,6 @@ export class ViewSelectComponent extends UntilDestroyedMixin implements OnInit {});const staticQueries = this.opStaticQueries.getStaticQueriesForView(this.viewType);- const newQueryLink = this.opStaticQueries.getCreateNewQueryForView(this.viewType);const viewCategories = [{ title: this.text.scope_starred, children: categories.starred, collapsible: true },{ title: this.text.scope_default, children: staticQueries, collapsible: true },@@ -221,9 +210,6 @@ export class ViewSelectComponent extends UntilDestroyedMixin implements OnInit {{ title: this.text.scope_private, children: categories.private, collapsible: true },];- if (canAddTeamPlanners) {- viewCategories.push({ title: this.text.scope_new, children: newQueryLink, collapsible: true });- }this.viewCategories$.next(viewCategories);});}diff --git a/frontend/src/app/shared/shared.module.ts b/frontend/src/app/shared/shared.module.tsindex e0dfcf97cba..e1942dfe78d 100644--- a/frontend/src/app/shared/shared.module.ts+++ b/frontend/src/app/shared/shared.module.ts@@ -198,6 +198,8 @@ export function bootstrapModule(injector:Injector) {OpSidemenuComponent,OpProjectIncludeComponent,OpProjectListComponent,++ ViewSelectComponent,],providers: [StaticQueriesService,diff --git a/modules/team_planner/app/views/team_planner/team_planner/_menu.html.erb b/modules/team_planner/app/views/team_planner/team_planner/_menu.html.erbindex 2c6f148d10b..fed603f4a41 100644--- a/modules/team_planner/app/views/team_planner/team_planner/_menu.html.erb+++ b/modules/team_planner/app/views/team_planner/team_planner/_menu.html.erb@@ -1,9 +1,7 @@<%=- angular_component_tag 'op-view-select',+ angular_component_tag 'op-team-planner-sidemenu',inputs: {projectId: (@project ? @project.id.to_s : ''),menuItems: [parent_name, name],- baseRoute: 'team_planner.page.show',- viewType: 'TeamPlanner',}%>