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
[#61126] hover card trigger service: Angular -> Stimulus
Tobias Dillmann01cde9923a24
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rbindex c2af4cfee9e..8e24190f902 100644--- a/app/helpers/application_helper.rb+++ b/app/helpers/application_helper.rb@@ -290,7 +290,7 @@ module ApplicationHelperdef body_data_attributes(local_assigns){- controller: "application",+ controller: "application hover-card-trigger",relative_url_root: root_path,overflowing_identifier: ".__overflowing_body",rendered_at: Time.zone.now.iso8601,diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.tsindex c42c3a74cdb..76e5546d833 100644--- a/frontend/src/app/app.module.ts+++ b/frontend/src/app/app.module.ts@@ -53,7 +53,6 @@ import { OpenprojectDashboardsModule } from 'core-app/features/dashboards/openprimport {OpenprojectWorkPackageGraphsModule,} from 'core-app/shared/components/work-package-graphs/openproject-work-package-graphs.module';-import { HoverCardTriggerService } from 'core-app/core/setup/globals/global-listeners/hover-card-trigger.service';import { OpenprojectOverviewModule } from 'core-app/features/overview/openproject-overview.module';import { OpenprojectMyPageModule } from 'core-app/features/my-page/openproject-my-page.module';import { OpenprojectProjectsModule } from 'core-app/features/projects/openproject-projects.module';@@ -239,7 +238,6 @@ import {export function initializeServices(injector:Injector) {return () => {- const PreviewTrigger = injector.get(HoverCardTriggerService);const topMenuService = injector.get(TopMenuService);const keyboardShortcuts = injector.get(KeyboardShortcutService);const contextMenu = injector.get(OPContextMenuService);@@ -249,13 +247,11 @@ export function initializeServices(injector:Injector) {injector.get(RevitAddInSettingsButtonService);topMenuService.register();- PreviewTrigger.setupListener();contextMenu.register();// Re-register on turbo:loaddocument.addEventListener('turbo:load', () => {topMenuService.register();- PreviewTrigger.setupListener();contextMenu.register();currentProject.detect();});diff --git a/frontend/src/app/core/setup/globals/global-listeners/hover-card-trigger.service.ts b/frontend/src/stimulus/controllers/hover-card-trigger.controller.tssimilarity index 81%rename from frontend/src/app/core/setup/globals/global-listeners/hover-card-trigger.service.tsrename to frontend/src/stimulus/controllers/hover-card-trigger.controller.tsindex df92f223014..e0a193bcd93 100644--- a/frontend/src/app/core/setup/globals/global-listeners/hover-card-trigger.service.ts+++ b/frontend/src/stimulus/controllers/hover-card-trigger.controller.ts@@ -1,37 +1,43 @@-//-- copyright-// OpenProject is an open source project management software.-// Copyright (C) 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 { Injectable } from '@angular/core';-import { computePosition, flip, limitShift, shift } from '@floating-ui/dom';+/*+ * -- copyright+ * OpenProject is an open source project management software.+ * Copyright (C) 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 { ApplicationController } from 'stimulus-use';import { sanitizeUrl } from '@braintree/sanitize-url';+import { computePosition, flip, limitShift, shift } from '@floating-ui/dom';-@Injectable({ providedIn: 'root' })-export class HoverCardTriggerService {+/**+ * This controller is responsible for showing a hover card when hovering over a trigger element.+ * You can define a trigger element by adding the class `op-hover-card--preview-trigger` to it.+ * To have hover cards available everywhere, add this controller to the body tag.+ */+export default class HoverCardTriggerController extends ApplicationController {private mouseInModal = false;private hoverTimeout:number|null = null;private closeTimeout:number|null = null;@@ -46,6 +52,16 @@ export class HoverCardTriggerService {// The time you need to keep away from trigger/hover card before an opened card is closedCLOSE_DELAY_IN_MS = 250;+ connect() {+ super.connect();++ this.setupListener();+ }++ disconnect() {+ super.disconnect();+ }+setupListener() {jQuery(document.body).on('mouseover', '.op-hover-card--preview-trigger', (e) => {e.preventDefault();diff --git a/frontend/src/stimulus/setup.ts b/frontend/src/stimulus/setup.tsindex d9ebf658cd0..aa6eb92c058 100644--- a/frontend/src/stimulus/setup.ts+++ b/frontend/src/stimulus/setup.ts@@ -16,6 +16,7 @@ import OpProjectsZenModeController from './controllers/dynamic/projects/zen-modeimport PasswordConfirmationDialogController from './controllers/password-confirmation-dialog.controller';import KeepScrollPositionController from './controllers/keep-scroll-position.controller';import PatternInputController from './controllers/pattern-input.controller';+import HoverCardTriggerController from './controllers/hover-card-trigger.controller';declare global {interface Window {@@ -41,6 +42,7 @@ instance.register('poll-for-changes', PollForChangesController);instance.register('print', PrintController);instance.register('refresh-on-form-changes', RefreshOnFormChangesController);instance.register('form-preview', FormPreviewController);+instance.register('hover-card-trigger', HoverCardTriggerController);instance.register('show-when-checked', OpShowWhenCheckedController);instance.register('show-when-value-selected', OpShowWhenValueSelectedController);instance.register('table-highlighting', TableHighlightingController);