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
Reload the sidemenu when a query is updated, created or deleted
Henriette Darge0b1bd23a9774
diff --git a/frontend/src/app/features/work-packages/components/wp-list/wp-list.service.ts b/frontend/src/app/features/work-packages/components/wp-list/wp-list.service.tsindex 1a109fb4bcb..040fdbfec02 100644--- a/frontend/src/app/features/work-packages/components/wp-list/wp-list.service.ts+++ b/frontend/src/app/features/work-packages/components/wp-list/wp-list.service.ts@@ -52,6 +52,7 @@ import { QueryFormResource } from 'core-app/features/hal/resources/query-form-reimport { WorkPackageStatesInitializationService } from './wp-states-initialization.service';import { WorkPackagesListInvalidQueryService } from './wp-list-invalid-query.service';import { WorkPackagesQueryViewService } from 'core-app/features/work-packages/components/wp-list/wp-query-view.service';+import { TurboElement } from 'core-typings/turbo';export interface QueryDefinition {queryParams:{ query_id?:string|null, query_props?:string|null };@@ -255,6 +256,7 @@ export class WorkPackagesListService {// Reload the query, and then reload the menuthis.reloadQuery(createdQuery).subscribe(() => {this.states.changes.queries.next(createdQuery.id);+ this.reloadSidemenu(createdQuery.id);});return createdQuery;@@ -280,14 +282,21 @@ export class WorkPackagesListService {.then(() => {this.toastService.addSuccess(this.I18n.t('js.notice_successful_delete'));- let id;- if (query.project) {- id = query.project.href!.split('/').pop();- }+ if (this.$state.$current.data.hardReloadOnBaseRoute) {+ const url = new URL(window.location.href);+ url.search = '';+ window.location.href = url.href;+ } else {+ let projectId;+ if (query.project) {+ projectId = query.project.href!.split('/').pop();+ }- this.loadDefaultQuery(id);+ void this.loadDefaultQuery(projectId);- this.states.changes.queries.next(query.id!);+ this.states.changes.queries.next(query.id!);+ this.reloadSidemenu(null);+ }});return promise;@@ -311,6 +320,7 @@ export class WorkPackagesListService {this.$state.go('.', { query_id: query!.id, query_props: null }, { reload: true });this.states.changes.queries.next(query!.id!);+ this.reloadSidemenu(query.id);}).catch((error:ErrorResource) => {this.toastService.addError(error.message);@@ -338,6 +348,7 @@ export class WorkPackagesListService {this.toastService.addSuccess(this.I18n.t('js.notice_successful_update'));this.states.changes.queries.next(query.id!);+ this.reloadSidemenu(query.id);});return promise;@@ -423,4 +434,24 @@ export class WorkPackagesListService {)),);}++ private reloadSidemenu(selectedQueryId:string|null):void {+ const menuIdentifier:string|undefined = this.$state.current.data.sidemenuId;++ if (menuIdentifier) {+ const menu = (document.getElementById(menuIdentifier) as HTMLElement&TurboElement);+ const currentSrc = menu.getAttribute('src');++ if (currentSrc && menu) {+ const frameUrl = new URL(currentSrc);++ // Override the frame src to enforce a reload+ if (selectedQueryId) {+ frameUrl.search = `?query_id=${selectedQueryId}`;+ }++ menu.setAttribute('src', frameUrl.href);+ }+ }+ }}diff --git a/frontend/src/app/features/work-packages/routing/work-packages-gantt-routes.ts b/frontend/src/app/features/work-packages/routing/work-packages-gantt-routes.tsindex aef995ba07a..dfb76626e10 100644--- a/frontend/src/app/features/work-packages/routing/work-packages-gantt-routes.ts+++ b/frontend/src/app/features/work-packages/routing/work-packages-gantt-routes.ts@@ -35,6 +35,8 @@ import { makeSplitViewRoutes } from 'core-app/features/work-packages/routing/splexport const menuItemClass = 'gantt-menu-item';+export const sidemenuId = 'gantt_menu';+export const WORK_PACKAGES_GANTT_ROUTES:Ng2StateDeclaration[] = [{name: 'gantt',@@ -47,6 +49,8 @@ export const WORK_PACKAGES_GANTT_ROUTES:Ng2StateDeclaration[] = [data: {bodyClasses: 'router--work-packages-base',menuItem: menuItemClass,+ sidemenuId,+ hardReloadOnBaseRoute: true,},params: {query_id: { type: 'query', dynamic: true },@@ -64,6 +68,8 @@ export const WORK_PACKAGES_GANTT_ROUTES:Ng2StateDeclaration[] = [data: {// This has to be empty to avoid inheriting the parent bodyClassesbodyClasses: '',+ sidemenuId,+ hardReloadOnBaseRoute: true,},},{@@ -77,6 +83,8 @@ export const WORK_PACKAGES_GANTT_ROUTES:Ng2StateDeclaration[] = [bodyClasses: 'router--work-packages-partitioned-split-view',menuItem: menuItemClass,partition: '-left-only',+ sidemenuId,+ hardReloadOnBaseRoute: true,},},...makeSplitViewRoutes(diff --git a/modules/gantt/spec/features/timeline/timeline_navigation_spec.rb b/modules/gantt/spec/features/timeline/timeline_navigation_spec.rbindex 2e9f39f2f17..ebe7c02edaf 100644--- a/modules/gantt/spec/features/timeline/timeline_navigation_spec.rb+++ b/modules/gantt/spec/features/timeline/timeline_navigation_spec.rb@@ -132,7 +132,7 @@ RSpec.describe 'Work package timeline navigation',find('#main-menu-gantt-wrapper .main-menu-toggler').click# Select first query again- query_menu.select query_tl+ query_menu.click_item query_tl.namewp_timeline.expect_timeline!(open: true)wp_timeline.expect_work_package_listed work_package2diff --git a/spec/support/components/work_packages/query_menu.rb b/spec/support/components/work_packages/query_menu.rbindex 6adfd25f692..417bcc85e62 100644--- a/spec/support/components/work_packages/query_menu.rb+++ b/spec/support/components/work_packages/query_menu.rb@@ -58,6 +58,10 @@ module Components'#query-title-filter'end+ def click_item(name)+ page.find(autocompleter_item_selector, text: name).click+ end+def expect_menu_entry(name)expect(page).to have_selector(autocompleter_item_selector, text: name)end