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 loading dialog
Oliver Günther3b09b4fc6bed
diff --git a/frontend/src/stimulus/controllers/async-dialog.controller.ts b/frontend/src/stimulus/controllers/async-dialog.controller.tsnew file mode 100644index 00000000000..86e24904d40--- /dev/null+++ b/frontend/src/stimulus/controllers/async-dialog.controller.ts@@ -0,0 +1,86 @@+/*+ * -- 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 { ApplicationController } from 'stimulus-use';+import { renderStreamMessage } from '@hotwired/turbo';++export default class AsyncDialogController extends ApplicationController {+ private loadingDialog:HTMLDialogElement|null;++ connect() {+ this.element.addEventListener('click', (e) => {+ e.preventDefault();+ this.addLoading();+ this.triggerTurboStream();+ });+ }++ async triggerTurboStream():Promise<void> {+ fetch(this.href, {+ method: this.method,+ headers: {+ Accept: 'text/vnd.turbo-stream.html',+ },+ }).then((r) => r.text())+ .then((html) => renderStreamMessage(html))+ .finally(() => this.removeLoading());+ }++ removeLoading() {+ this.loadingDialog?.remove();+ }++ addLoading() {+ this.removeLoading();+ const dialog = document.createElement('dialog');+ dialog.classList.add('Overlay', 'Overlay--size-medium', 'Overlay--motion-scaleFade');+ dialog.style.height = '150px';+ dialog.style.display = 'grid';+ dialog.style.placeContent = 'center';+ dialog.id = 'loading';+ dialog.innerHTML = `+ <svg style="box-sizing: content-box; color: var(--color-icon-primary);" width="32" height="32" viewBox="0 0 16 16" fill="none" data-view-component="true" class="anim-rotate">+ <circle cx="8" cy="8" r="7" stroke="currentColor" stroke-opacity="0.25" stroke-width="2" vector-effect="non-scaling-stroke" fill="none" />+ <path d="M15 8a7.002 7.002 0 00-7-7" stroke="currentColor" stroke-width="2" stroke-linecap="round" vector-effect="non-scaling-stroke" />+ </svg>+ `;+ document.body.appendChild(dialog);+ dialog.showModal();+ this.loadingDialog = dialog;+ }++ get href() {+ return (this.element as HTMLLinkElement).href;+ }++ get method() {+ return (this.element as HTMLLinkElement).dataset.turboMethod || 'GET';+ }+}diff --git a/frontend/src/stimulus/setup.ts b/frontend/src/stimulus/setup.tsindex bfca0612ba4..48382bd3b44 100644--- a/frontend/src/stimulus/setup.ts+++ b/frontend/src/stimulus/setup.ts@@ -5,6 +5,7 @@ import MainMenuController from './controllers/dynamic/menus/main.controller';import OpDisableWhenCheckedController from './controllers/disable-when-checked.controller';import PrintController from './controllers/print.controller';import RefreshOnFormChangesController from './controllers/refresh-on-form-changes.controller';+import AsyncDialogController from './controllers/async-dialog.controller';declare global {interface Window {@@ -26,3 +27,4 @@ instance.register('menus--main', MainMenuController);instance.register('disable-when-checked', OpDisableWhenCheckedController);instance.register('print', PrintController);instance.register('refresh-on-form-changes', RefreshOnFormChangesController);+instance.register('async-dialog', AsyncDialogController);diff --git a/modules/meeting/app/components/meetings/header_component.html.erb b/modules/meeting/app/components/meetings/header_component.html.erbindex 3aa3628647d..10207832a0c 100644--- a/modules/meeting/app/components/meetings/header_component.html.erb+++ b/modules/meeting/app/components/meetings/header_component.html.erb@@ -47,8 +47,8 @@tag: :a,href: history_meeting_path(@meeting),content_arguments: {+ "data-controller": "async-dialog","data-show-dialog-id": "meetings-history-dialog",- "data-turbo-stream": true},value: "") do |item|