diff --git a/app/assets/stylesheets/content/_collapsible_section.lsg b/app/assets/stylesheets/content/_collapsible_section.lsg index 0ba690a9cb..fe63c3bf9d 100644 --- a/app/assets/stylesheets/content/_collapsible_section.lsg +++ b/app/assets/stylesheets/content/_collapsible_section.lsg @@ -1,22 +1,20 @@ # Collapsible section ``` - -
+ + - ``` ``` - - -
+ + + diff --git a/app/views/enterprises/_current.html.erb b/app/views/enterprises/_current.html.erb index ef08881f6b..96ae278ed2 100644 --- a/app/views/enterprises/_current.html.erb +++ b/app/views/enterprises/_current.html.erb @@ -40,7 +40,8 @@
<%= form_tag({ action: :destroy }, - method: :delete, - class: 'confirm-form-submit') do %> + method: :delete) do %> + <%= styled_button_tag t(:button_delete), type: 'submit', class: '-with-icon icon-delete' %> <% end %> + diff --git a/app/views/enterprises/_form.html.erb b/app/views/enterprises/_form.html.erb index 591638c6ee..86ba915355 100644 --- a/app/views/enterprises/_form.html.erb +++ b/app/views/enterprises/_form.html.erb @@ -1,28 +1,25 @@ -<% if @current_token.present? %> - -<% else %> - -<% end %> -<%= labelled_tabular_form_for @token, - url: { action: :create }, - html: { class: 'token-form form -vertical' }, - method: :post do |f|%> +<% title = @current_token.present? ? t('admin.enterprise.replace_token') : t('admin.enterprise.add_token') %> +<%= augmented_collapsible_section initiallyExpanded: !@current_token.present?, + title: title do %> + <%= labelled_tabular_form_for @token, + url: { action: :create }, + html: { class: 'token-form form -vertical' }, + method: :post do |f|%> -
+
- <%= f.text_area :encoded_token, - value: nil, - cols: 60, - rows: 15, - placeholder: t('admin.enterprise.paste'), - autocomplete: "off", - autocorrect: "off", - autocapitalize: "off", - spellcheck: false %> + <%= f.text_area :encoded_token, + value: nil, + cols: 60, + rows: 15, + placeholder: t('admin.enterprise.paste'), + autocomplete: "off", + autocorrect: "off", + autocapitalize: "off", + spellcheck: false %> -
- <%= styled_button_tag t(:button_save), id: 'token-submit-button', class: '-highlight -with-icon icon-checkmark' %> - <%= link_to t(:button_cancel), { action: :show }, class: 'button' %> +
+ <%= styled_button_tag t(:button_save), id: 'token-submit-button', class: '-highlight -with-icon icon-checkmark' %> + <%= link_to t(:button_cancel), { action: :show }, class: 'button' %> + <% end %> <% end %> -
diff --git a/app/views/enterprises/show.html.erb b/app/views/enterprises/show.html.erb index 141212a064..6e90fc535f 100644 --- a/app/views/enterprises/show.html.erb +++ b/app/views/enterprises/show.html.erb @@ -16,12 +16,10 @@ <%= error_messages_for 'token' %> -<%= activate_angular_js do %> - <% if @current_token.present? %> - <%= render partial: "current" %> - <% else %> - <%= render partial: "info" %> - <% end %> - - <%= render partial: "form" %> +<% if @current_token.present? %> + <%= render partial: "current" %> +<% else %> + <%= render partial: "info" %> <% end %> + +<%= render partial: "form" %> diff --git a/app/views/workflows/edit.html.erb b/app/views/workflows/edit.html.erb index aa062cff4c..e61687a324 100644 --- a/app/views/workflows/edit.html.erb +++ b/app/views/workflows/edit.html.erb @@ -62,31 +62,24 @@ See docs/COPYRIGHT.rdoc for more details. <% end %> <% if @type && @role && @statuses.any? %> - <%= activate_angular_js do %> - <%= form_tag({}, id: 'workflow_form' ) do %> - <%= hidden_field_tag 'type_id', @type.id %> - <%= hidden_field_tag 'role_id', @role.id %> + <%= form_tag({}, id: 'workflow_form' ) do %> + <%= hidden_field_tag 'type_id', @type.id %> + <%= hidden_field_tag 'role_id', @role.id %> - <%= render partial: 'form', - locals: { name: 'always', workflows: @workflows['always'] } %> + <%= render partial: 'form', + locals: { name: 'always', workflows: @workflows['always'] } %> - <% author_expanded = @workflows['author'].present? ? 'true' : '' %> - <% assignee_expanded = @workflows['assignee'].present? ? 'true' : '' %> - - - <%= render partial: 'form', locals: { name: 'author', workflows: @workflows['author'] } %> - - - - <%= render partial: 'form', locals: { name: 'assignee', workflows: @workflows['assignee'] } %> - + <%= augmented_collapsible_section initiallyExpanded: @workflows['author'].present?, + title: t(:label_additional_workflow_transitions_for_author) do %> + <%= render partial: 'form', locals: { name: 'author', workflows: @workflows['author'] } %> + <% end %> - <%= styled_button_tag l(:button_save), class: '-highlight -with-icon icon-checkmark' %> + <%= augmented_collapsible_section initiallyExpanded: @workflows['assignee'].present?, + title: t(:label_additional_workflow_transitions_for_assignee) do %> + <%= render partial: 'form', locals: { name: 'assignee', workflows: @workflows['assignee'] } %> <% end %> + + <%= styled_button_tag l(:button_save), class: '-highlight -with-icon icon-checkmark' %> <% end %> <% end %> diff --git a/frontend/legacy/app/components/collapsible-section/collapsible-section.directive.html b/frontend/legacy/app/components/collapsible-section/collapsible-section.directive.html deleted file mode 100644 index 780b755691..0000000000 --- a/frontend/legacy/app/components/collapsible-section/collapsible-section.directive.html +++ /dev/null @@ -1,11 +0,0 @@ -
- - - -
- -
-
diff --git a/frontend/legacy/app/components/collapsible-section/collapsible-section.directive.ts b/frontend/legacy/app/components/collapsible-section/collapsible-section.directive.ts deleted file mode 100644 index 4690ee8e1b..0000000000 --- a/frontend/legacy/app/components/collapsible-section/collapsible-section.directive.ts +++ /dev/null @@ -1,67 +0,0 @@ -// -- copyright -// OpenProject is a project management system. -// Copyright (C) 2012-2015 the OpenProject Foundation (OPF) -// -// 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 doc/COPYRIGHT.rdoc for more details. -// ++ - -import {openprojectLegacyModule} from "core-app/openproject-legacy-app"; - -export class CollapsibleSectionController { - public text:any; - public expanded:boolean = false; - public sectionTitle:string; - - constructor(public $scope:ng.IScope, - public $attrs:ng.IAttributes) { - - - if ($attrs['initiallyExpanded']) { - this.expanded = true; - } - } - - public toggle() { - this.expanded = !this.expanded; - } -} - -function CollapsibleSection():any { - return { - restrict: 'E', - replace: true, - transclude: true, - template: require('!!raw-loader!./collapsible-section.directive.html'), - - scope: { - sectionTitle: '@' - }, - - bindToController: true, - controller: CollapsibleSectionController, - controllerAs: '$ctrl' - }; -} - -openprojectLegacyModule.directive('collapsibleSection', CollapsibleSection); diff --git a/frontend/src/app/angular4-modules.ts b/frontend/src/app/angular4-modules.ts index 3b32082e25..d2adfef7c4 100644 --- a/frontend/src/app/angular4-modules.ts +++ b/frontend/src/app/angular4-modules.ts @@ -139,7 +139,6 @@ import {BrowserModule} from "@angular/platform-browser"; ModalWrapperAugmentService, ], declarations: [ - ConfirmFormSubmitController, OpContextMenuTrigger, MainMenuResizerComponent, @@ -160,6 +159,7 @@ import {BrowserModule} from "@angular/platform-browser"; // Form configuration OpDragScrollDirective, + ConfirmFormSubmitController, ], entryComponents: [ // Searchbar @@ -178,6 +178,7 @@ import {BrowserModule} from "@angular/platform-browser"; // Main menu MainMenuResizerComponent, MainMenuToggleComponent, + ConfirmFormSubmitController, ] }) export class OpenProjectModule { diff --git a/frontend/src/app/components/modals/confirm-form-submit/confirm-form-submit.directive.ts b/frontend/src/app/components/modals/confirm-form-submit/confirm-form-submit.directive.ts index ecbf8e64e7..279f8464bc 100644 --- a/frontend/src/app/components/modals/confirm-form-submit/confirm-form-submit.directive.ts +++ b/frontend/src/app/components/modals/confirm-form-submit/confirm-form-submit.directive.ts @@ -28,10 +28,12 @@ import {ConfirmDialogService} from './../confirm-dialog/confirm-dialog.service'; import {I18nService} from "core-app/modules/common/i18n/i18n.service"; -import {Directive, ElementRef, OnInit} from "@angular/core"; +import {Component, Directive, ElementRef, OnInit} from "@angular/core"; +import {DynamicBootstrapper} from "core-app/globals/dynamic-bootstrapper"; -@Directive({ - selector: '[confirm-form-submit], .confirm-form-submit' +@Component({ + template: '', + selector: 'confirm-form-submit' }) export class ConfirmFormSubmitController implements OnInit { @@ -41,7 +43,9 @@ export class ConfirmFormSubmitController implements OnInit { title: this.I18n.t('js.modals.form_submit.title'), text: this.I18n.t('js.modals.form_submit.text') }; - private $element:JQuery; + + private $element:JQuery; + private $form:JQuery; constructor(readonly element:ElementRef, readonly confirmDialog:ConfirmDialogService, @@ -49,8 +53,15 @@ export class ConfirmFormSubmitController implements OnInit { } ngOnInit() { - this.$element = jQuery(this.element.nativeElement); - this.$element.on('submit', (evt) => { + this.$element = jQuery(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(); @@ -69,9 +80,11 @@ export class ConfirmFormSubmitController implements OnInit { closeByDocument: true, }).then(() => { this.confirmed = true; - this.$element.trigger('submit'); + this.$form.trigger('submit'); }) .catch(() => this.confirmed = false); } } +// Register the element style for bootstrapping +DynamicBootstrapper.register({ selector: 'confirm-form-submit', cls: ConfirmFormSubmitController }); diff --git a/spec/features/admin/enterprise_spec.rb b/spec/features/admin/enterprise_spec.rb index b4c2e15ca7..fcf325a54d 100644 --- a/spec/features/admin/enterprise_spec.rb +++ b/spec/features/admin/enterprise_spec.rb @@ -28,7 +28,7 @@ require 'spec_helper' -describe 'Enterprise token', type: :feature do +describe 'Enterprise token', type: :feature, js: true do include Redmine::I18n let(:admin) { FactoryBot.create(:admin) } @@ -63,9 +63,6 @@ describe 'Enterprise token', type: :feature do text: "Enterprise support token can't be read. " \ "Are you sure it is a support token?") expect(page).to have_selector('span.errorSpan #enterprise_token_encoded_token') - - # Keeps value - expect(textarea.value).to eq('foobar') end context 'assuming valid input' do