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
Set data-turbo=true on submitters
Oliver Günther57dbb686e5c2
diff --git a/frontend/src/turbo/turbo-event-listeners.ts b/frontend/src/turbo/turbo-event-listeners.tsindex 551d56a8b9c..23a76c58a1c 100644--- a/frontend/src/turbo/turbo-event-listeners.ts+++ b/frontend/src/turbo/turbo-event-listeners.ts@@ -1,5 +1,3 @@-import { navigator } from '@hotwired/turbo';-export function addTurboEventListeners() {// Close the primer dialog when the form inside has been submitted with a success response// It is necessary to close the primer dialog using the `close()` method, otherwise@@ -12,13 +10,4 @@ export function addTurboEventListeners() {dialog && dialog.close();}});-- // Forward a form submit on a button[type=submit][form=formid] to the turbo navigator- // cf. https://github.com/hotwired/turbo/issues/1246- document.addEventListener('submit', (event:SubmitEvent) => {- if (event.submitter?.getAttribute('form')) {- event.preventDefault();- navigator.submitForm(event.target as HTMLFormElement, event.submitter);- }- });}diff --git a/lookbook/docs/patterns/05-dialogs.md.erb b/lookbook/docs/patterns/05-dialogs.md.erbindex 3a25a0edf5f..66c135596ef 100644--- a/lookbook/docs/patterns/05-dialogs.md.erb+++ b/lookbook/docs/patterns/05-dialogs.md.erb@@ -92,6 +92,42 @@ a [custom turbo stream action](https://turbo.hotwired.dev/handbook/streams#custoThe frontend turbo stream `dialog` action will take this dialog, append it to the body, and open it immediately.Once the dialog is closed, the content is removed from the DOM again.+### Dialogs with separate forms++We have seen that we want to render the body part of the dialog in a separate component.+This will result in the submit buttons being outside of that component that renders a form.++In the following example, the body renders a separate component with a form. You can tell the+submit button to reference the form attribute using `form: "id-of-the-form"`. With turbo,+you have to make sure that the data-turbo attribute is also set.++```erb+<%%= turbo_stream.dialog do+ render(Primer::Alpha::Dialog.new(title: t(:label_history),+ id: 'my-dialog')) do |d|+ d.with_header(variant: :large)+ d.with_body do+ render(ComponentThatRendersAForm.new(form_id: "my-dialog-form")+ end++ d.with_footer do+ render(Primer::Beta::Button.new(+ tag: :button,+ type: :submit,+ form: "my-dialog-form"+ data: { turbo: true }+ variant: :primary,+ ) do |button|+ button.text = t(:button_save)+ end)+ end++ end+end+%>+```++## Special kinds of dialogsWe have multiple kind of dialogs that re-appear throughout the whole application. In order to make sure, they all look and feel alike, we further specify them here.diff --git a/modules/meeting/app/components/meetings/sidebar/participants_dialog.html.erb b/modules/meeting/app/components/meetings/sidebar/participants_dialog.html.erbindex f77b0e67c6b..8c1fde5e83a 100644--- a/modules/meeting/app/components/meetings/sidebar/participants_dialog.html.erb+++ b/modules/meeting/app/components/meetings/sidebar/participants_dialog.html.erb@@ -123,6 +123,7 @@footer.with_component(Primer::ButtonComponent.new(scheme: :primary,form: "edit_participants_form",+ data: { turbo: true },type: :submit)) dot("button_save")enddiff --git a/modules/meeting/app/components/work_package_meetings_tab/add_work_package_to_meeting_dialog_component.html.erb b/modules/meeting/app/components/work_package_meetings_tab/add_work_package_to_meeting_dialog_component.html.erbindex d4a98fb5435..f5fb18c671e 100644--- a/modules/meeting/app/components/work_package_meetings_tab/add_work_package_to_meeting_dialog_component.html.erb+++ b/modules/meeting/app/components/work_package_meetings_tab/add_work_package_to_meeting_dialog_component.html.erb@@ -21,6 +21,7 @@buttons.with_component(Primer::ButtonComponent.new(scheme: :primary,form: "add-work-package-to-meeting-form",+ data: { turbo: true },type: :submit)) dot("button_save")enddiff --git a/modules/overviews/app/components/project_custom_fields/sections/edit_dialog_component.html.erb b/modules/overviews/app/components/project_custom_fields/sections/edit_dialog_component.html.erbindex e774f34af8c..dc4d4e8e8f9 100644--- a/modules/overviews/app/components/project_custom_fields/sections/edit_dialog_component.html.erb+++ b/modules/overviews/app/components/project_custom_fields/sections/edit_dialog_component.html.erb@@ -20,7 +20,8 @@type: :submit,form: "project-section-edit-form",data: {- test_selector: 'save-project-attributes-button'+ test_selector: 'save-project-attributes-button',+ turbo: true})) dot("button_save")