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

Replace AsyncDialogComponent with the truly async dialogs

Oliver Güntherb9f9ec4ecb34
diff --git a/app/components/concerns/op_turbo/streamable.rb b/app/components/concerns/op_turbo/streamable.rb
index d0d76118d96..000bdc1088c 100644
--- a/app/components/concerns/op_turbo/streamable.rb
+++ b/app/components/concerns/op_turbo/streamable.rb
@@ -43,7 +43,7 @@ module OpTurbo
included do
def render_as_turbo_stream(view_context:, action: :update)
case action
- when :update
+ when :update, :dialog
@inner_html_only = true
template = render_in(view_context)
when :replace
@@ -56,7 +56,7 @@ module OpTurbo
raise ArgumentError, "Unsupported action #{action}"
end
- unless wrapped?
+ if action != :dialog && !wrapped?
raise MissingComponentWrapper,
"Wrap your component in a `component_wrapper` block in order to use turbo-stream methods"
end
diff --git a/app/controllers/concerns/op_turbo/dialog_stream_helper.rb b/app/controllers/concerns/op_turbo/dialog_stream_helper.rb
new file mode 100644
index 00000000000..429506530d3
--- /dev/null
+++ b/app/controllers/concerns/op_turbo/dialog_stream_helper.rb
@@ -0,0 +1,41 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2024 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.
+#++
+
+module OpTurbo
+ module DialogStreamHelper
+ def respond_with_dialog(dialog_component, status: :ok, &format_block)
+ respond_to do |format|
+ format.turbo_stream do
+ render turbo_stream: dialog_component.render_as_turbo_stream(view_context:, action: :dialog), status:
+ end
+
+ yield(format) if format_block
+ end
+ end
+ end
+end
diff --git a/frontend/src/stimulus/controllers/async-dialog.controller.ts b/frontend/src/stimulus/controllers/async-dialog.controller.ts
index 86e24904d40..61e9fa59391 100644
--- a/frontend/src/stimulus/controllers/async-dialog.controller.ts
+++ b/frontend/src/stimulus/controllers/async-dialog.controller.ts
@@ -37,19 +37,29 @@ export default class AsyncDialogController extends ApplicationController {
connect() {
this.element.addEventListener('click', (e) => {
e.preventDefault();
- this.addLoading();
this.triggerTurboStream();
});
}
- async triggerTurboStream():Promise<void> {
+ triggerTurboStream():void {
+ let loaded = false;
+
+ setTimeout(() => {
+ if (!loaded) {
+ this.addLoading();
+ }
+ }, 100);
+
fetch(this.href, {
method: this.method,
headers: {
Accept: 'text/vnd.turbo-stream.html',
},
}).then((r) => r.text())
- .then((html) => renderStreamMessage(html))
+ .then((html) => {
+ loaded = true;
+ renderStreamMessage(html);
+ })
.finally(() => this.removeLoading());
}
diff --git a/frontend/src/stimulus/controllers/dynamic/op-turbo-op-primer-async-dialog.controller.ts b/frontend/src/stimulus/controllers/dynamic/op-turbo-op-primer-async-dialog.controller.ts
deleted file mode 100644
index 59ca206674b..00000000000
--- a/frontend/src/stimulus/controllers/dynamic/op-turbo-op-primer-async-dialog.controller.ts
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * -- 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 { Controller } from '@hotwired/stimulus';
-import { TurboElement } from '../../../typings/turbo';
-
-export default class extends Controller {
- static targets = ['frameElement'];
- declare readonly frameElementTarget:HTMLInputElement&TurboElement;
-
- private initialState:string;
-
- connect():void {
- this.initialState = this.frameElementTarget.innerHTML;
- }
-
- reinitFrame():void {
- this.frameElementTarget.innerHTML = this.initialState;
- this.frameElementTarget.reload();
- }
-}
diff --git a/lib/primer/open_project/forms/autocompleter.html.erb b/lib/primer/open_project/forms/autocompleter.html.erb
index 9b3c555f437..1f2d040100a 100644
--- a/lib/primer/open_project/forms/autocompleter.html.erb
+++ b/lib/primer/open_project/forms/autocompleter.html.erb
@@ -1,6 +1,7 @@
<%= render(FormControl.new(input: @input, data: @wrapper_data_attributes)) do %>
<% if decorated_select? %>
<%= render partial: '/augmented/autocomplete_select_decoration',
+ formats: %i[html],
locals: {
input_name: @autocomplete_options.fetch(:inputName) { builder.field_name(@input.name) },
input_id: @autocomplete_options.fetch(:inputId) { builder.field_id(@input.name) },
diff --git a/modules/meeting/app/components/meetings/header_component.html.erb b/modules/meeting/app/components/meetings/header_component.html.erb
index 10207832a0c..f45c3ec1789 100644
--- a/modules/meeting/app/components/meetings/header_component.html.erb
+++ b/modules/meeting/app/components/meetings/header_component.html.erb
@@ -48,7 +48,6 @@
href: history_meeting_path(@meeting),
content_arguments: {
"data-controller": "async-dialog",
- "data-show-dialog-id": "meetings-history-dialog",
},
value: ""
) do |item|
diff --git a/modules/meeting/app/components/meetings/sidebar/details_component.html.erb b/modules/meeting/app/components/meetings/sidebar/details_component.html.erb
index 462d10d66d7..a14094b5c16 100644
--- a/modules/meeting/app/components/meetings/sidebar/details_component.html.erb
+++ b/modules/meeting/app/components/meetings/sidebar/details_component.html.erb
@@ -102,7 +102,9 @@
render(Primer::Beta::Button.new(
scheme: :link,
underline: false,
- data: { 'show-dialog-id': "edit-participants-dialog" }
+ tag: :a,
+ href: participants_dialog_meeting_path(@meeting),
+ data: { controller: 'async-dialog' }
)) do
t("label_meeting_show_all_participants")
end
@@ -110,16 +112,6 @@
end
end
end
-
- details.with_row do
- render(OpTurbo::OpPrimer::AsyncDialogComponent.new(
- id: "edit-participants-dialog",
- src: participants_dialog_meeting_path(@meeting),
- size: :medium_portrait,
- title: Meeting.human_attribute_name(:participants),
- hide_button: true
- ))
- end
end
end
end
diff --git a/modules/meeting/app/components/meetings/sidebar/participants_component.html.erb b/modules/meeting/app/components/meetings/sidebar/participants_component.html.erb
index 913d6a470c9..cd083d2738e 100644
--- a/modules/meeting/app/components/meetings/sidebar/participants_component.html.erb
+++ b/modules/meeting/app/components/meetings/sidebar/participants_component.html.erb
@@ -20,9 +20,11 @@
render(Primer::Beta::IconButton.new(
icon: :gear,
scheme: :invisible,
+ tag: :a,
+ href: participants_dialog_meeting_path(@meeting),
+ data: { controller: 'async-dialog' },
'aria-label': t("label_meeting_manage_participants"),
test_selector: "manage-participants-button",
- data: { 'show-dialog-id': "edit-participants-dialog" }
))
end
end
@@ -80,7 +82,9 @@
color: :default,
underline: false,
font_weight: :bold,
- data: { 'show-dialog-id': "edit-participants-dialog" }
+ tag: :a,
+ href: participants_dialog_meeting_path(@meeting),
+ data: { controller: 'async-dialog' }
)) do |button|
button.with_leading_visual_icon(icon: "person-add")
t("label_meeting_add_participants")
diff --git a/modules/meeting/app/components/meetings/sidebar/participants_dialog.html.erb b/modules/meeting/app/components/meetings/sidebar/participants_dialog.html.erb
new file mode 100644
index 00000000000..edf6fbe6dab
--- /dev/null
+++ b/modules/meeting/app/components/meetings/sidebar/participants_dialog.html.erb
@@ -0,0 +1,136 @@
+<%=
+ render(Primer::Alpha::Dialog.new(
+ id: "edit-participants-dialog",
+ size: :medium_portrait,
+ title: Meeting.human_attribute_name(:participants
+ ))) do |d|
+ d.with_header(variant: :large)
+ d.with_body do
+ component_wrapper(class: 'Overlay-form') do
+ primer_form_with(
+ id: "edit_participants_form",
+ model: @meeting,
+ method: :put,
+ url: update_participants_meeting_path(@meeting),
+ data: { turbo: true, turbo_stream: true },
+ class: 'Overlay-form'
+ ) do |f|
+ component_collection do |collection|
+ collection.with_component(Primer::Alpha::Dialog::Body.new(my: 3)) do
+ flex_layout(mt: 3) do |form_container|
+ form_container.with_row do
+ flex_layout(justify_content: :flex_end) do |header|
+ header.with_column(style: "width: 90px;", text_align: :center) do
+ render(Primer::Beta::Text.new(font_weight: :emphasized)) { t("description_invite").capitalize }
+ end
+
+ header.with_column(style: "width: 90px;", text_align: :center) do
+ render(Primer::Beta::Text.new(font_weight: :emphasized)) { t("description_attended").capitalize }
+ end
+ end
+ end
+
+ form_container.with_row do
+ flex_layout(my: 3) do |form_content|
+ @meeting.all_changeable_participants.sort.each do |user|
+ form_content.with_row do
+ hidden_field_tag "meeting[participants_attributes][][user_id]", user.id
+ end
+ form_content.with_row(mb: 2, pb: 1, border: :bottom) do
+ if @meeting.participants.present? && participant = @meeting.participants.detect { |p| p.user_id == user.id }
+ flex_layout do |existing_participant_container|
+ existing_participant_container.with_row do
+ hidden_field_tag "meeting[participants_attributes][][id]", participant.id
+ end
+
+ existing_participant_container.with_row do
+ flex_layout(align_items: :center) do |existing_participant|
+ existing_participant.with_column(flex: 1, classes: 'ellipsis') do
+ render(Users::AvatarComponent.new(
+ user: participant.user,
+ classes: 'op-principal_flex'
+ ))
+ end
+ existing_participant.with_column(style: "width: 90px;", text_align: :center) do
+ styled_check_box_tag "meeting[participants_attributes][][invited]",
+ value = 1,
+ checked = participant.invited?,
+ id: "checkbox_invited_#{participant.user.id}",
+ disabled: [email protected]?
+ # Primer checkboxes currently not working in this context as they render an additional hidden input tag
+ # messing up the nested attributes mapping when posting the data to the server
+ #
+ # render(Primer::Alpha::CheckBox.new(
+ # name: "meeting[participants_attributes][][invited]",
+ # checked: participant.invited?,
+ # id: "checkbox_invited_#{participant.user.id}",
+ # visually_hide_label: true,
+ # label: "Invited",
+ # scheme: :boolean,
+ # unchecked_value: ""
+ # ))
+ end
+ existing_participant.with_column(style: "width: 90px;", text_align: :center) do
+ styled_check_box_tag "meeting[participants_attributes][][attended]",
+ value = 1,
+ checked = participant.attended?,
+ id: "checkbox_attended_#{participant.user.id}",
+ disabled: [email protected]?
+ end
+ end
+ end
+ end
+ else
+ flex_layout(align_items: :center) do |new_participant|
+ new_participant.with_column(flex: 1, classes: 'ellipsis') do
+ render(Users::AvatarComponent.new(
+ user:,
+ classes: 'op-principal_flex'
+ ))
+ end
+
+ new_participant.with_column(style: "width: 90px;", text_align: :center) do
+ styled_check_box_tag "meeting[participants_attributes][][invited]",
+ value = "1",
+ checked = false,
+ id: "checkbox_invited_#{user.id}",
+ disabled: [email protected]?
+ end
+
+ new_participant.with_column(style: "width: 90px;", text_align: :center) do
+ styled_check_box_tag "meeting[participants_attributes][][attended]",
+ value = "1",
+ checked = false,
+ id: "checkbox_attended_#{user.id}",
+ disabled: [email protected]?
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+
+ if @meeting.editable?
+ d.with_footer do
+ component_collection do |footer|
+ footer.with_component(Primer::ButtonComponent.new(data: { 'close-dialog-id': "edit-participants-dialog" })) do
+ t("button_cancel")
+ end
+ footer.with_component(Primer::ButtonComponent.new(
+ scheme: :primary,
+ form: "edit_participants_form",
+ type: :submit)) do
+ t("button_save")
+ end
+ end
+ end
+ end
+ end
+%>
diff --git a/modules/meeting/app/components/meetings/sidebar/participants_form_component.rb b/modules/meeting/app/components/meetings/sidebar/participants_dialog.rb
similarity index 95%
rename from modules/meeting/app/components/meetings/sidebar/participants_form_component.rb
rename to modules/meeting/app/components/meetings/sidebar/participants_dialog.rb
index 7e799c91146..1e1824b86ab 100644
--- a/modules/meeting/app/components/meetings/sidebar/participants_form_component.rb
+++ b/modules/meeting/app/components/meetings/sidebar/participants_dialog.rb
@@ -27,7 +27,7 @@
#++
module Meetings
- class Sidebar::ParticipantsFormComponent < ApplicationComponent
+ class Sidebar::ParticipantsDialog < ApplicationComponent
include ApplicationHelper
include OpenProject::FormTagHelper
include OpTurbo::Streamable
diff --git a/modules/meeting/app/components/meetings/sidebar/participants_form_component.html.erb b/modules/meeting/app/components/meetings/sidebar/participants_form_component.html.erb
deleted file mode 100644
index 8cd962c23d8..00000000000
--- a/modules/meeting/app/components/meetings/sidebar/participants_form_component.html.erb
+++ /dev/null
@@ -1,124 +0,0 @@
-<%=
- content_tag("turbo-frame", id: "edit-participants-dialog-frame") do
- component_wrapper(class: 'Overlay-form') do
- primer_form_with(
- model: @meeting,
- method: :put,
- url: update_participants_meeting_path(@meeting),
- class: 'Overlay-form'
- ) do |f|
- component_collection do |collection|
- collection.with_component(Primer::Alpha::Dialog::Body.new(my: 3)) do
- flex_layout(mt: 3) do |form_container|
- form_container.with_row do
- flex_layout(justify_content: :flex_end) do |header|
- header.with_column(style: "width: 90px;", text_align: :center) do
- render(Primer::Beta::Text.new(font_weight: :emphasized)) { t("description_invite").capitalize }
- end
-
- header.with_column(style: "width: 90px;", text_align: :center) do
- render(Primer::Beta::Text.new(font_weight: :emphasized)) { t("description_attended").capitalize }
- end
- end
- end
-
- form_container.with_row do
- flex_layout(my: 3) do |form_content|
- @meeting.all_changeable_participants.sort.each do |user|
- form_content.with_row do
- hidden_field_tag "meeting[participants_attributes][][user_id]", user.id
- end
- form_content.with_row(mb: 2, pb: 1, border: :bottom) do
- if @meeting.participants.present? && participant = @meeting.participants.detect { |p| p.user_id == user.id }
- flex_layout do |existing_participant_container|
- existing_participant_container.with_row do
- hidden_field_tag "meeting[participants_attributes][][id]", participant.id
- end
-
- existing_participant_container.with_row do
- flex_layout(align_items: :center) do |existing_participant|
- existing_participant.with_column(flex: 1, classes: 'ellipsis') do
- render(Users::AvatarComponent.new(
- user: participant.user,
- classes: 'op-principal_flex'
- ))
- end
- existing_participant.with_column(style: "width: 90px;", text_align: :center) do
- styled_check_box_tag "meeting[participants_attributes][][invited]",
- value = 1,
- checked = participant.invited?,
- id: "checkbox_invited_#{participant.user.id}",
- disabled: [email protected]?
- # Primer checkboxes currently not working in this context as they render an additional hidden input tag
- # messing up the nested attributes mapping when posting the data to the server
- #
- # render(Primer::Alpha::CheckBox.new(
- # name: "meeting[participants_attributes][][invited]",
- # checked: participant.invited?,
- # id: "checkbox_invited_#{participant.user.id}",
- # visually_hide_label: true,
- # label: "Invited",
- # scheme: :boolean,
- # unchecked_value: ""
- # ))
- end
- existing_participant.with_column(style: "width: 90px;", text_align: :center) do
- styled_check_box_tag "meeting[participants_attributes][][attended]",
- value = 1,
- checked = participant.attended?,
- id: "checkbox_attended_#{participant.user.id}",
- disabled: [email protected]?
- end
- end
- end
- end
- else
- flex_layout(align_items: :center) do |new_participant|
- new_participant.with_column(flex: 1, classes: 'ellipsis') do
- render(Users::AvatarComponent.new(
- user:,
- classes: 'op-principal_flex'
- ))
- end
-
- new_participant.with_column(style: "width: 90px;", text_align: :center) do
- styled_check_box_tag "meeting[participants_attributes][][invited]",
- value = "1",
- checked = false,
- id: "checkbox_invited_#{user.id}",
- disabled: [email protected]?
- end
-
- new_participant.with_column(style: "width: 90px;", text_align: :center) do
- styled_check_box_tag "meeting[participants_attributes][][attended]",
- value = "1",
- checked = false,
- id: "checkbox_attended_#{user.id}",
- disabled: [email protected]?
- end
- end
- end
- end
- end
- end
- end
- end
- end
-
- if @meeting.editable?
- collection.with_component(Primer::Alpha::Dialog::Footer.new(show_divider: true)) do
- component_collection do |footer|
- footer.with_component(Primer::ButtonComponent.new(data: { 'close-dialog-id': "edit-participants-dialog" })) do
- t("button_cancel")
- end
- footer.with_component(Primer::ButtonComponent.new(scheme: :primary, type: :submit)) do
- t("button_save")
- end
- end
- end
- end
- end
- end
- end
- end
-%>
diff --git a/modules/meeting/app/components/op_turbo/op_primer/async_dialog_component.html.erb b/modules/meeting/app/components/op_turbo/op_primer/async_dialog_component.html.erb
deleted file mode 100644
index 59c33590647..00000000000
--- a/modules/meeting/app/components/op_turbo/op_primer/async_dialog_component.html.erb
+++ /dev/null
@@ -1,35 +0,0 @@
-<%=
- render(Primer::Box.new(data: stimulus_attributes)) do
- render(Primer::Alpha::Dialog.new(
- id: @id,
- title: @title,
- size: @size
- )) do |dialog|
- dialog.with_header(variant: @header_variant)
-
- unless @hide_button
- if @button_text
- dialog.with_show_button(**merged_text_button_attributes) do |button|
- button.with_leading_visual_icon(icon: @button_icon) if @button_icon
- @button_text
- end
- else
- dialog.with_show_button(**merged_icon_button_attributes)
- end
- end
-
- content_tag("turbo-frame",
- id: "#{@id}-frame",
- loading: :lazy,
- src: @src,
- class: 'Overlay-form',
- data: { 'op-turbo-op-primer-async-dialog-target': "frameElement" }) do
- flex_layout(justify_content: :center) do |flex|
- flex.with_column(my: 5) do
- render(Primer::Beta::Spinner.new)
- end
- end
- end
- end
- end
-%>
diff --git a/modules/meeting/app/components/op_turbo/op_primer/async_dialog_component.rb b/modules/meeting/app/components/op_turbo/op_primer/async_dialog_component.rb
deleted file mode 100644
index eab35782557..00000000000
--- a/modules/meeting/app/components/op_turbo/op_primer/async_dialog_component.rb
+++ /dev/null
@@ -1,76 +0,0 @@
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) 2012-2024 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.
-#++
-
-module OpTurbo
- module OpPrimer
- class AsyncDialogComponent < ApplicationComponent
- include ApplicationHelper
- include ::OpPrimer::ComponentHelpers
-
- def initialize(id:, src:, title:, size: :auto, header_variant: :medium,
- hide_button: false, button_icon: nil, button_icon_label: nil, button_text: nil, button_attributes: {})
- super
-
- @id = id
- @src = src
- @title = title
- @header_variant = header_variant
- @size = size
- @hide_button = hide_button
- @button_icon = button_icon
- @button_icon_label = button_icon_label
- @button_text = button_text
- @button_attributes = button_attributes
- end
-
- private
-
- def stimulus_attributes
- {
- controller: 'op-turbo-op-primer-async-dialog',
- 'application-target': 'dynamic'
- }
- end
-
- def merged_text_button_attributes
- stimuls_action_ref = 'click->op-turbo-op-primer-async-dialog#reinitFrame'
-
- @button_attributes[:data] = {} if @button_attributes[:data].nil?
- @button_attributes[:data][:action] = stimuls_action_ref
-
- @button_attributes
- end
-
- def merged_icon_button_attributes
- merged_text_button_attributes.merge(
- icon: @button_icon, 'aria-label': @button_icon_label
- )
- end
- end
- end
-end
diff --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.erb
new file mode 100644
index 00000000000..76457f6103f
--- /dev/null
+++ b/modules/meeting/app/components/work_package_meetings_tab/add_work_package_to_meeting_dialog_component.html.erb
@@ -0,0 +1,42 @@
+<%=
+ render(Primer::Alpha::Dialog.new(title: t("label_add_work_package_to_meeting_dialog_title"),
+ size: :xlarge,
+ id: 'add-work-package-to-meeting-dialog')) do |d|
+ d.with_header(variant: :large)
+ d.with_body do
+ primer_form_with(
+ model: @meeting_agenda_item,
+ method: :post,
+ url: work_package_meeting_agenda_items_path(@work_package),
+ ) do |f|
+ flex_layout(my: 3) do |flex|
+ flex.with_row do
+ if @base_errors&.any?
+ render(Primer::Alpha::Banner.new(mb: 3, icon: :stop, scheme: :danger)) { @base_errors.join("\n") }
+ end
+ end
+ flex.with_row do
+ render(MeetingAgendaItem::MeetingForm.new(f, wrapper_id: 'add-work-package-to-meeting-dialog'))
+ end
+ flex.with_row(mt: 3) do
+ render(MeetingAgendaItem::Notes.new(f))
+ end
+ end
+ end
+ end
+ d.with_footer do
+ component_collection do |buttons|
+ buttons.with_component(Primer::ButtonComponent.new(
+ data: {
+ 'close-dialog-id': "add-work-package-to-meeting-dialog"
+ }
+ )) do
+ t("button_cancel")
+ end
+ buttons.with_component(Primer::ButtonComponent.new(scheme: :primary, type: :submit)) do
+ t("button_save")
+ end
+ end
+ end
+ end
+%>
diff --git a/modules/meeting/app/components/work_package_meetings_tab/add_work_package_to_meeting_form_component.rb b/modules/meeting/app/components/work_package_meetings_tab/add_work_package_to_meeting_dialog_component.rb
similarity index 95%
rename from modules/meeting/app/components/work_package_meetings_tab/add_work_package_to_meeting_form_component.rb
rename to modules/meeting/app/components/work_package_meetings_tab/add_work_package_to_meeting_dialog_component.rb
index ece92b57d75..ac8801102a3 100644
--- a/modules/meeting/app/components/work_package_meetings_tab/add_work_package_to_meeting_form_component.rb
+++ b/modules/meeting/app/components/work_package_meetings_tab/add_work_package_to_meeting_dialog_component.rb
@@ -27,7 +27,7 @@
#++
module WorkPackageMeetingsTab
- class AddWorkPackageToMeetingFormComponent < ApplicationComponent
+ class AddWorkPackageToMeetingDialogComponent < ApplicationComponent
include ApplicationHelper
include OpTurbo::Streamable
include OpPrimer::ComponentHelpers
diff --git a/modules/meeting/app/components/work_package_meetings_tab/add_work_package_to_meeting_form_component.html.erb b/modules/meeting/app/components/work_package_meetings_tab/add_work_package_to_meeting_form_component.html.erb
deleted file mode 100644
index ceb7acf637e..00000000000
--- a/modules/meeting/app/components/work_package_meetings_tab/add_work_package_to_meeting_form_component.html.erb
+++ /dev/null
@@ -1,44 +0,0 @@
-<%=
- content_tag("turbo-frame", id: "add-work-package-to-meeting-dialog-frame") do
- component_wrapper(class: 'Overlay-form') do
- primer_form_with(
- model: @meeting_agenda_item,
- method: :post,
- url: work_package_meeting_agenda_items_path(@work_package),
- class: 'Overlay-form'
- ) do |f|
- component_collection do |collection|
- collection.with_component(Primer::Alpha::Dialog::Body.new(test_selector: 'op-add-work-package-to-meeting-dialog-body')) do
- flex_layout(my: 3) do |flex|
- flex.with_row do
- if @base_errors&.any?
- render(Primer::Alpha::Banner.new(mb: 3, icon: :stop, scheme: :danger)) { @base_errors.join("\n") }
- end
- end
- flex.with_row do
- render(MeetingAgendaItem::MeetingForm.new(f, wrapper_id: 'add-work-package-to-meeting-dialog'))
- end
- flex.with_row(mt: 3) do
- render(MeetingAgendaItem::Notes.new(f))
- end
- end
- end
- collection.with_component(Primer::Alpha::Dialog::Footer.new) do
- component_collection do |collection1|
- collection1.with_component(Primer::ButtonComponent.new(
- data: {
- 'close-dialog-id': "add-work-package-to-meeting-dialog"
- }
- )) do
- t("button_cancel")
- end
- collection1.with_component(Primer::ButtonComponent.new(scheme: :primary, type: :submit)) do
- t("button_save")
- end
- end
- end
- end
- end
- end
- end
-%>
diff --git a/modules/meeting/app/components/work_package_meetings_tab/heading_component.html.erb b/modules/meeting/app/components/work_package_meetings_tab/heading_component.html.erb
index 3bb93be6981..da04671cd96 100644
--- a/modules/meeting/app/components/work_package_meetings_tab/heading_component.html.erb
+++ b/modules/meeting/app/components/work_package_meetings_tab/heading_component.html.erb
@@ -6,17 +6,15 @@
end
if allowed_to_add_to_meeting?
flex.with_column(ml: 3) do
- render(OpTurbo::OpPrimer::AsyncDialogComponent.new(
- id: "add-work-package-to-meeting-dialog",
- src: dialog_work_package_meeting_agenda_items_path(@work_package),
- size: :xlarge,
- title: t("label_add_work_package_to_meeting_dialog_title"),
- button_icon: :plus,
- button_text: t("label_add_work_package_to_meeting_dialog_button"),
- button_attributes: {
- test_selector: "op-add-work-package-to-meeting-dialog-trigger"
- }
- ))
+ render(Primer::Beta::Button.new(
+ tag: :a,
+ href: dialog_work_package_meeting_agenda_items_path(@work_package),
+ data: { controller: 'async-dialog' },
+ test_selector: "op-add-work-package-to-meeting-dialog-trigger"
+ )) do |button|
+ button.with_leading_visual_icon(icon: :plus)
+ t("label_add_work_package_to_meeting_dialog_button")
+ end
end
end
end
diff --git a/modules/meeting/app/controllers/meetings_controller.rb b/modules/meeting/app/controllers/meetings_controller.rb
index 0766b381656..d4b6c440d63 100644
--- a/modules/meeting/app/controllers/meetings_controller.rb
+++ b/modules/meeting/app/controllers/meetings_controller.rb
@@ -160,20 +160,14 @@ class MeetingsController < ApplicationController
end
end
- def participants_dialog
- render(Meetings::Sidebar::ParticipantsFormComponent.new(meeting: @meeting), layout: false)
- end
+ def participants_dialog; end
def update_participants
@meeting.participants_attributes = @converted_params.delete(:participants_attributes)
@meeting.save
- if @meeting.errors.any?
- update_sidebar_participants_form_component_via_turbo_stream
- else
- update_sidebar_details_component_via_turbo_stream
- update_sidebar_participants_component_via_turbo_stream
- end
+ update_sidebar_details_component_via_turbo_stream
+ update_sidebar_participants_component_via_turbo_stream
respond_with_turbo_streams
end
diff --git a/modules/meeting/app/controllers/work_package_meetings_tab_controller.rb b/modules/meeting/app/controllers/work_package_meetings_tab_controller.rb
index add8df56053..f876d7e2c89 100644
--- a/modules/meeting/app/controllers/work_package_meetings_tab_controller.rb
+++ b/modules/meeting/app/controllers/work_package_meetings_tab_controller.rb
@@ -28,6 +28,7 @@
class WorkPackageMeetingsTabController < ApplicationController
include OpTurbo::ComponentStream
+ include OpTurbo::DialogStreamHelper
include Meetings::WorkPackageMeetingsTabComponentStreams
before_action :set_work_package
@@ -56,7 +57,7 @@ class WorkPackageMeetingsTabController < ApplicationController
end
def add_work_package_to_meeting_dialog
- render(WorkPackageMeetingsTab::AddWorkPackageToMeetingFormComponent.new(work_package: @work_package), layout: false)
+ respond_with_dialog WorkPackageMeetingsTab::AddWorkPackageToMeetingDialogComponent.new(work_package: @work_package)
end
def add_work_package_to_meeting
diff --git a/modules/meeting/app/views/meetings/participants_dialog.turbo_stream.erb b/modules/meeting/app/views/meetings/participants_dialog.turbo_stream.erb
new file mode 100644
index 00000000000..d0a526ec92d
--- /dev/null
+++ b/modules/meeting/app/views/meetings/participants_dialog.turbo_stream.erb
@@ -0,0 +1,5 @@
+<%=
+ turbo_stream.dialog do
+ render(Meetings::Sidebar::ParticipantsDialog.new(meeting: @meeting))
+ end
+%>
diff --git a/modules/meeting/spec/support/pages/structured_meeting/show.rb b/modules/meeting/spec/support/pages/structured_meeting/show.rb
index 68d28ab9590..a5a9876319b 100644
--- a/modules/meeting/spec/support/pages/structured_meeting/show.rb
+++ b/modules/meeting/spec/support/pages/structured_meeting/show.rb
@@ -158,11 +158,11 @@ module Pages::StructuredMeeting
def open_participant_form
page.find_test_selector("manage-participants-button").click
- expect(page).to have_css("#meetings-sidebar-participants-form-component")
+ expect(page).to have_css("#edit-participants-dialog")
end
def in_participant_form(&)
- page.within("#meetings-sidebar-participants-form-component form", &)
+ page.within("#edit-participants-dialog form", &)
end
def expect_participant(participant, invited: false, attended: false, editable: true)