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
Replace confirm-form-submit component with dialog
Oliver Günther412dd8e780b9
diff --git a/app/helpers/confirmation_dialog_helper.rb b/app/helpers/confirmation_dialog_helper.rbindex 9b2e7ce5ada..b3733b89fc5 100644--- a/app/helpers/confirmation_dialog_helper.rb+++ b/app/helpers/confirmation_dialog_helper.rb@@ -30,7 +30,7 @@ module ConfirmationDialogHelper### Show an angular modal confirmation dialog using the augmented# ConfirmationDialogService- def augmented_confirmation_dialog(title:, text:, danger_zone: false, button_continue: nil, button_cancel: nil)+ def augmented_confirmation_dialog(title: nil, text: nil, danger_zone: false, button_continue: nil, button_cancel: nil){'augmented-confirm-dialog': {text: {diff --git a/app/views/enterprises/_current.html.erb b/app/views/enterprises/_current.html.erbindex 34f3e7693f9..dd8f34b4590 100644--- a/app/views/enterprises/_current.html.erb+++ b/app/views/enterprises/_current.html.erb@@ -11,8 +11,10 @@></enterprise-active-saved-trial>-<%= form_tag(enterprise_path, method: :delete) do %>- <confirm-form-submit></confirm-form-submit>+<%= form_tag(enterprise_path,+ method: :delete,+ data: augmented_confirmation_dialog+ ) do %><%= styled_button_tag t(:button_delete),method: :delete,class: '-with-icon icon-delete' %>diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.tsindex 0a8dc9f3d32..7611f0443bc 100644--- a/frontend/src/app/app.module.ts+++ b/frontend/src/app/app.module.ts@@ -70,7 +70,6 @@ import { ConfirmDialogModalComponent } from 'core-app/shared/components/modals/cimport { DynamicContentModalComponent } from 'core-app/shared/components/modals/modal-wrapper/dynamic-content.modal';import { PasswordConfirmationModalComponent } from 'core-app/shared/components/modals/request-for-confirmation/password-confirmation.modal';import { WpPreviewModalComponent } from 'core-app/shared/components/modals/preview-modal/wp-preview-modal/wp-preview.modal';-import { ConfirmFormSubmitController } from 'core-app/shared/components/modals/confirm-form-submit/confirm-form-submit.directive';import { OpHeaderProjectSelectComponent } from 'core-app/shared/components/header-project-select/header-project-select.component';import { OpHeaderProjectSelectListComponent } from 'core-app/shared/components/header-project-select/list/header-project-select-list.component';@@ -222,7 +221,6 @@ export function initializeServices(injector:Injector) {// Form configurationOpDragScrollDirective,- ConfirmFormSubmitController,],})export class OpenProjectModule {diff --git a/frontend/src/app/core/setup/global-dynamic-components.const.ts b/frontend/src/app/core/setup/global-dynamic-components.const.tsindex 315237de1a0..b18637a4f18 100644--- a/frontend/src/app/core/setup/global-dynamic-components.const.ts+++ b/frontend/src/app/core/setup/global-dynamic-components.const.ts@@ -171,10 +171,6 @@ import {homescreenNewFeaturesBlockSelector,} from 'core-app/features/homescreen/blocks/new-features.component';import { MainMenuToggleComponent, mainMenuToggleSelector } from 'core-app/core/main-menu/main-menu-toggle.component';-import {- ConfirmFormSubmitController,- confirmFormSubmitSelector,-} from 'core-app/shared/components/modals/confirm-form-submit/confirm-form-submit.directive';import {MainMenuResizerComponent,mainMenuResizerSelector,@@ -232,7 +228,6 @@ export const globalDynamicComponents:OptionalBootstrapDefinition[] = [{ selector: contentTabsSelector, cls: ContentTabsComponent },{ selector: globalSearchTitleSelector, cls: GlobalSearchTitleComponent },{ selector: copyToClipboardSelector, cls: CopyToClipboardDirective },- { selector: confirmFormSubmitSelector, cls: ConfirmFormSubmitController },{ selector: mainMenuResizerSelector, cls: MainMenuResizerComponent },{ selector: mainMenuToggleSelector, cls: MainMenuToggleComponent },{ selector: globalSearchSelector, cls: GlobalSearchInputComponent },diff --git a/frontend/src/app/shared/components/modals/confirm-dialog/confirm-dialog.modal.html b/frontend/src/app/shared/components/modals/confirm-dialog/confirm-dialog.modal.htmlindex 5178df77c05..cfd0dd04eb6 100644--- a/frontend/src/app/shared/components/modals/confirm-dialog/confirm-dialog.modal.html+++ b/frontend/src/app/shared/components/modals/confirm-dialog/confirm-dialog.modal.html@@ -22,6 +22,7 @@<div class="spot-modal--footer spot-action-bar"><div class="spot-action-bar--right"><button+ type="button"class="button button_no-margin spot-action-bar--action"data-qa-selector="confirmation-modal--cancel"(click)="closeMe($event)"@@ -39,6 +40,7 @@>{{text.button_cancel}}</span></button><button+ type="button"class="button button_no-margin spot-action-bar--action"data-qa-selector="confirmation-modal--confirmed"[ngClass]="dangerHighlighting ? '-danger': '-highlight'"diff --git a/frontend/src/app/shared/components/modals/confirm-form-submit/confirm-form-submit.directive.ts b/frontend/src/app/shared/components/modals/confirm-form-submit/confirm-form-submit.directive.tsdeleted file mode 100644index c04d560b010..00000000000--- a/frontend/src/app/shared/components/modals/confirm-form-submit/confirm-form-submit.directive.ts+++ /dev/null@@ -1,89 +0,0 @@-// -- copyright-// OpenProject is an open source project management software.-// Copyright (C) 2012-2022 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 { I18nService } from 'core-app/core/i18n/i18n.service';-import { Component, ElementRef, OnInit } from '@angular/core';-import { ConfirmDialogService } from '../confirm-dialog/confirm-dialog.service';--export const confirmFormSubmitSelector = 'confirm-form-submit';--@Component({- template: '',- selector: confirmFormSubmitSelector,-})-export class ConfirmFormSubmitController implements OnInit {- // Allow original form submission after dialog was closed- public confirmed = false;-- public text = {- title: this.I18n.t('js.modals.form_submit.title'),- text: this.I18n.t('js.modals.form_submit.text'),- };-- private $element:JQuery<HTMLElement>;-- private $form:JQuery<HTMLElement>;-- constructor(readonly element:ElementRef,- readonly confirmDialog:ConfirmDialogService,- readonly I18n:I18nService) {- }-- ngOnInit() {- this.$element = jQuery<HTMLElement>(this.element.nativeElement);-- if (this.$element.is('form')) {- this.$form = this.$element;- } else {- this.$form = this.$element.closest('form');- }-- this.$form.on('submit', (evt) => {- if (!this.confirmed) {- evt.preventDefault();- this.openConfirmationDialog();- return false;- }-- return true;- });- }-- public openConfirmationDialog() {- this.confirmDialog.confirm({- text: this.text,- closeByEscape: true,- showClose: true,- closeByDocument: true,- }).then(() => {- this.confirmed = true;- this.$form.trigger('submit');- })- .catch(() => this.confirmed = false);- }-}diff --git a/spec/features/admin/enterprise/enterprise_spec.rb b/spec/features/admin/enterprise/enterprise_spec.rbindex f4ad9e35e70..f51cdad7e36 100644--- a/spec/features/admin/enterprise/enterprise_spec.rb+++ b/spec/features/admin/enterprise/enterprise_spec.rb@@ -108,7 +108,6 @@ describe 'Enterprise token', type: :feature, js: true do# Expect modalfind('[data-qa-selector="confirmation-modal--confirmed"]').click- expect(textarea.value).to be_emptyexpect(page).to have_selector('.flash.notice', text: I18n.t(:notice_successful_delete))# Assume next request