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
[#55024] Project overview headers are showing on work package view, hide it via stimulus.js
Dombi Attilab4979c8a2afc
diff --git a/frontend/src/app/core/routing/openproject.routes.ts b/frontend/src/app/core/routing/openproject.routes.tsindex b72d4b749bb..c52b5783ce4 100644--- a/frontend/src/app/core/routing/openproject.routes.ts+++ b/frontend/src/app/core/routing/openproject.routes.ts@@ -242,6 +242,29 @@ export function initializeUiRouterListeners(injector:Injector) {(transition) => redirectToMobileAlternative(transition),);+ // Fire an event when navigating to a different module. This event then can be detected in+ // the non-angular parts of the application. A usecase for this can be found in the+ // overview-header.controllers.ts+ // See https://community.openproject.org/wp/55024 for details.+ $transitions.onBefore(+ {},+ (transition:Transition) => {+ const fromState = transition.from();+ const toState = transition.to();+ if (+ !!fromState.name+ && !!toState.name+ && fromState.name?.split('.')[0] !== toState.name?.split('.')[0]+ ) {+ window.dispatchEvent(new CustomEvent('angular:router:module-changed', {+ detail: toState.name?.split('.')[0],+ }));+ }++ return true;+ },+ );+// Apply classes from bodyClasses in each state definition// This was defined as onEnter, onExit functions in each state before// but since AOT doesn't allow anonymous functions, we can't re-use them now.diff --git a/frontend/src/stimulus/controllers/dynamic/overview-header.controller.ts b/frontend/src/stimulus/controllers/dynamic/overview-header.controller.tsnew file mode 100644index 00000000000..bfe845600c1--- /dev/null+++ b/frontend/src/stimulus/controllers/dynamic/overview-header.controller.ts@@ -0,0 +1,52 @@+/*+ * -- copyright+ * OpenProject is an open source project management software.+ * Copyright (C) 2023 the OpenProject GmbH+ *+ * This program is free software; you can redistribute it and/or+ * modify it under the terms of the GNU General Public License version 3.+ *+ * OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+ * Copyright (C) 2006-2013 Jean-Philippe Lang+ * Copyright (C) 2010-2013 the ChiliProject Team+ *+ * This program is free software; you can redistribute it and/or+ * modify it under the terms of the GNU General Public License+ * as published by the Free Software Foundation; either version 2+ * of the License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU General Public License for more details.+ *+ * You should have received a copy of the GNU General Public License+ * along with this program; if not, write to the Free Software+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+ *+ * See COPYRIGHT and LICENSE files for more details.+ * +++ */++import { Controller } from '@hotwired/stimulus';++export default class OverviewHeaderController extends Controller {+ connect() {+ window.addEventListener('angular:router:module-changed', this.toggleHeaderVisibility);+ }++ disconnect() {+ window.removeEventListener('angular:router:module-changed', this.toggleHeaderVisibility);+ }++ toggleHeaderVisibility = (event:CustomEvent) => {+ const name = event.detail as string;+ const element = this.element as HTMLElement;++ if (name === 'overview') {+ element.classList.remove('d-none');+ } else {+ element.classList.add('d-none');+ }+ };+}diff --git a/modules/overviews/app/views/overviews/overviews/show.html.erb b/modules/overviews/app/views/overviews/overviews/show.html.erbindex f79c9c3de55..bd1d6114ccb 100644--- a/modules/overviews/app/views/overviews/overviews/show.html.erb+++ b/modules/overviews/app/views/overviews/overviews/show.html.erb@@ -3,7 +3,13 @@<% end -%><%=- render(Primer::OpenProject::PageHeader.new(data: { turbo: true })) do |header|+ render(Primer::OpenProject::PageHeader.new(+ data: {+ 'controller': 'overview-header',+ 'application-target': 'dynamic',+ turbo: true+ }+ )) do |header|header.with_title(variant: :medium) { t("overviews.label") }header.with_breadcrumbs([