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
Rework participants components
Mir Bhatia74dafecb0ec3
diff --git a/modules/meeting/app/components/_index.sass b/modules/meeting/app/components/_index.sassindex 4a6c5017df5..725ead5b82f 100644--- a/modules/meeting/app/components/_index.sass+++ b/modules/meeting/app/components/_index.sass@@ -6,3 +6,4 @@@import "./recurring_meetings/table_header_component.sass"@import "./meeting_agenda_items/outcomes/show_notes_component.sass"@import "./meetings/header_infoline_component.sass"+@import "./meetings/side_panel/participants/add_user_form_component.sass"diff --git a/modules/meeting/app/components/meetings/side_panel/details_component.html.erb b/modules/meeting/app/components/meetings/side_panel/details_component.html.erbindex 1d364351994..9cd9b9d5de4 100644--- a/modules/meeting/app/components/meetings/side_panel/details_component.html.erb+++ b/modules/meeting/app/components/meetings/side_panel/details_component.html.erb@@ -142,7 +142,7 @@scheme: :link,underline: false,tag: :a,- href: participants_dialog_project_meeting_path(@project, @meeting),+ href: manage_participants_dialog_meeting_participants_path(@meeting),classes: "hide-when-print",data: { controller: "async-dialog" })diff --git a/modules/meeting/app/components/meetings/side_panel/participants/add_user_form_component.html.erb b/modules/meeting/app/components/meetings/side_panel/participants/add_user_form_component.html.erbnew file mode 100644index 00000000000..720c102d886--- /dev/null+++ b/modules/meeting/app/components/meetings/side_panel/participants/add_user_form_component.html.erb@@ -0,0 +1,20 @@+<%=+ component_wrapper do+ primer_form_with(+ model: MeetingParticipant.new(meeting: @meeting),+ url: meeting_participants_path(@meeting)+ ) do |form|+ grid_layout("meeting-participant-form", tag: :div) do |grid|+ grid.with_area(:participant) do+ render(Meeting::Participant.new(form))+ end++ grid.with_area(:submit) do+ render(Primer::Beta::Button.new(scheme: :primary, type: :submit)) do+ I18n.t(:button_add)+ end+ end+ end+ end+ end+%>diff --git a/modules/meeting/app/components/meetings/side_panel/participants/add_user_form_component.rb b/modules/meeting/app/components/meetings/side_panel/participants/add_user_form_component.rbnew file mode 100644index 00000000000..7e1ea9f7494--- /dev/null+++ b/modules/meeting/app/components/meetings/side_panel/participants/add_user_form_component.rb@@ -0,0 +1,44 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 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 Meetings+ class SidePanel::Participants::AddUserFormComponent < ApplicationComponent+ include ApplicationHelper+ include OpenProject::FormTagHelper+ include OpTurbo::Streamable+ include OpPrimer::ComponentHelpers++ def initialize(meeting:)+ super++ @meeting = meeting+ end+ end+enddiff --git a/modules/meeting/app/components/meetings/side_panel/participants/add_user_form_component.sass b/modules/meeting/app/components/meetings/side_panel/participants/add_user_form_component.sassnew file mode 100644index 00000000000..b619fa68305--- /dev/null+++ b/modules/meeting/app/components/meetings/side_panel/participants/add_user_form_component.sass@@ -0,0 +1,5 @@+.meeting-participant-form+ display: grid+ grid-template-columns: 1fr auto+ grid-template-areas: "participant submit"+ grid-column-gap: 0.5remdiff --git a/modules/meeting/app/components/meetings/side_panel/participants/attended_toggle_button_component.rb b/modules/meeting/app/components/meetings/side_panel/participants/attended_toggle_button_component.rbnew file mode 100644index 00000000000..82a79171877--- /dev/null+++ b/modules/meeting/app/components/meetings/side_panel/participants/attended_toggle_button_component.rb@@ -0,0 +1,70 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 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 Meetings+ class SidePanel::Participants::AttendedToggleButtonComponent < ApplicationComponent+ include ApplicationHelper+ include OpenProject::FormTagHelper+ include OpTurbo::Streamable+ include OpPrimer::ComponentHelpers++ def initialize(meeting:, participant:)+ super++ @meeting = meeting+ @participant = participant+ # binding.pry+ end++ def call+ render(+ Primer::Beta::Button.new(+ tag: :a,+ href: toggle_attendance_meeting_participant_path(@meeting, @participant),+ data: { turbo_method: :post },+ align_self: :center+ )+ ) do |button|+ button.with_leading_visual_icon(icon:)+ label+ end+ end++ private++ def icon+ @participant.attended? ? :check : "op-person-assigned"+ end++ def label+ @participant.attended? ? "Attended" : "Mark as attended"+ end+ end+enddiff --git a/modules/meeting/app/components/meetings/side_panel/participants/list_component.html.erb b/modules/meeting/app/components/meetings/side_panel/participants/list_component.html.erbnew file mode 100644index 00000000000..0c622e7ee3a--- /dev/null+++ b/modules/meeting/app/components/meetings/side_panel/participants/list_component.html.erb@@ -0,0 +1,92 @@+<%=+ component_wrapper do+ render(border_box_container) do |box|+ box.with_header(color: :muted) do+ flex_layout(align_items: :center, justify_content: :space_between) do |flex|+ flex.with_column do+ flex_layout(align_items: :center) do |participants|+ participants.with_column do+ render(Primer::Beta::Text.new(font_weight: :bold)) { "Participants" }+ end+ participants.with_column(ml: 2) do+ render(Primer::Beta::Counter.new(count: @meeting.invited_participants.count, round: true, scheme: :primary))+ end+ end+ end+ if show_mark_all_attended?+ flex.with_column do+ render(+ Primer::Beta::Button.new(+ tag: :a,+ href: mark_all_attended_meeting_participants_path(@meeting),+ align_self: :center,+ data: { "turbo-method": :post }+ )+ ) do |button|+ button.with_leading_visual_icon(icon: :"op-person-assigned")+ "Mark all as attended"+ end+ end+ end+ end+ end++ if @meeting.invited_participants.none?+ box.with_row do+ render(Primer::Beta::Blankslate.new) do |blankslate|+ blankslate.with_visual_icon(icon: :people, size: :medium)+ blankslate.with_heading(tag: :h2).with_content("No participants")+ blankslate.with_description do+ flex_layout do |flex|+ flex.with_row(mb: 2) do+ render(Primer::Beta::Text.new(color: :subtle)) { "There are no participants yet." }+ end+ end+ end+ end+ end+ else+ render(Primer::BaseComponent.new(tag: :div, classes: "participants-list")) do+ @meeting.all_changeable_participants.sort.each do |user|+ if @meeting.participants.present? && participant = @meeting.participants.detect { |p| p.user_id == user.id }+ box.with_row do+ flex_layout(align_items: :center, justify_content: :space_between) do |row|+ row.with_column(flex: 1, classes: "ellipsis") do+ render(+ Users::AvatarComponent.new(+ user: participant.user,+ classes: "op-principal_flex",+ hover_card: { active: true, target: :custom }+ )+ )+ end+ row.with_column do+ flex_layout(align_items: :center, justify_content: :space_between) do |actions|+ if @meeting.in_progress?+ actions.with_column(ml: 2) do+ render(Meetings::SidePanel::Participants::AttendedToggleButtonComponent.new(meeting: @meeting, participant:))+ end+ end+ actions.with_column(ml: 2) do+ render(+ Primer::Beta::IconButton.new(+ scheme: :invisible,+ tag: :a,+ href: meeting_participant_path(@meeting, participant),+ data: { turbo_method: :delete },+ icon: :x,+ aria: { label: "Remove participant" }+ )+ )+ end+ end+ end+ end+ end+ end+ end+ end+ end+ end+ end+%>diff --git a/modules/meeting/app/components/meetings/side_panel/participants/list_component.rb b/modules/meeting/app/components/meetings/side_panel/participants/list_component.rbnew file mode 100644index 00000000000..f288b6c5ddc--- /dev/null+++ b/modules/meeting/app/components/meetings/side_panel/participants/list_component.rb@@ -0,0 +1,51 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 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 Meetings+ class SidePanel::Participants::ListComponent < ApplicationComponent+ include ApplicationHelper+ include OpenProject::FormTagHelper+ include OpTurbo::Streamable+ include OpPrimer::ComponentHelpers++ def initialize(meeting:)+ super++ @meeting = meeting+ # binding.pry+ end++ private++ def show_mark_all_attended?+ @meeting.participants.where(attended: true).count != @meeting.participants.count && @meeting.in_progress?+ end+ end+enddiff --git a/modules/meeting/app/components/meetings/side_panel/participants/manage_participants_dialog.html.erb b/modules/meeting/app/components/meetings/side_panel/participants/manage_participants_dialog.html.erbnew file mode 100644index 00000000000..41fbbffe5ca--- /dev/null+++ b/modules/meeting/app/components/meetings/side_panel/participants/manage_participants_dialog.html.erb@@ -0,0 +1,46 @@+<%=+ component_wrapper do+ render(+ Primer::Alpha::Dialog.new(+ id: "manage-participants-dialog",+ size: :large,+ title: "Manage participants",+ data: { "keep-open-on-submit": true }+ )+ ) do |d|+ d.with_header(variant: :large)++ d.with_body do+ flex_layout do |container|+ container.with_row(mb: 3) do+ render(Meetings::EmailUpdatesBannerComponent.new(@meeting))+ end++ container.with_row(mb: 3) do+ render(Primer::Beta::Text.new) { "Search for and add project members as participants to this meeting." }+ end++ container.with_row(mb: 3) do+ render(Meetings::SidePanel::Participants::AddUserFormComponent.new(meeting: @meeting))+ end++ container.with_row do+ render(Meetings::SidePanel::Participants::ListComponent.new(meeting: @meeting))+ end+ end+ end++ if @meeting.editable?+ d.with_footer do+ flex_layout do |footer|+ footer.with_row(mt: 3) do+ render(Primer::Beta::Button.new(data: { "close-dialog-id": "manage-participants-dialog" })) do+ t("button_cancel")+ end+ end+ end+ end+ end+ end+ end+%>diff --git a/modules/meeting/app/components/meetings/side_panel/participants_dialog.rb b/modules/meeting/app/components/meetings/side_panel/participants/manage_participants_dialog.rbsimilarity index 95%rename from modules/meeting/app/components/meetings/side_panel/participants_dialog.rbrename to modules/meeting/app/components/meetings/side_panel/participants/manage_participants_dialog.rbindex 74dfd3e9bc9..cd4b2a661fc 100644--- a/modules/meeting/app/components/meetings/side_panel/participants_dialog.rb+++ b/modules/meeting/app/components/meetings/side_panel/participants/manage_participants_dialog.rb@@ -1,4 +1,5 @@# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -28,7 +29,7 @@#++module Meetings- class SidePanel::ParticipantsDialog < ApplicationComponent+ class SidePanel::Participants::ManageParticipantsDialog < ApplicationComponentinclude ApplicationHelperinclude OpenProject::FormTagHelperinclude OpTurbo::Streamablediff --git a/modules/meeting/app/components/meetings/side_panel/participants_component.html.erb b/modules/meeting/app/components/meetings/side_panel/participants_component.html.erbindex dbdf3c35f82..8b83eb8bfe1 100644--- a/modules/meeting/app/components/meetings/side_panel/participants_component.html.erb+++ b/modules/meeting/app/components/meetings/side_panel/participants_component.html.erb@@ -2,7 +2,7 @@component_wrapper dorender(Primer::OpenProject::SidePanel::Section.new) do |section|section.with_title { Meeting.human_attribute_name(:participants) }- section.with_counter(count: @meeting.invited_or_attended_participants.count)+ section.with_counter(count: @meeting.invited_participants.count)if @meeting.templated?section.with_description { I18n.t("meeting.participants.template") }@@ -13,7 +13,7 @@icon: :gear,scheme: :invisible,tag: :a,- href: participants_dialog_project_meeting_path(@project, @meeting),+ href: manage_participants_dialog_meeting_participants_path(@meeting),classes: "hide-when-print",data: { controller: "async-dialog" },"aria-label": t("label_meeting_manage_participants"),@@ -40,13 +40,13 @@underline: false,font_weight: :bold,tag: :a,- href: participants_dialog_project_meeting_path(@project, @meeting),+ href: manage_participants_dialog_meeting_participants_path(@meeting),classes: "hide-when-print",data: { controller: "async-dialog" })) do |button|button.with_leading_visual_icon(icon: "person-add")- t("label_meeting_add_participants")+ "Manage participants"endendenddiff --git a/modules/meeting/app/components/meetings/side_panel/participants_component.rb b/modules/meeting/app/components/meetings/side_panel/participants_component.rbindex 8e34151fb9f..a3de2937897 100644--- a/modules/meeting/app/components/meetings/side_panel/participants_component.rb+++ b/modules/meeting/app/components/meetings/side_panel/participants_component.rb@@ -49,7 +49,7 @@ module Meetingsenddef elements- @elements ||= @meeting.invited_or_attended_participants.sort+ @elements ||= @meeting.invited_participants.sortenddef count@@ -72,10 +72,6 @@ module Meetingsflex.with_column(ml: 1) dorender(Primer::Beta::Text.new(font_size: :small, color: :subtle)) { t("description_attended").capitalize }end- elsif participant.invited?- flex.with_column(ml: 1) do- render(Primer::Beta::Text.new(font_size: :small, color: :subtle)) { t("description_invite").capitalize }- endendendenddiff --git a/modules/meeting/app/components/meetings/side_panel/participants_dialog.html.erb b/modules/meeting/app/components/meetings/side_panel/participants_dialog.html.erbdeleted file mode 100644index edd84fc7e5b..00000000000--- a/modules/meeting/app/components/meetings/side_panel/participants_dialog.html.erb+++ /dev/null@@ -1,159 +0,0 @@-<%=- 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_project_meeting_path(@project, @meeting),- data: { turbo: true, turbo_stream: true },- class: "Overlay-form"- ) do |_f|- flex_layout do |form_container|- form_container.with_row(mb: 3) do- render(Meetings::EmailUpdatesBannerComponent.new(@meeting))- end-- 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-- unless @meeting.template?- 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- 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",- hover_card: { active: true, target: :custom }- )- )- 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- unless @meeting.template?- 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- 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",- hover_card: { active: true, target: :custom }- )- )- 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-- unless @meeting.template?- 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-- form_container.with_row do- helpers.angular_component_tag "opce-custom-modal-overlay"- end- end- end- end- end-- if @meeting.editable?- d.with_footer do- component_collection do |footer|- footer.with_component(Primer::Beta::Button.new(data: { "close-dialog-id": "edit-participants-dialog" })) do- t("button_cancel")- end- footer.with_component(- Primer::Beta::Button.new(- scheme: :primary,- form: "edit_participants_form",- data: { turbo: true },- type: :submit- )- ) do- t("button_save")- end- end- end- end- end-%>diff --git a/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb b/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rbindex db38025a122..4d57b796927 100644--- a/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb+++ b/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb@@ -83,12 +83,15 @@ module Meetings)end- def update_sidebar_participants_form_component_via_turbo_stream(meeting: @meeting)+ def update_add_user_form_component_via_turbo_stream(meeting: @meeting)update_via_turbo_stream(- component: Meetings::SidePanel::ParticipantsFormComponent.new(- meeting:- ),- status: :bad_request # TODO: why bad_request?+ component: Meetings::SidePanel::Participants::AddUserFormComponent.new(meeting:)+ )+ end++ def update_list_component_via_turbo_stream(meeting: @meeting)+ update_via_turbo_stream(+ component: Meetings::SidePanel::Participants::ListComponent.new(meeting:))enddiff --git a/modules/meeting/app/controllers/meeting_participants_controller.rb b/modules/meeting/app/controllers/meeting_participants_controller.rbnew file mode 100644index 00000000000..2946fa8897f--- /dev/null+++ b/modules/meeting/app/controllers/meeting_participants_controller.rb@@ -0,0 +1,112 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 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.+#++++class MeetingParticipantsController < ApplicationController+ include OpTurbo::ComponentStream+ include Meetings::AgendaComponentStreams++ before_action :authorize+ before_action :set_meeting+ before_action :set_participant, only: %i[toggle_attendance destroy]++ def create+ user_id = params[:meeting_participant][:user_id]++ if MeetingParticipant.exists?(user_id: user_id, meeting_id: @meeting.id)+ update_add_user_form_component_via_turbo_stream+ update_list_component_via_turbo_stream++ respond_with_turbo_streams+ return+ end++ if MeetingParticipant.create(+ meeting: @meeting,+ user_id:,+ invited: true,+ attended: false+ )+ update_add_user_form_component_via_turbo_stream+ update_list_component_via_turbo_stream+ update_sidebar_participants_component_via_turbo_stream(meeting: @meeting)++ respond_with_turbo_streams+ else+ respond_with_flash_error(message: "Error!")+ end+ end++ def mark_all_attended+ @meeting.participants.each do |participant|+ participant.update!(attended: true)+ end++ update_add_user_form_component_via_turbo_stream+ update_list_component_via_turbo_stream+ update_sidebar_participants_component_via_turbo_stream(meeting: @meeting)++ respond_with_turbo_streams+ end++ def toggle_attendance+ @participant.toggle!(:attended)++ update_add_user_form_component_via_turbo_stream+ update_list_component_via_turbo_stream+ update_sidebar_participants_component_via_turbo_stream(meeting: @meeting)++ respond_with_turbo_streams+ end++ def destroy+ if @participant.destroy+ update_add_user_form_component_via_turbo_stream+ update_list_component_via_turbo_stream+ update_sidebar_participants_component_via_turbo_stream(meeting: @meeting)+ respond_with_turbo_streams+ else+ respond_with_flash_error(message: "Error!")+ end+ end++ def manage_participants_dialog+ respond_with_dialog Meetings::SidePanel::Participants::ManageParticipantsDialog.new(meeting: @meeting)+ end++ private++ def set_meeting+ @meeting = Meeting.find(params[:meeting_id])+ end++ def set_participant+ @participant = MeetingParticipant.find(params[:id])+ end+enddiff --git a/modules/meeting/app/controllers/meetings_controller.rb b/modules/meeting/app/controllers/meetings_controller.rbindex 15ef352a22f..320c965e0e4 100644--- a/modules/meeting/app/controllers/meetings_controller.rb+++ b/modules/meeting/app/controllers/meetings_controller.rb@@ -38,7 +38,7 @@ class MeetingsController < ApplicationControllerbefore_action :redirect_to_project, only: %i[show]before_action :set_activity, only: %i[history]before_action :find_copy_from_meeting, only: %i[create]- before_action :convert_params, only: %i[create update update_participants]+ before_action :convert_params, only: %i[create update]before_action :prevent_template_destruction, only: :destroyhelper :watchers@@ -239,18 +239,6 @@ class MeetingsController < ApplicationControllerdef details_dialog; end- def participants_dialog; end-- def update_participants- @meeting.participants_attributes = @converted_params.delete(:participants_attributes)- @meeting.save-- update_sidebar_details_component_via_turbo_stream- update_sidebar_participants_component_via_turbo_stream-- respond_with_turbo_streams- end-def update_title@meeting.update(title: meeting_params[:title])diff --git a/modules/meeting/app/forms/meeting/participant.rb b/modules/meeting/app/forms/meeting/participant.rbnew file mode 100644index 00000000000..5ebc11333fb--- /dev/null+++ b/modules/meeting/app/forms/meeting/participant.rb@@ -0,0 +1,70 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 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.+#++++class Meeting::Participant < ApplicationForm+ form do |participant_form|+ participant_form.autocompleter(+ name: :user_id,+ label: MeetingAgendaItem.human_attribute_name(:presenter),+ visually_hide_label: true,+ autocomplete_options: {+ defaultData: true,+ component: "opce-user-autocompleter",+ url: ::API::V3::Utilities::PathHelper::ApiV3Path.principals,+ filters:,+ searchKey: "any_name_attribute",+ resource: "principals",+ focusDirectly: false,+ multiple: false,+ isOpenedInModal: true,+ hoverCards: true,+ placeholder: I18n.t("activerecord.attributes.meeting_agenda_item.presenter")+ }+ )+ end++ private++ def excluded_ids+ @excluded_ids ||= @builder.object.meeting.invited_participants.filter_map(&:user_id)+ end++ def filters+ list = [+ { name: "type", operator: "=", values: %w[User Group] },+ { name: "member", operator: "=", values: [@builder.object.meeting.project_id] },+ { name: "status", operator: "=", values: [Principal.statuses[:active], Principal.statuses[:invited]] }+ ]++ list << { name: "id", operator: "!", values: excluded_ids } if excluded_ids.any?++ list+ end+enddiff --git a/modules/meeting/app/models/meeting.rb b/modules/meeting/app/models/meeting.rbindex 8bdc08b324e..b4ae17bc478 100644--- a/modules/meeting/app/models/meeting.rb+++ b/modules/meeting/app/models/meeting.rb@@ -193,6 +193,10 @@ class Meeting < ApplicationRecordendend+ def invited_participants+ participants.select(&:invited)+ end+def invited_or_attended_participantsparticipants.where(invited: true).or(participants.where(attended: true))end@@ -200,8 +204,6 @@ class Meeting < ApplicationRecorddef all_changeable_participantschangeable_participants = participants.select(&:invited).collect(&:user)changeable_participants = changeable_participants + participants.select(&:attended).collect(&:user)- changeable_participants = changeable_participants +- User.allowed_members(:view_meetings, project)changeable_participants.compactdiff --git a/modules/meeting/app/views/meetings/participants_dialog.turbo_stream.erb b/modules/meeting/app/views/meetings/participants_dialog.turbo_stream.erbdeleted file mode 100644index 18f531fde94..00000000000--- a/modules/meeting/app/views/meetings/participants_dialog.turbo_stream.erb+++ /dev/null@@ -1,5 +0,0 @@-<%=- turbo_stream.dialog do- render(Meetings::SidePanel::ParticipantsDialog.new(meeting: @meeting))- end-%>diff --git a/modules/meeting/config/routes.rb b/modules/meeting/config/routes.rbindex 24aad015748..76c56540691 100644--- a/modules/meeting/config/routes.rb+++ b/modules/meeting/config/routes.rb@@ -44,8 +44,6 @@ Rails.application.routes.draw doput :update_titleget :details_dialogput :update_details- get :participants_dialog- put :update_participantsput :change_statepost :notifyget :history@@ -136,6 +134,15 @@ Rails.application.routes.draw doget :cancel_editendend+ resources :participants, controller: "meeting_participants" do+ collection do+ get :manage_participants_dialog+ post :mark_all_attended+ end+ member do+ post :toggle_attendance+ end+ endresource :agenda, controller: "meeting_agendas", only: [:update] domember dodiff --git a/modules/meeting/lib/open_project/meeting/engine.rb b/modules/meeting/lib/open_project/meeting/engine.rbindex 0c9c54f6b5e..99859f34149 100644--- a/modules/meeting/lib/open_project/meeting/engine.rb+++ b/modules/meeting/lib/open_project/meeting/engine.rb@@ -43,7 +43,7 @@ module OpenProject::Meetingproject_module :meetings dopermission :view_meetings,{- meetings: %i[index show check_for_updates download_ics participants_dialog+ meetings: %i[index show check_for_updates download_icsgenerate_pdf_dialog history],"meetings/menus": %i[show],work_package_meetings_tab: %i[index count],@@ -63,10 +63,11 @@ module OpenProject::Meetingpermission :edit_meetings,{meetings: %i[edit cancel_edit update update_title change_state toggle_notifications_dialog- details_dialog update_details update_participants toggle_notifications],+ details_dialog update_details toggle_notifications],recurring_meetings: %i[edit cancel_edit update update_title details_dialog update_detailsnotify end_series end_series_dialog],- work_package_meetings_tab: %i[add_work_package_to_meeting_dialog add_work_package_to_meeting]+ work_package_meetings_tab: %i[add_work_package_to_meeting_dialog add_work_package_to_meeting],+ meeting_participants: %i[create destroy mark_all_attended toggle_attendance manage_participants_dialog]},permissible_on: :project,require: :member