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

Fix error handling in meeting tab component

Oliver Günther8d95316d8a85
diff --git a/app/controllers/concerns/op_turbo/component_stream.rb b/app/controllers/concerns/op_turbo/component_stream.rb
index 625f98a978a..4c1836f9f4e 100644
--- a/app/controllers/concerns/op_turbo/component_stream.rb
+++ b/app/controllers/concerns/op_turbo/component_stream.rb
@@ -30,7 +30,7 @@ module OpTurbo
module ComponentStream
extend ActiveSupport::Concern
- def respond_to_with_turbo_streams(status: :ok, &format_block)
+ def respond_to_with_turbo_streams(status: turbo_status, &format_block)
respond_to do |format|
format.turbo_stream do
render turbo_stream: turbo_streams, status:
@@ -54,7 +54,7 @@ module OpTurbo
end
def modify_via_turbo_stream(component:, action:, status:)
- @status = status
+ @turbo_status = status
turbo_streams << component.render_as_turbo_stream(
view_context:,
action:
@@ -77,8 +77,8 @@ module OpTurbo
@turbo_streams ||= []
end
- def status
- @status ||= :ok
+ def turbo_status
+ @turbo_status ||= :ok
end
end
end
diff --git a/modules/meeting/app/components/meetings/sidebar/participants_dialog.html.erb b/modules/meeting/app/components/meetings/sidebar/participants_dialog.html.erb
index edf6fbe6dab..f77b0e67c6b 100644
--- a/modules/meeting/app/components/meetings/sidebar/participants_dialog.html.erb
+++ b/modules/meeting/app/components/meetings/sidebar/participants_dialog.html.erb
@@ -5,6 +5,7 @@
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(
@@ -15,98 +16,94 @@
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
+ 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
+ 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
+ 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
+ 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:,
+ user: participant.user,
classes: 'op-principal_flex'
))
end
-
- new_participant.with_column(style: "width: 90px;", text_align: :center) do
+ existing_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}",
+ 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
-
- new_participant.with_column(style: "width: 90px;", text_align: :center) do
+ existing_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}",
+ 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
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
index 76457f6103f..d4a98fb5435 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
@@ -4,25 +4,10 @@
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
+ render(WorkPackageMeetingsTab::AddWorkPackageToMeetingFormComponent.new(
+ work_package: @work_package,
+ meeting_agenda_item: @meeting_agenda_item
+ ))
end
d.with_footer do
component_collection do |buttons|
@@ -33,7 +18,10 @@
)) do
t("button_cancel")
end
- buttons.with_component(Primer::ButtonComponent.new(scheme: :primary, type: :submit)) do
+ buttons.with_component(Primer::ButtonComponent.new(
+ scheme: :primary,
+ form: "add-work-package-to-meeting-form",
+ type: :submit)) do
t("button_save")
end
end
diff --git a/modules/meeting/app/components/work_package_meetings_tab/add_work_package_to_meeting_dialog_component.rb b/modules/meeting/app/components/work_package_meetings_tab/add_work_package_to_meeting_dialog_component.rb
index ac8801102a3..49cd7944de7 100644
--- a/modules/meeting/app/components/work_package_meetings_tab/add_work_package_to_meeting_dialog_component.rb
+++ b/modules/meeting/app/components/work_package_meetings_tab/add_work_package_to_meeting_dialog_component.rb
@@ -32,12 +32,11 @@ module WorkPackageMeetingsTab
include OpTurbo::Streamable
include OpPrimer::ComponentHelpers
- def initialize(work_package:, meeting_agenda_item: nil, base_errors: nil)
+ def initialize(work_package:, meeting_agenda_item: nil)
super
@work_package = work_package
@meeting_agenda_item = meeting_agenda_item || MeetingAgendaItem.new(work_package: @work_package)
- @base_errors = base_errors
end
end
end
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
new file mode 100644
index 00000000000..0b736b31f17
--- /dev/null
+++ b/modules/meeting/app/components/work_package_meetings_tab/add_work_package_to_meeting_form_component.html.erb
@@ -0,0 +1,24 @@
+<%=
+ component_wrapper do
+ primer_form_with(
+ id: "add-work-package-to-meeting-form",
+ 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
+%>
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_form_component.rb
new file mode 100644
index 00000000000..ece92b57d75
--- /dev/null
+++ b/modules/meeting/app/components/work_package_meetings_tab/add_work_package_to_meeting_form_component.rb
@@ -0,0 +1,43 @@
+#-- 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 WorkPackageMeetingsTab
+ class AddWorkPackageToMeetingFormComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpTurbo::Streamable
+ include OpPrimer::ComponentHelpers
+
+ def initialize(work_package:, meeting_agenda_item: nil, base_errors: nil)
+ super
+
+ @work_package = work_package
+ @meeting_agenda_item = meeting_agenda_item || MeetingAgendaItem.new(work_package: @work_package)
+ @base_errors = base_errors
+ end
+ end
+end
diff --git a/modules/meeting/app/controllers/concerns/meetings/work_package_meetings_tab_component_streams.rb b/modules/meeting/app/controllers/concerns/meetings/work_package_meetings_tab_component_streams.rb
index 750b676b4f8..eb3498f2ffe 100644
--- a/modules/meeting/app/controllers/concerns/meetings/work_package_meetings_tab_component_streams.rb
+++ b/modules/meeting/app/controllers/concerns/meetings/work_package_meetings_tab_component_streams.rb
@@ -47,7 +47,7 @@ module Meetings
work_package:,
base_errors:
),
- status: base_errors.blank? && meeting_agenda_item.errors.blank? ? :ok : :bad_request
+ status: :bad_request
)
end
diff --git a/modules/meeting/spec/features/structured_meetings/work_package_meetings_tab_spec.rb b/modules/meeting/spec/features/structured_meetings/work_package_meetings_tab_spec.rb
index 0b7f7926dca..81803223bff 100644
--- a/modules/meeting/spec/features/structured_meetings/work_package_meetings_tab_spec.rb
+++ b/modules/meeting/spec/features/structured_meetings/work_package_meetings_tab_spec.rb
@@ -279,19 +279,16 @@ RSpec.describe "Open the Meetings tab", :js do
end
context "when user is allowed to edit meetings" do
- it "shows the add to meeting button" do
+ it "shows the add to meeting button and dialog" do
work_package_page.visit!
switch_to_meetings_tab
meetings_tab.expect_add_to_meeting_button_present
- end
- it "opens the add to meeting dialog when clicking the add to meeting button" do
work_package_page.visit!
switch_to_meetings_tab
meetings_tab.open_add_to_meeting_dialog
-
meetings_tab.expect_add_to_meeting_dialog_shown
end
diff --git a/modules/meeting/spec/support/pages/structured_meeting/mobile/show.rb b/modules/meeting/spec/support/pages/structured_meeting/mobile/show.rb
index 4455dd0dd0a..20e63fdbf44 100644
--- a/modules/meeting/spec/support/pages/structured_meeting/mobile/show.rb
+++ b/modules/meeting/spec/support/pages/structured_meeting/mobile/show.rb
@@ -33,15 +33,15 @@ module Pages::StructuredMeeting::Mobile
def expect_participants(count: 1)
within(meeting_details_container) do
expect(page).to have_text(Meeting.human_attribute_name(:participant, count:))
- expect(page).to have_button("Show all")
+ expect(page).to have_link("Show all")
end
end
def open_participant_form
within(meeting_details_container) do
- click_on "Show all"
+ click_link_or_button "Show all"
end
- expect(page).to have_css("#meetings-sidebar-participants-form-component")
+ expect(page).to have_css("#edit-participants-dialog")
end
end
end
diff --git a/modules/meeting/spec/support/pages/structured_meeting/show.rb b/modules/meeting/spec/support/pages/structured_meeting/show.rb
index a5a9876319b..8b3b2a6ae18 100644
--- a/modules/meeting/spec/support/pages/structured_meeting/show.rb
+++ b/modules/meeting/spec/support/pages/structured_meeting/show.rb
@@ -162,7 +162,7 @@ module Pages::StructuredMeeting
end
def in_participant_form(&)
- page.within("#edit-participants-dialog form", &)
+ page.within("#edit-participants-dialog", &)
end
def expect_participant(participant, invited: false, attended: false, editable: true)
diff --git a/modules/meeting/spec/support/pages/work_package_meetings_tab.rb b/modules/meeting/spec/support/pages/work_package_meetings_tab.rb
index 37c95e8339b..5e71e4928a8 100644
--- a/modules/meeting/spec/support/pages/work_package_meetings_tab.rb
+++ b/modules/meeting/spec/support/pages/work_package_meetings_tab.rb
@@ -79,7 +79,7 @@ module Pages
end
def expect_add_to_meeting_dialog_shown
- expect(page).to have_test_selector("op-add-work-package-to-meeting-dialog-body")
+ expect(page).to have_css("#add-work-package-to-meeting-dialog")
end
def switch_to_upcoming_meetings_section