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
Extract view logic into separate files
Henriette Dargeaaeee67433c7
diff --git a/modules/meeting/app/components/meetings/header_component.html.erb b/modules/meeting/app/components/meetings/header_component.html.erbnew file mode 100644index 00000000000..32083ed3012--- /dev/null+++ b/modules/meeting/app/components/meetings/header_component.html.erb@@ -0,0 +1,118 @@+<%=+ component_wrapper do+ case @state+ when :show+ flex_layout do |show_header|+ show_header.with_row do+ flex_layout(justify_content: :space_between, align_items: :center) do |title|+ title.with_column(flex: 1) do+ render(Primer::Beta::Heading.new(tag: :h1)) { @meeting.title }+ end++ title.with_column do+ render(Primer::Alpha::ActionMenu.new) do |menu|+ menu.with_show_button(icon: "kebab-horizontal", 'aria-label': t("label_meeting_actions"), test_selector: 'op-meetings-header-action-trigger')++ menu.with_item(label: t("label_meeting_edit_title"),+ href: edit_meeting_path(@meeting),+ content_arguments: {+ data: { 'turbo-stream': true }+ }) do |item|+ item.with_leading_visual_icon(icon: :pencil)+ end if @meeting.editable?++ menu.with_item(label: t(:label_icalendar_download),+ href: download_ics_meeting_path(@meeting)) do |item|+ item.with_leading_visual_icon(icon: :download)+ end++ menu.with_item(label: t("label_meeting_delete"),+ scheme: :danger,+ href: meeting_path(@meeting),+ form_arguments: {+ method: :delete, data: { confirm: t("text_are_you_sure"), turbo: 'false' }+ }) do |item|+ item.with_leading_visual_icon(icon: :trash)+ end if delete_enabled?+ end+ end+ end+ end++ show_header.with_row do+ flex_layout(align_items: :center) do |meta_info|+ meta_info.with_column(mr: 1) do+ render(Primer::Beta::Text.new(font_size: :small, color: :subtle)) { t("label_meeting_created_by") }+ end++ meta_info.with_column(mr: 1) do+ render_author_link+ end++ meta_info.with_column(mr: 1) do+ render(Primer::Beta::Text.new(font_size: :small, color: :subtle)) { t("label_meeting_last_updated") }+ end++ meta_info.with_column do+ render(Primer::Beta::RelativeTime.new(font_size: :small, color: :subtle, datetime: last_updated_at))+ end+ end+ end+ end++ when :edit+ if @meeting.editable?+ flex_layout do |edit_header|+ edit_header.with_row(mb: 2) do+ primer_form_with(+ model: @meeting,+ method: :put,+ url: update_title_meeting_path(@meeting)+ ) do |f|+ flex_layout do |editable_title_form|+ editable_title_form.with_column(flex: 1, mr: 2) do+ render(Meeting::Title.new(f))+ end++ editable_title_form.with_column(mr: 2) do+ render(Meeting::Submit.new(f))+ end++ editable_title_form.with_column do+ render(Primer::Beta::Button.new(+ scheme: :secondary,+ tag: :a,+ href: cancel_edit_meeting_path(@meeting),+ data: { 'turbo-stream': true }+ )) do |_c|+ t("button_cancel")+ end+ end+ end+ end+ end++ edit_header.with_row do+ flex_layout(align_items: :center) do |meta_info|+ meta_info.with_column(mr: 1) do+ render(Primer::Beta::Text.new(font_size: :small, color: :subtle)) { t("label_meeting_created_by") }+ end++ meta_info.with_column(mr: 1) do+ render_author_link+ end++ meta_info.with_column(mr: 1) do+ render(Primer::Beta::Text.new(font_size: :small, color: :subtle)) { t("label_meeting_last_updated") }+ end++ meta_info.with_column do+ render(Primer::Beta::RelativeTime.new(font_size: :small, color: :subtle, datetime: last_updated_at))+ end+ end+ end+ end+ end+ end+ end+%>diff --git a/modules/meeting/app/components/meetings/header_component.rb b/modules/meeting/app/components/meetings/header_component.rbindex 7c350c9fc20..9326e83ce02 100644--- a/modules/meeting/app/components/meetings/header_component.rb+++ b/modules/meeting/app/components/meetings/header_component.rb@@ -39,110 +39,19 @@ module Meetings@state = stateend- def call- component_wrapper do- case @state- when :show- show_partial- when :edit- edit_partial if @meeting.editable?- end- end- end-private- def delete_enabled?- User.current.allowed_to?(:delete_meetings, @meeting.project)- end-- def show_partial- flex_layout do |flex|- flex.with_row do- title_and_actions_partial- end- flex.with_row do- meta_info_partial- end- end- end-- def title_and_actions_partial- flex_layout(justify_content: :space_between, align_items: :center) do |flex|- flex.with_column(flex: 1) do- title_partial- end- flex.with_column do- actions_partial- end- end- end-- def title_partial- render(Primer::Beta::Heading.new(tag: :h1)) { @meeting.title }- end-- def actions_partial- render(Primer::Alpha::ActionMenu.new) do |menu|- menu.with_show_button(icon: "kebab-horizontal", 'aria-label': t("label_meeting_actions"), test_selector: 'op-meetings-header-action-trigger')- edit_action_item(menu) if @meeting.editable?- download_ics_item(menu)- delete_action_item(menu) if delete_enabled?- end- end-- def edit_action_item(menu)- menu.with_item(label: t("label_meeting_edit_title"),- href: edit_meeting_path(@meeting),- content_arguments: {- data: { 'turbo-stream': true }- }) do |item|- item.with_leading_visual_icon(icon: :pencil)- end- end-- def download_ics_item(menu)- menu.with_item(label: t(:label_icalendar_download),- href: download_ics_meeting_path(@meeting)) do |item|- item.with_leading_visual_icon(icon: :download)- end- end-- def delete_action_item(menu)- menu.with_item(label: t("label_meeting_delete"),- scheme: :danger,- href: meeting_path(@meeting),- form_arguments: {- method: :delete, data: { confirm: t("text_are_you_sure"), turbo: 'false' }- }) do |item|- item.with_leading_visual_icon(icon: :trash)- end- end-- def meta_info_partial- flex_layout(align_items: :center) do |flex|- flex.with_column(mr: 1) do- render(Primer::Beta::Text.new(font_size: :small, color: :subtle)) { t("label_meeting_created_by") }- end- flex.with_column(mr: 1) do- author_link_partial- end- flex.with_column(mr: 1) do- render(Primer::Beta::Text.new(font_size: :small, color: :subtle)) { t("label_meeting_last_updated") }- end- flex.with_column do- render(Primer::Beta::RelativeTime.new(font_size: :small, color: :subtle, datetime: last_updated_at))- end- end- end-- def author_link_partial+ def render_author_linkrender(Primer::Beta::Link.new(font_size: :small, href: user_path(@meeting.author), underline: false,target: "_blank")) do"#{@meeting.author.name}."endend+ def delete_enabled?+ User.current.allowed_to?(:delete_meetings, @meeting.project)+ end+def last_updated_atlatest_agenda_update = @meeting.agenda_items.maximum(:updated_at) || @meeting.updated_atlatest_meeting_update = @meeting.updated_at@@ -150,50 +59,5 @@ module Meetings[latest_agenda_update, latest_meeting_update].maxend- def edit_partial- flex_layout do |flex|- flex.with_row(mb: 2) do- title_form_partial- end- flex.with_row do- meta_info_partial- end- end- end-- def title_form_partial- primer_form_with(- model: @meeting,- method: :put,- url: update_title_meeting_path(@meeting)- ) do |f|- form_content_partial(f)- end- end-- def form_content_partial(form)- flex_layout do |flex|- flex.with_column(flex: 1, mr: 2) do- render(Meeting::Title.new(form))- end- flex.with_column(mr: 2) do- render(Meeting::Submit.new(form))- end- flex.with_column do- back_link_partial- end- end- end-- def back_link_partial- render(Primer::Beta::Button.new(- scheme: :secondary,- tag: :a,- href: cancel_edit_meeting_path(@meeting),- data: { 'turbo-stream': true }- )) do |_c|- t("button_cancel")- end- endendenddiff --git a/modules/meeting/app/components/meetings/show_component.html.erb b/modules/meeting/app/components/meetings/show_component.html.erbnew file mode 100644index 00000000000..58be44ff7e9--- /dev/null+++ b/modules/meeting/app/components/meetings/show_component.html.erb@@ -0,0 +1,34 @@+<%=+ flex_layout(data: { turbo: true }) do |show_page|+ show_page.with_row do+ # prototyical usage of Primer's flash message component wrapped in a component which can be updated via turbo stream+ # empty initially+ # should become part of the application layout once finalized+ render(FlashMessageComponent.new)+ end++ show_page.with_row(mt: 2, mb: 3, pb: 2, border: :bottom) do+ render(Meetings::HeaderComponent.new(meeting: @meeting))+ end++ show_page.with_row do+ render(Primer::Alpha::Layout.new(stacking_breakpoint: :lg)) do |content|+ content.with_main do+ flex_layout do |agenda|+ agenda.with_row do+ render(MeetingAgendaItems::ListComponent.new(meeting: @meeting))+ end++ agenda.with_row do+ render(MeetingAgendaItems::NewButtonComponent.new(meeting: @meeting))+ end+ end+ end++ content.with_sidebar(row_placement: :end, col_placement: :end, width: :wide) do+ render(Meetings::SidebarComponent.new(meeting: @meeting))+ end+ end+ end+ end+%>diff --git a/modules/meeting/app/components/meetings/show_component.rb b/modules/meeting/app/components/meetings/show_component.rbindex 9d2cd397975..074acb0493f 100644--- a/modules/meeting/app/components/meetings/show_component.rb+++ b/modules/meeting/app/components/meetings/show_component.rb@@ -36,50 +36,5 @@ module Meetings@meeting = meetingend-- def call- flex_layout(data: { turbo: true }) do |flex|- flex.with_row do- # prototyical usage of Primer's flash message component wrapped in a component which can be updated via turbo stream- # empty initially- # should become part of the application layout once finalized- render(FlashMessageComponent.new)- end- flex.with_row(mt: 2, mb: 3, pb: 2, border: :bottom) do- heading_partial- end- flex.with_row do- main_content_partial- end- end- end-- private-- def heading_partial- render(Meetings::HeaderComponent.new(meeting: @meeting))- end-- def main_content_partial- render(Primer::Alpha::Layout.new(stacking_breakpoint: :lg)) do |component|- component.with_main { agenda_partial }- component.with_sidebar(row_placement: :end, col_placement: :end, width: :wide) { sidebar_partial }- end- end-- def agenda_partial- flex_layout do |flex|- flex.with_row do- render(MeetingAgendaItems::ListComponent.new(meeting: @meeting))- end- flex.with_row do- render(MeetingAgendaItems::NewButtonComponent.new(meeting: @meeting))- end- end- end-- def sidebar_partial- render(Meetings::SidebarComponent.new(meeting: @meeting))- endendenddiff --git a/modules/meeting/app/components/meetings/sidebar/details_component.html.erb b/modules/meeting/app/components/meetings/sidebar/details_component.html.erbnew file mode 100644index 00000000000..5947b2611c7--- /dev/null+++ b/modules/meeting/app/components/meetings/sidebar/details_component.html.erb@@ -0,0 +1,93 @@+<%=+ component_wrapper do+ flex_layout do |details_container|+ details_container.with_row do+ flex_layout(align_items: :center, justify_content: :space_between) do |heading|+ heading.with_column(flex: 1) do+ render(Primer::Beta::Heading.new(tag: :h4)) { t("label_meeting_details") }+ end++ if @meeting.editable?+ heading.with_column do+ render(Primer::Alpha::Dialog.new(+ id: "edit-meeting-details-dialog", title: t("label_meeting_details"),+ size: :medium_portrait+ )) do |dialog|+ dialog.with_show_button(icon: :pencil, 'aria-label': t("label_meeting_details_edit"), scheme: :invisible)+ render(Meetings::Sidebar::DetailsFormComponent.new(meeting: @meeting))+ end+ end+ end+ end+ end++ details_container.with_row(mt: 2) do+ flex_layout do |details|+ details.with_row do+ render_meeting_attribute_row(:calendar) do+ render(Primer::Beta::Text.new) do+ format_date(@meeting.start_time)+ end+ end+ end++ details.with_row(mt: 2) do+ render_meeting_attribute_row(:clock) do+ flex_layout(align_items: :center) do |time|+ time.with_column do+ render(Primer::Beta::Text.new) do+ "#{format_time(@meeting.start_time, false)} - #{format_time(@meeting.end_time, false)}"+ end+ end++ time.with_column(ml: 2) do+ render(Primer::Beta::Text.new(color: :subtle, font_size: :small)) do+ Time.zone.to_s[/\((.*?)\)/m, 1]+ end+ end+ end+ end+ end++ details.with_row(mt: 2) do+ render_meeting_attribute_row(:stopwatch) do+ flex_layout do |duration|+ duration.with_column do+ render OpenProject::Common::DurationComponent.new(@meeting.duration, :hours, abbreviated: true)+ end++ if @meeting.duration_exceeded_by_agenda_items? do+ duration.with_column(ml: 2) do+ render(Primer::Beta::Text.new(color: :danger, font_size: :small)) do+ "+ #{I18n.t('datetime.distance_in_words.x_minutes_abbreviated',+ count: @meeting.duration_exceeded_by_agenda_items_in_minutes.to_i)}"+ end+ end+ end+ end+ end+ end++ if @meeting.location.present?+ details.with_row(mt: 2) do+ if @meeting.location.include?("http")+ render_meeting_attribute_row(:link) do+ render(Primer::Beta::Link.new(href: @meeting.location, target: "_blank")) do+ render_truncated_location+ end+ end+ else+ render_meeting_attribute_row(:location) do+ render(Primer::Beta::Text.new) do+ render_truncated_location+ end+ end+ end+ end+ end+ end+ end+ end+ end+ end+%>diff --git a/modules/meeting/app/components/meetings/sidebar/details_component.rb b/modules/meeting/app/components/meetings/sidebar/details_component.rbindex 78fee2fae07..53f046d1d1b 100644--- a/modules/meeting/app/components/meetings/sidebar/details_component.rb+++ b/modules/meeting/app/components/meetings/sidebar/details_component.rb@@ -38,121 +38,9 @@ module Meetings@meeting = meetingend- def call- component_wrapper do- flex_layout do |flex|- flex.with_row do- heading_partial- end- flex.with_row(mt: 2) do- details_partial- end- end- end- end-private- def heading_partial- flex_layout(align_items: :center, justify_content: :space_between) do |flex|- flex.with_column(flex: 1) do- render(Primer::Beta::Heading.new(tag: :h4)) { t("label_meeting_details") }- end- if @meeting.editable?- flex.with_column do- dialog_wrapper_partial- end- end- end- end-- def dialog_wrapper_partial- render(Primer::Alpha::Dialog.new(- id: "edit-meeting-details-dialog", title: t("label_meeting_details"),- size: :medium_portrait- )) do |dialog|- dialog.with_show_button(icon: :pencil, 'aria-label': t("label_meeting_details_edit"), scheme: :invisible)- render(Meetings::Sidebar::DetailsFormComponent.new(meeting: @meeting))- end- end-- def details_partial- flex_layout do |flex|- flex.with_row do- date_partial- end- flex.with_row(mt: 2) do- time_partial- end- flex.with_row(mt: 2) do- duration_partial- end- if @meeting.location.present?- flex.with_row(mt: 2) do- location_partial- end- end- end- end-- def date_partial- meeting_attribute_row(:calendar) do- render(Primer::Beta::Text.new) do- format_date(@meeting.start_time)- end- end- end-- def time_partial- meeting_attribute_row(:clock) do- flex_layout(align_items: :center) do |flex|- flex.with_column do- render(Primer::Beta::Text.new) do- "#{format_time(@meeting.start_time, false)} - #{format_time(@meeting.end_time, false)}"- end- end- flex.with_column(ml: 2) do- render(Primer::Beta::Text.new(color: :subtle, font_size: :small)) do- Time.zone.to_s[/\((.*?)\)/m, 1]- end- end- end- end- end-- def duration_partial- meeting_attribute_row(:stopwatch) do- flex_layout do |flex|- flex.with_column do- render OpenProject::Common::DurationComponent.new(@meeting.duration, :hours, abbreviated: true)- end- flex.with_column(ml: 2) do- render(Primer::Beta::Text.new(color: :danger, font_size: :small)) do- "+ #{I18n.t('datetime.distance_in_words.x_minutes_abbreviated',- count: @meeting.duration_exceeded_by_agenda_items_in_minutes.to_i)}"- end- end if @meeting.duration_exceeded_by_agenda_items?- end- end- end-- def location_partial- if @meeting.location.include?("http")- meeting_attribute_row(:link) do- render(Primer::Beta::Link.new(href: @meeting.location, target: "_blank")) do- truncated_location- end- end- else- meeting_attribute_row(:location) do- render(Primer::Beta::Text.new) do- truncated_location- end- end- end- end-- def truncated_location+ def render_truncated_locationrender(Primer::Beta::Truncate.new) do |component|component.with_item(max_width: 250) do@meeting.location@@ -160,11 +48,12 @@ module Meetingsendend- def meeting_attribute_row(icon, &)+ def render_meeting_attribute_row(icon, &)flex_layout(align_items: :center, justify_content: :space_between) do |flex|flex.with_column dorender(Primer::Beta::Octicon.new(icon:))end+flex.with_column(flex: 1, ml: 1, &)endenddiff --git a/modules/meeting/app/components/meetings/sidebar/details_form_component.html.erb b/modules/meeting/app/components/meetings/sidebar/details_form_component.html.erbnew file mode 100644index 00000000000..b5271d00ac8--- /dev/null+++ b/modules/meeting/app/components/meetings/sidebar/details_form_component.html.erb@@ -0,0 +1,43 @@+<%=+ component_wrapper do+ primer_form_with(+ model: @meeting,+ method: :put,+ url: update_details_meeting_path(@meeting)+ ) do |f|+ component_collection do |collection|+ collection.with_component(Primer::Alpha::Dialog::Body.new) do+ flex_layout(my: 3) do |modal_body|+ modal_body.with_row do+ render(Meeting::StartDate.new(f, initial_value: start_date_initial_value))+ end++ modal_body.with_row(mt: 3) do+ render(Meeting::StartTime.new(f, initial_value: start_time_initial_value))+ end++ modal_body.with_row(mt: 3) do+ render(Meeting::Duration.new(f))+ end++ modal_body.with_row(mt: 3) do+ render(Meeting::Location.new(f))+ end+ end+ end++ collection.with_component(Primer::Alpha::Dialog::Footer.new) do+ component_collection do |modal_footer|+ modal_footer.with_component(Primer::ButtonComponent.new(data: { 'close-dialog-id': "edit-meeting-details-dialog" })) do+ t("button_cancel")+ end++ modal_footer.with_component(Primer::ButtonComponent.new(scheme: :primary, type: :submit)) do+ t("button_save")+ end+ end+ end+ end+ end+ end+%>diff --git a/modules/meeting/app/components/meetings/sidebar/details_form_component.rb b/modules/meeting/app/components/meetings/sidebar/details_form_component.rbindex 50771b99943..9f42e53fe39 100644--- a/modules/meeting/app/components/meetings/sidebar/details_form_component.rb+++ b/modules/meeting/app/components/meetings/sidebar/details_form_component.rb@@ -38,48 +38,12 @@ module Meetings@meeting = meetingend- def call- component_wrapper do- primer_form_with(- model: @meeting,- method: :put,- url: update_details_meeting_path(@meeting)- ) do |f|- component_collection do |collection|- collection.with_component(Primer::Alpha::Dialog::Body.new) do- form_content_partial(f)- end- collection.with_component(Primer::Alpha::Dialog::Footer.new) do- form_actions_partial- end- end- end- end- end-def render?User.current.allowed_to?(:edit_meetings, @meeting.project)endprivate- def form_content_partial(form)- flex_layout(my: 3) do |flex|- flex.with_row do- render(Meeting::StartDate.new(form, initial_value: start_date_initial_value))- end- flex.with_row(mt: 3) do- render(Meeting::StartTime.new(form, initial_value: start_time_initial_value))- end- flex.with_row(mt: 3) do- render(Meeting::Duration.new(form))- end- flex.with_row(mt: 3) do- render(Meeting::Location.new(form))- end- end- end-def start_date_initial_value@meeting.start_time&.strftime("%Y-%m-%d")end@@ -88,15 +52,5 @@ module Meetings@meeting.start_time&.strftime("%H:%M")end- def form_actions_partial- component_collection do |collection|- collection.with_component(Primer::ButtonComponent.new(data: { 'close-dialog-id': "edit-meeting-details-dialog" })) do- t("button_cancel")- end- collection.with_component(Primer::ButtonComponent.new(scheme: :primary, type: :submit)) do- t("button_save")- end- end- endendenddiff --git a/modules/meeting/app/components/meetings/sidebar/participants_component.html.erb b/modules/meeting/app/components/meetings/sidebar/participants_component.html.erbnew file mode 100644index 00000000000..924754b62f4--- /dev/null+++ b/modules/meeting/app/components/meetings/sidebar/participants_component.html.erb@@ -0,0 +1,95 @@+<%=+ component_wrapper do+ flex_layout do |participants_container|+ participants_container.with_row do+ flex_layout(align_items: :center, justify_content: :space_between) do |heading|+ heading.with_column(flex: 1) do+ flex_layout(align_items: :center) do |title|+ title.with_column(mr: 2) do+ render(Primer::Beta::Heading.new(tag: :h4)) { Meeting.human_attribute_name(:participants) }+ end++ title.with_column do+ render(Primer::Beta::Counter.new(count: @meeting.invited_or_attended_participants.count, scheme: :primary))+ end+ end+ end++ if @meeting.editable?+ heading.with_column do+ render(Primer::Alpha::Dialog.new(+ id: "edit-participants-dialog", title: Meeting.human_attribute_name(:participants),+ size: :medium_portrait+ )) do |dialog|+ dialog.with_show_button(icon: :gear, 'aria-label': t("label_meeting_manage_participants"), scheme: :invisible)+ render(Meetings::Sidebar::ParticipantsFormComponent.new(meeting: @meeting))+ end+ end+ end+ end+ end++ participants_container.with_row(mt: 2) do+ if count == 0+ render(Primer::Beta::Text.new(color: :subtle)) { t("label_meeting_no_participants") }+ elsif count <= MAX_SHOWN_PARTICIPANTS+ flex_layout do |list|+ @meeting.invited_or_attended_participants.sort.each do |participant|+ list.with_row(mt: 1) do+ render_participant(participant)+ end+ end+ end+ elsif count > MAX_SHOWN_PARTICIPANTS+ flex_layout do |list|+ @meeting.invited_or_attended_participants.sort.take(MAX_SHOWN_PARTICIPANTS).each do |participant|+ list.with_row(mt: 1) do+ render_participant(participant)+ end+ end++ list.with_row(mt: 2) do+ render Primer::Beta::Details.new do |hidden_details|+ flex_layout do |flex|+ flex.with_row do+ hidden_details.with_summary(size: :small, scheme: :link) do+ t('label_meeting_show_hide_participants',+ count: @meeting.invited_or_attended_participants.count - MAX_SHOWN_PARTICIPANTS).to_s+ end+ end++ flex.with_row do+ hidden_details.with_body do+ flex_layout do |hidden_user_list|+ @meeting.invited_or_attended_participants.sort[MAX_SHOWN_PARTICIPANTS..].each do |participant|+ hidden_user_list.with_row(mt: 1) do+ render_participant(participant)+ end+ end+ end+ end+ end+ end+ end+ end+ end+ end+ end++ if @meeting.editable?+ participants_container.with_row(mt: 3) do+ render(Primer::Beta::Button.new(+ scheme: :link,+ color: :default,+ underline: false,+ font_weight: :bold,+ data: { 'show-dialog-id': "edit-participants-dialog" }+ )) do |button|+ button.with_leading_visual_icon(icon: "person-add")+ t("label_meeting_add_participants")+ end+ end+ end+ end+ end+%>diff --git a/modules/meeting/app/components/meetings/sidebar/participants_component.rb b/modules/meeting/app/components/meetings/sidebar/participants_component.rbindex 8d654bfa75b..8ac30d4b720 100644--- a/modules/meeting/app/components/meetings/sidebar/participants_component.rb+++ b/modules/meeting/app/components/meetings/sidebar/participants_component.rb@@ -32,141 +32,32 @@ module Meetingsinclude OpTurbo::Streamableinclude OpPrimer::ComponentHelpers+ MAX_SHOWN_PARTICIPANTS = 5+def initialize(meeting:)super@meeting = meetingend- def call- component_wrapper do- flex_layout do |flex|- flex.with_row do- heading_partial- end- flex.with_row(mt: 2) do- participant_list_partial(5)- end- if @meeting.editable?- flex.with_row(mt: 3) do- manage_button_partial- end- end- end- end- end-private- def heading_partial- flex_layout(align_items: :center, justify_content: :space_between) do |flex|- flex.with_column(flex: 1) do- title_partial- end- if @meeting.editable?- flex.with_column do- dialog_wrapper_partial- end- end- end+ def count+ @count ||= @meeting.invited_or_attended_participants.countend- def title_partial- flex_layout(align_items: :center) do |flex|- flex.with_column(mr: 2) do- render(Primer::Beta::Heading.new(tag: :h4)) { Meeting.human_attribute_name(:participants) }- end- flex.with_column do- render(Primer::Beta::Counter.new(count: @meeting.invited_or_attended_participants.count, scheme: :primary))- end- end- end-- def dialog_wrapper_partial- render(Primer::Alpha::Dialog.new(- id: "edit-participants-dialog", title: Meeting.human_attribute_name(:participants),- size: :medium_portrait- )) do |dialog|- dialog.with_show_button(icon: :gear, 'aria-label': t("label_meeting_manage_participants"), scheme: :invisible)- render(Meetings::Sidebar::ParticipantsFormComponent.new(meeting: @meeting))- end- end-- def participant_list_partial(max_initially_shown_participants)- count = @meeting.invited_or_attended_participants.count-- if count == 0- render(Primer::Beta::Text.new(color: :subtle)) { t("label_meeting_no_participants") }- elsif count <= max_initially_shown_participants- unsplit_participant_list- elsif count > max_initially_shown_participants- split_participant_list(max_initially_shown_participants)- end- end-- def unsplit_participant_list- flex_layout do |flex|- @meeting.invited_or_attended_participants.sort.each do |participant|- flex.with_row(mt: 1) do- participant_partial(participant)- end- end- end- end-- def split_participant_list(max_initially_shown_participants)- flex_layout do |flex|- @meeting.invited_or_attended_participants.sort.take(max_initially_shown_participants).each do |participant|- flex.with_row(mt: 1) do- participant_partial(participant)- end- end- flex.with_row(mt: 2) do- more_participants_partial(max_initially_shown_participants)- end- end- end-- def more_participants_partial(max_initially_shown_participants)- render Primer::Beta::Details.new do |component|- flex_layout do |flex|- flex.with_row do- component.with_summary(size: :small, scheme: :link) do- t('label_meeting_show_hide_participants',- count: @meeting.invited_or_attended_participants.count - max_initially_shown_participants).to_s- end- end- flex.with_row do- component.with_body do- hidden_participants_partial(max_initially_shown_participants)- end- end- end- end- end-- def hidden_participants_partial(max_initially_shown_participants)- flex_layout do |flex|- @meeting.invited_or_attended_participants.sort[max_initially_shown_participants..].each do |participant|- flex.with_row(mt: 1) do- participant_partial(participant)- end- end- end- end-- def participant_partial(participant)+ def render_participant(participant)flex_layout(align_items: :center) do |flex|flex.with_column(classes: 'ellipsis') dorender(Users::AvatarComponent.new(user: participant.user,size: :medium,classes: 'op-principal_flex'))end- participant_state_partial(participant, flex)+ render_participant_state(participant, flex)endend- def participant_state_partial(participant, flex)+ def render_participant_state(participant, flex)if participant.attended?flex.with_column(ml: 1) dorender(Primer::Beta::Text.new(font_size: :small, color: :subtle)) { t("description_attended").capitalize }@@ -177,18 +68,5 @@ module Meetingsendendend-- def manage_button_partial- render(Primer::Beta::Button.new(- scheme: :link,- color: :default,- underline: false,- font_weight: :bold,- data: { 'show-dialog-id': "edit-participants-dialog" }- )) do |button|- button.with_leading_visual_icon(icon: "person-add")- t("label_meeting_add_participants")- end- endendenddiff --git a/modules/meeting/app/components/meetings/sidebar/participants_form_component.html.erb b/modules/meeting/app/components/meetings/sidebar/participants_form_component.html.erbnew file mode 100644index 00000000000..dbd369a60c7--- /dev/null+++ b/modules/meeting/app/components/meetings/sidebar/participants_form_component.html.erb@@ -0,0 +1,108 @@+<%=+ component_wrapper do+ primer_form_with(+ model: @meeting,+ method: :put,+ url: update_participants_meeting_path(@meeting)+ ) do |f|+ component_collection do |collection|+ collection.with_component(Primer::Alpha::Dialog::Body.new(style: "max-height: 460px;", 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]", 1, participant.invited?,+ id: "checkbox_invited_#{participant.user.id}"+ # 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]", 1, participant.attended?,+ id: "checkbox_attended_#{participant.user.id}"+ 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}"+ 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}"+ end+ end+ end+ end+ end+ end+ end+ end+ end++ 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+%>diff --git a/modules/meeting/app/components/meetings/sidebar/participants_form_component.rb b/modules/meeting/app/components/meetings/sidebar/participants_form_component.rbindex 5d0e98e9086..735ada84f44 100644--- a/modules/meeting/app/components/meetings/sidebar/participants_form_component.rb+++ b/modules/meeting/app/components/meetings/sidebar/participants_form_component.rb@@ -39,194 +39,9 @@ module Meetings@meeting = meetingend- def call- component_wrapper do- form_partial- end- end-def render?User.current.allowed_to?(:edit_meetings, @meeting.project)end- private-- def form_partial- primer_form_with(- model: @meeting,- method: :put,- url: update_participants_meeting_path(@meeting)- ) do |f|- component_collection do |collection|- collection.with_component(Primer::Alpha::Dialog::Body.new(style: "max-height: 460px;", my: 3)) do- flex_layout(mt: 3) do |flex|- flex.with_row do- header_partial- end- flex.with_row do- form_content_partial(f)- end- end- end- collection.with_component(Primer::Alpha::Dialog::Footer.new(show_divider: true)) do- form_actions_partial- end- end- end- end-- def header_partial- flex_layout(justify_content: :flex_end) do |flex|- flex.with_column(style: "width: 90px;", text_align: :center) do- render(Primer::Beta::Text.new(font_weight: :emphasized)) { t("description_invite").capitalize }- end- flex.with_column(style: "width: 90px;", text_align: :center) do- render(Primer::Beta::Text.new(font_weight: :emphasized)) { t("description_attended").capitalize }- end- end- end-- def form_content_partial(_form)- flex_layout(my: 3) do |flex|- @meeting.all_changeable_participants.sort.each do |user|- flex.with_row do- hidden_field_tag "meeting[participants_attributes][][user_id]", user.id- end- participant_form_partial(user, flex)- end- end- end-- def participant_form_partial(user, flex)- flex.with_row(mb: 2, pb: 1, border: :bottom) do- if @meeting.participants.present? && participant = @meeting.participants.detect { |p| p.user_id == user.id }- exisiting_participant_form_partial(participant)- else- new_participant_form_partial(user)- end- end- end-- def exisiting_participant_form_partial(participant)- flex_layout do |flex|- flex.with_row do- hidden_field_tag "meeting[participants_attributes][][id]", participant.id- end- flex.with_row do- exisiting_participant_form_checkboxes_partial(participant)- end- end- end-- def exisiting_participant_form_checkboxes_partial(participant)- flex_layout(align_items: :center) do |flex|- flex.with_column(flex: 1, classes: 'ellipsis') do- render(Users::AvatarComponent.new(- user: participant.user,- classes: 'op-principal_flex'- ))- end- flex.with_column(style: "width: 90px;", text_align: :center) do- invited_participant_checkbox_partial(participant)- end- flex.with_column(style: "width: 90px;", text_align: :center) do- attended_participant_checkbox_partial(participant)- end- end- end-- def invited_participant_checkbox_partial(participant)- styled_check_box_tag "meeting[participants_attributes][][invited]", 1, participant.invited?,- id: "checkbox_invited_#{participant.user.id}"- # 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-- def attended_participant_checkbox_partial(participant)- styled_check_box_tag "meeting[participants_attributes][][attended]", 1, participant.attended?,- id: "checkbox_attended_#{participant.user.id}"- # 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][][attended]",- # checked: participant.attended?,- # id: "checkbox_attended_#{participant.user.id}",- # visually_hide_label: true,- # label: "Attended",- # scheme: :boolean,- # unchecked_value: ""- # ))- end-- def new_participant_form_partial(user)- flex_layout(align_items: :center) do |flex|- flex.with_column(flex: 1, classes: 'ellipsis') do- render(Users::AvatarComponent.new(- user:,- classes: 'op-principal_flex'- ))- end- flex.with_column(style: "width: 90px;", text_align: :center) do- invited_user_checkbox_partial(user)- end- flex.with_column(style: "width: 90px;", text_align: :center) do- attended_user_checkbox_partial(user)- end- end- end-- def invited_user_checkbox_partial(user)- styled_check_box_tag "meeting[participants_attributes][][invited]", value = "1", checked = false,- id: "checkbox_invited_#{user.id}"- # 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]",- # id: "checkbox_invited_#{user.id}",- # visually_hide_label: true,- # label: "Invited",- # scheme: :boolean,- # unchecked_value: ""- # ))- end-- def attended_user_checkbox_partial(user)- styled_check_box_tag "meeting[participants_attributes][][attended]", value = "1", checked = false,- id: "checkbox_attended_#{user.id}"- # 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][][attended]",- # id: "checkbox_attended_#{user.id}",- # visually_hide_label: true,- # label: "Attended",- # scheme: :boolean,- # unchecked_value: ""- # ))- end-- def form_actions_partial- component_collection do |collection|- collection.with_component(Primer::ButtonComponent.new(data: { 'close-dialog-id': "edit-participants-dialog" })) do- t("button_cancel")- end- collection.with_component(Primer::ButtonComponent.new(scheme: :primary, type: :submit)) do- t("button_save")- end- end- endendenddiff --git a/modules/meeting/app/components/meetings/sidebar/state_component.html.erb b/modules/meeting/app/components/meetings/sidebar/state_component.html.erbnew file mode 100644index 00000000000..74034d27288--- /dev/null+++ b/modules/meeting/app/components/meetings/sidebar/state_component.html.erb@@ -0,0 +1,102 @@+<%=+ component_wrapper do+ case @meeting.state+ when "open"+ flex_layout do |open_state|+ open_state.with_row do+ render(Primer::Beta::State.new(title: "state", scheme: :open)) do+ flex_layout do |open_state_label|+ open_state_label.with_column(mr: 1) do+ render(Primer::Beta::Octicon.new(icon: "issue-opened"))+ end++ open_state_label.with_column do+ render(Primer::Beta::Text.new) { t("label_meeting_state_open") }+ end+ end+ end+ end++ open_state.with_row(mt: 3) do+ render(Primer::Beta::Text.new(color: :subtle)) do+ t("text_meeting_open_description")+ end+ end++ if edit_enabled?+ open_state.with_row(mt: 3) do+ form_for(@meeting, method: "put", url: change_state_meeting_path(@meeting),+ data: { 'turbo-stream': true }) do |f|+ flex_layout do |open_state_actions|+ open_state_actions.with_row do+ f.hidden_field :state, value: "closed"+ end++ open_state_actions.with_row do+ render(Primer::Beta::Button.new(+ scheme: :link,+ color: :default,+ underline: false,+ font_weight: :bold,+ type: :submit+ )) do |button|+ button.with_leading_visual_icon(icon: :lock)+ t("label_meeting_close_action")+ end+ end+ end+ end+ end+ end+ end+ when "closed"+ flex_layout do |closed_state|+ closed_state.with_row do+ render(Primer::Beta::State.new(title: "state", scheme: :default)) do+ flex_layout do |closed_state_label|+ closed_state_label.with_column(mr: 1) do+ render(Primer::Beta::Octicon.new(icon: "issue-closed"))+ end++ closed_state_label.with_column do+ render(Primer::Beta::Text.new) { t("label_meeting_state_closed") }+ end+ end+ end+ end++ closed_state.with_row(mt: 3) do+ render(Primer::Beta::Text.new(color: :subtle)) do+ t("text_meeting_closed_description")+ end+ end++ if edit_enabled?+ closed_state.with_row(mt: 3) do+ form_for(@meeting, method: "put", url: change_state_meeting_path(@meeting),+ data: { 'turbo-stream': true }) do |f|+ flex_layout do |closed_state_actions|+ closed_state_actions.with_row do+ f.hidden_field :state, value: "open"+ end++ closed_state_actions.with_row do+ render(Primer::Beta::Button.new(+ scheme: :link,+ color: :default,+ underline: false,+ font_weight: :bold,+ type: :submit+ )) do |button|+ button.with_leading_visual_icon(icon: :unlock)+ t("label_meeting_reopen_action")+ end+ end+ end+ end+ end+ end+ end+ end+ end+%>diff --git a/modules/meeting/app/components/meetings/sidebar/state_component.rb b/modules/meeting/app/components/meetings/sidebar/state_component.rbindex 13f83ed3090..5a28f499102 100644--- a/modules/meeting/app/components/meetings/sidebar/state_component.rb+++ b/modules/meeting/app/components/meetings/sidebar/state_component.rb@@ -38,137 +38,10 @@ module Meetings@meeting = meetingend- def call- component_wrapper do- case @meeting.state- when "open"- open_state_partial- when "closed"- closed_state_partial- end- end- end-privatedef edit_enabled?User.current.allowed_to?(:close_meeting_agendas, @meeting.project)end-- def open_state_partial- flex_layout do |flex|- flex.with_row do- open_state_label_partial- end- flex.with_row(mt: 3) do- open_description_partial- end- if edit_enabled?- flex.with_row(mt: 3) do- open_actions_partial- end- end- end- end-- def open_state_label_partial- render(Primer::Beta::State.new(title: "state", scheme: :open)) do- flex_layout do |flex|- flex.with_column(mr: 1) do- render(Primer::Beta::Octicon.new(icon: "issue-opened"))- end- flex.with_column do- render(Primer::Beta::Text.new) { t("label_meeting_state_open") }- end- end- end- end-- def open_description_partial- render(Primer::Beta::Text.new(color: :subtle)) do- t("text_meeting_open_description")- end- end-- def open_actions_partial- form_for(@meeting, method: "put", url: change_state_meeting_path(@meeting),- data: { 'turbo-stream': true }) do |f|- flex_layout do |flex|- flex.with_row do- f.hidden_field :state, value: "closed"- end- flex.with_row do- render(Primer::Beta::Button.new(- scheme: :link,- color: :default,- underline: false,- font_weight: :bold,- type: :submit- )) do |button|- button.with_leading_visual_icon(icon: :lock)- t("label_meeting_close_action")- end- end- end- end- end-- def closed_state_partial- flex_layout do |flex|- flex.with_row do- closed_state_label_partial- end- flex.with_row(mt: 3) do- closed_description_partial- end- if edit_enabled?- flex.with_row(mt: 3) do- closed_actions_partial- end- end- end- end-- def closed_state_label_partial- render(Primer::Beta::State.new(title: "state", scheme: :default)) do- flex_layout do |flex|- flex.with_column(mr: 1) do- render(Primer::Beta::Octicon.new(icon: "issue-closed"))- end- flex.with_column do- render(Primer::Beta::Text.new) { t("label_meeting_state_closed") }- end- end- end- end-- def closed_description_partial- render(Primer::Beta::Text.new(color: :subtle)) do- t("text_meeting_closed_description")- end- end-- def closed_actions_partial- form_for(@meeting, method: "put", url: change_state_meeting_path(@meeting),- data: { 'turbo-stream': true }) do |f|- flex_layout do |flex|- flex.with_row do- f.hidden_field :state, value: "open"- end- flex.with_row do- render(Primer::Beta::Button.new(- scheme: :link,- color: :default,- underline: false,- font_weight: :bold,- type: :submit- )) do |button|- button.with_leading_visual_icon(icon: :unlock)- t("label_meeting_reopen_action")- end- end- end- end- endendenddiff --git a/modules/meeting/app/components/meetings/sidebar_component.html.erb b/modules/meeting/app/components/meetings/sidebar_component.html.erbnew file mode 100644index 00000000000..182e5b13787--- /dev/null+++ b/modules/meeting/app/components/meetings/sidebar_component.html.erb@@ -0,0 +1,9 @@+<%=+ component_wrapper do+ render(Primer::OpenProject::BorderGrid.new) do |border_grid|+ border_grid.with_row { render(Meetings::Sidebar::DetailsComponent.new(meeting: @meeting)) }+ border_grid.with_row { render(Meetings::Sidebar::StateComponent.new(meeting: @meeting)) }+ border_grid.with_row { render(Meetings::Sidebar::ParticipantsComponent.new(meeting: @meeting)) }+ end+ end+%>diff --git a/modules/meeting/app/components/meetings/sidebar_component.rb b/modules/meeting/app/components/meetings/sidebar_component.rbindex 921854c6186..886e1a192d5 100644--- a/modules/meeting/app/components/meetings/sidebar_component.rb+++ b/modules/meeting/app/components/meetings/sidebar_component.rb@@ -37,29 +37,5 @@ module Meetings@meeting = meetingend-- def call- component_wrapper do- render(Primer::OpenProject::BorderGrid.new) do |border_grid|- border_grid.with_row { details_partial }- border_grid.with_row { state_partial }- border_grid.with_row { participants_partial }- end- end- end-- private-- def details_partial- render(Meetings::Sidebar::DetailsComponent.new(meeting: @meeting))- end-- def state_partial- render(Meetings::Sidebar::StateComponent.new(meeting: @meeting))- end-- def participants_partial- render(Meetings::Sidebar::ParticipantsComponent.new(meeting: @meeting))- endendend