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
fixed section based approach for empty meetings
Jonas Jabari0573550ecfe6
diff --git a/modules/meeting/app/components/meeting_agenda_items/list_component.html.erb b/modules/meeting/app/components/meeting_agenda_items/list_component.html.erbindex bcda9adafef..177bfb774e3 100644--- a/modules/meeting/app/components/meeting_agenda_items/list_component.html.erb+++ b/modules/meeting/app/components/meeting_agenda_items/list_component.html.erb@@ -12,31 +12,33 @@))end- flex.with_row do- render(Primer::Beta::BorderBox.new(mt: 1, position: :relative)) do |border_box|- if @meeting.agenda_items.empty? && @form_hidden- border_box.with_body(- scheme: :default- ) do- render(Primer::Beta::Blankslate.new) do |component|- component.with_visual_icon(icon: :book)- component.with_heading(tag: :h2).with_content(t("text_meeting_empty_heading"))- component.with_description do- flex_layout do |flex|- flex.with_row(mb: 2) do- render(Primer::Beta::Text.new(color: :subtle)) { t("text_meeting_empty_description_1") }- end- flex.with_row do- render(Primer::Beta::Text.new(color: :subtle)) { t("text_meeting_empty_description_2") }+ if @meeting.agenda_items.empty? && @meeting.sections.empty?+ flex.with_row do+ render(Primer::Beta::BorderBox.new(mt: 1, position: :relative)) do |border_box|+ if @form_hidden+ border_box.with_body(+ scheme: :default+ ) do+ render(Primer::Beta::Blankslate.new) do |component|+ component.with_visual_icon(icon: :book)+ component.with_heading(tag: :h2).with_content(t("text_meeting_empty_heading"))+ component.with_description do+ flex_layout do |flex|+ flex.with_row(mb: 2) do+ render(Primer::Beta::Text.new(color: :subtle)) { t("text_meeting_empty_description_1") }+ end+ flex.with_row do+ render(Primer::Beta::Text.new(color: :subtle)) { t("text_meeting_empty_description_2") }+ endendendendendend+ border_box.with_row(p: 0, border_top: 0) do+ render(MeetingAgendaItems::NewComponent.new(meeting: @meeting, hidden: @form_hidden, type: @form_type))+ endend- # border_box.with_row(p: 0, border_top: 0, id: insert_target_modifier_id) do- # render(MeetingAgendaItems::NewComponent.new(meeting: @meeting, hidden: @form_hidden, type: @form_type))- # endendendenddiff --git a/modules/meeting/app/components/meeting_agenda_items/new_button_component.html.erb b/modules/meeting/app/components/meeting_agenda_items/new_button_component.html.erbindex 5e9d85afa6d..5743a10edaa 100644--- a/modules/meeting/app/components/meeting_agenda_items/new_button_component.html.erb+++ b/modules/meeting/app/components/meeting_agenda_items/new_button_component.html.erb@@ -21,7 +21,7 @@data: { "turbo-stream": true }})- unless @meeting_section+ unless @meeting_section || @meeting.sections.empty?component.with_item(label: "Section",tag: :a,diff --git a/modules/meeting/app/components/meeting_agenda_items/new_component.rb b/modules/meeting/app/components/meeting_agenda_items/new_component.rbindex 9bcaa249035..d1dbc6dca93 100644--- a/modules/meeting/app/components/meeting_agenda_items/new_component.rb+++ b/modules/meeting/app/components/meeting_agenda_items/new_component.rb@@ -32,7 +32,7 @@ module MeetingAgendaItemsinclude OpTurbo::Streamableinclude OpPrimer::ComponentHelpers- def initialize(meeting:, meeting_section:, meeting_agenda_item: nil, hidden: true, type: :simple)+ def initialize(meeting:, meeting_section: nil, meeting_agenda_item: nil, hidden: true, type: :simple)super@meeting = meeting@@ -45,7 +45,7 @@ module MeetingAgendaItemsprivatedef wrapper_uniq_by- @meeting_section.id+ @meeting_section&.idenddef build_agenda_itemdiff --git a/modules/meeting/app/components/meeting_sections/show_component.html.erb b/modules/meeting/app/components/meeting_sections/show_component.html.erbindex eb3207cf2d7..bdc70ca49f1 100644--- a/modules/meeting/app/components/meeting_sections/show_component.html.erb+++ b/modules/meeting/app/components/meeting_sections/show_component.html.erb@@ -1,36 +1,38 @@<%=component_wrapper(class: "op-meeting-section-container", data: { test_selector: "meeting-section-container-#{@meeting_section.id}" }) do- render(Primer::Beta::BorderBox.new(mt: top_margin, data: drag_and_drop_target_config)) do |component|- if render_section_wrapper?- component.with_header(font_weight: :bold, pl: 0) do- render(MeetingSections::HeaderComponent.new(meeting_section: @meeting_section))+ unless hide_section?+ render(Primer::Beta::BorderBox.new(mt: top_margin, data: drag_and_drop_target_config)) do |component|+ if render_section_wrapper?+ component.with_header(font_weight: :bold, pl: 0) do+ render(MeetingSections::HeaderComponent.new(meeting_section: @meeting_section))+ endend- end- if @meeting_agenda_items.empty? && @form_hidden- component.with_row(data: { 'empty-list-item': true }) do- flex_layout(align_items: :center, justify_content: :space_between) do |empty_list_container|- empty_list_container.with_column(mr: 2) do- render(Primer::Beta::Text.new(color: :subtle)) { "Drag items here or create a new one" } # TODO: i18n- end- empty_list_container.with_column do- render(MeetingAgendaItems::NewButtonComponent.new(meeting: @meeting, meeting_section: @meeting_section))+ if render_new_button_in_section?+ component.with_row(data: { 'empty-list-item': true }) do+ flex_layout(align_items: :center, justify_content: :space_between) do |empty_list_container|+ empty_list_container.with_column(mr: 2) do+ render(Primer::Beta::Text.new(color: :subtle)) { "Drag items here or create a new one" } # TODO: i18n+ end+ empty_list_container.with_column do+ render(MeetingAgendaItems::NewButtonComponent.new(meeting: @meeting, meeting_section: @meeting_section))+ endendend- end- else- first_and_last = [@meeting_agenda_items.first, @meeting_agenda_items.last]- @meeting_agenda_items.each do |agenda_item|- render(- MeetingAgendaItems::ItemComponent.new(- meeting_agenda_item: agenda_item,- container: component,- first_and_last:+ else+ first_and_last = [@meeting_agenda_items.first, @meeting_agenda_items.last]+ @meeting_agenda_items.each do |agenda_item|+ render(+ MeetingAgendaItems::ItemComponent.new(+ meeting_agenda_item: agenda_item,+ container: component,+ first_and_last:+ ))- )+ end+ end+ component.with_row(p: 0, border_top: 0, id: insert_target_modifier_id) do+ render(MeetingAgendaItems::NewComponent.new(meeting: @meeting, meeting_section: @meeting_section, hidden: @form_hidden, type: @form_type))end- end- component.with_row(p: 0, border_top: 0, id: insert_target_modifier_id) do- render(MeetingAgendaItems::NewComponent.new(meeting: @meeting, meeting_section: @meeting_section, hidden: @form_hidden, type: @form_type))endendenddiff --git a/modules/meeting/app/components/meeting_sections/show_component.rb b/modules/meeting/app/components/meeting_sections/show_component.rbindex e5004bb7226..2fa29e9e9bd 100644--- a/modules/meeting/app/components/meeting_sections/show_component.rb+++ b/modules/meeting/app/components/meeting_sections/show_component.rb@@ -51,12 +51,20 @@ module MeetingSections@meeting_section.idend+ def hide_section?+ @meeting.sections.count == 1 && @meeting_agenda_items.empty?+ end+def render_section_wrapper?@meeting_section.meeting.sections.count > 1end+ def render_new_button_in_section?+ @meeting_agenda_items.empty? && @form_hidden+ end+def top_margin- if @meeting_section.id == @first_and_last.first.id+ if @meeting_section.id == @first_and_last&.first&.id1else3diff --git a/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb b/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rbindex bb0c59754a3..f47eac31830 100644--- a/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb+++ b/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb@@ -136,6 +136,24 @@ module Meetingsenddef render_agenda_item_form_via_turbo_stream(meeting: @meeting, meeting_section: @meeting_section, type: :simple)+ if meeting.sections.empty?+ render_agenda_item_form_for_empty_meeting_via_turbo_stream(meeting:, type:)+ else+ render_agenda_item_form_in_section_via_turbo_stream(meeting:, meeting_section:, type:)+ end++ update_new_button_via_turbo_stream(disabled: true)+ end++ def render_agenda_item_form_for_empty_meeting_via_turbo_stream(meeting: @meeting, type: :simple)+ update_new_component_via_turbo_stream(+ hidden: false,+ meeting_section: nil,+ type:+ )+ end++ def render_agenda_item_form_in_section_via_turbo_stream(meeting: @meeting, meeting_section: @meeting_section, type: :simple)if meeting_section.nil?meeting_section = meeting.sections.lastend@@ -149,8 +167,6 @@ module Meetingstype:)end-- update_new_button_via_turbo_stream(disabled: true)enddef update_list_via_turbo_stream(meeting: @meeting, form_hidden: true, form_type: :simple)@@ -182,6 +198,14 @@ module Meetingsdef add_item_via_turbo_stream(meeting_agenda_item: @meeting_agenda_item, clear_slate: false)if clear_slateupdate_list_via_turbo_stream(form_hidden: false, form_type: @agenda_item_type)+ elsif meeting_agenda_item.meeting.agenda_items.count == 1+ update_list_via_turbo_stream(form_hidden: true)++ update_new_component_via_turbo_stream(+ hidden: false,+ meeting_section: meeting_agenda_item.meeting_section,+ type: @agenda_item_type+ )else# TODO: more specific UI update as beforeupdate_section_via_turbo_stream(meeting_section: meeting_agenda_item.meeting_section)diff --git a/modules/meeting/app/controllers/meeting_agenda_items_controller.rb b/modules/meeting/app/controllers/meeting_agenda_items_controller.rbindex 615fd483f41..3523cdc560b 100644--- a/modules/meeting/app/controllers/meeting_agenda_items_controller.rb+++ b/modules/meeting/app/controllers/meeting_agenda_items_controller.rb@@ -69,7 +69,7 @@ class MeetingAgendaItemsController < ApplicationControllerenddef create- clear_slate = @meeting.agenda_items.empty?+ # clear_slate = @meeting.agenda_items.empty?call = ::MeetingAgendaItems::CreateService.new(user: current_user)@@ -84,7 +84,7 @@ class MeetingAgendaItemsController < ApplicationControllerif call.success?# enable continue editing- add_item_via_turbo_stream(clear_slate:)+ add_item_via_turbo_stream(clear_slate: false)update_header_component_via_turbo_streamupdate_sidebar_details_component_via_turbo_streamelsediff --git a/modules/meeting/app/models/meeting_agenda_item.rb b/modules/meeting/app/models/meeting_agenda_item.rbindex b81d870c92b..5bc4d92df30 100644--- a/modules/meeting/app/models/meeting_agenda_item.rb+++ b/modules/meeting/app/models/meeting_agenda_item.rb@@ -69,6 +69,7 @@ class MeetingAgendaItem < ApplicationRecorditem.duration_in_minutes_previously_changed? || item.position_previously_changed?}after_destroy :trigger_meeting_agenda_item_time_slots_calculation+ after_destroy :delete_meeting_section_if_emptydef add_to_latest_meeting_sectionif meeting_section_id.nil?@@ -86,6 +87,14 @@ class MeetingAgendaItem < ApplicationRecordmeeting.calculate_agenda_item_time_slotsend+ def delete_meeting_section_if_empty+ # we need to delete the last existing section if the last meeting agenda item is deleted+ # as we don't render the section (including the section menu) if only one section exists+ # thus the section would silently exist in the database when the very last agenda item was deleted+ # which makes UI rendering inconsistent+ meeting_section.destroy if meeting_section.agenda_items.empty? && meeting.sections.count == 1+ end+def linked_work_package?item_type == "work_package" && work_package.present?end