Skip to content

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

avoid double submit of form configuration

ulferts1b16dbcc0724
diff --git a/app/models/type/attribute_groups.rb b/app/models/type/attribute_groups.rb
index 5873e531477..93bb4968af7 100644
--- a/app/models/type/attribute_groups.rb
+++ b/app/models/type/attribute_groups.rb
@@ -136,7 +136,6 @@ module Type::AttributeGroups
self.attribute_groups_objects = nil
end
-
private
def write_attribute_groups_objects
diff --git a/app/services/base_type_service.rb b/app/services/base_type_service.rb
index 448f4db1cf2..00353931646 100644
--- a/app/services/base_type_service.rb
+++ b/app/services/base_type_service.rb
@@ -104,7 +104,6 @@ class BaseTypeService
def transform_attribute_groups(groups)
groups.map do |group|
-
if group['type'] == 'query'
transform_query_group(group)
else
diff --git a/app/views/types/form/_form_configuration.html.erb b/app/views/types/form/_form_configuration.html.erb
index 1abfcf013b2..d851152ccc3 100644
--- a/app/views/types/form/_form_configuration.html.erb
+++ b/app/views/types/form/_form_configuration.html.erb
@@ -89,6 +89,7 @@ See docs/COPYRIGHT.rdoc for more details.
<div class="grid-block">
<div class="generic-table--action-buttons">
<%= styled_button_tag t(@type.new_record? ? :button_create : :button_save),
+ data: { disable_with: t(@type.new_record? ? :button_create : :button_save) },
class: 'form-configuration--save -highlight -with-icon icon-checkmark' %>
</div>
</div>
diff --git a/frontend/src/app/modules/admin/types/type-form-configuration.component.ts b/frontend/src/app/modules/admin/types/type-form-configuration.component.ts
index 5df24de52da..763c1fe712f 100644
--- a/frontend/src/app/modules/admin/types/type-form-configuration.component.ts
+++ b/frontend/src/app/modules/admin/types/type-form-configuration.component.ts
@@ -79,9 +79,22 @@ export class TypeFormConfigurationComponent implements OnInit, OnDestroy {
this.form = jQuery(this.element).closest('form');
this.submit = this.form.find('.form-configuration--save');
+ // In the following we are triggering the form submit ourselves to work around
+ // a firefox shortcoming. But to avoid double submits which are sometimes not canceled fast
+ // enough, we need to memoize whether we have already submitted.
+ let submitted = false;
+
+ this.form.on('submit', (event) => {
+ submitted = true;
+ });
+
// Capture mousedown on button because firefox breaks blur on click
this.submit.on('mousedown', (event) => {
- setTimeout(() => this.form.trigger('submit'), 50);
+ setTimeout(() => {
+ if (!submitted) {
+ this.form.trigger('submit');
+ }
+ }, 50);
return true;
});