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
WIP: finalized section based structure and agenda edits, without drag and drop support yet
Jonas Jabari526b030ced22
diff --git a/frontend/src/stimulus/controllers/dynamic/meeting-section-form.controller.ts b/frontend/src/stimulus/controllers/dynamic/meeting-section-form.controller.tsnew file mode 100644index 00000000000..91be719c9c6--- /dev/null+++ b/frontend/src/stimulus/controllers/dynamic/meeting-section-form.controller.ts@@ -0,0 +1,76 @@+/*+ * -- copyright+ * OpenProject is an open source project management software.+ * Copyright (C) 2023 the OpenProject GmbH+ *+ * This program is free software; you can redistribute it and/or+ * modify it under the terms of the GNU General Public License version 3.+ *+ * OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+ * Copyright (C) 2006-2013 Jean-Philippe Lang+ * Copyright (C) 2010-2013 the ChiliProject Team+ *+ * This program is free software; you can redistribute it and/or+ * modify it under the terms of the GNU General Public License+ * as published by the Free Software Foundation; either version 2+ * of the License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU General Public License for more details.+ *+ * You should have received a copy of the GNU General Public License+ * along with this program; if not, write to the Free Software+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+ *+ * See COPYRIGHT and LICENSE files for more details.+ * +++ */++import * as Turbo from '@hotwired/turbo';+import { Controller } from '@hotwired/stimulus';++export default class extends Controller {+ static values = {+ cancelUrl: String,+ };++ declare cancelUrlValue:string;++ connect():void {+ this.focusInput();+ }++ focusInput():void {+ const nameInput = this.element.querySelector('input[name="meeting_section[name]"]');++ setTimeout(() => {+ this.element.scrollIntoView({ block: 'center' });+ (nameInput as HTMLInputElement).focus();+ this.setCursorAtEnd(nameInput as HTMLInputElement);+ }, 100);+ }++ async cancel() {+ const response = await fetch(this.cancelUrlValue, {+ method: 'GET',+ headers: {+ 'X-CSRF-Token': (document.querySelector('meta[name="csrf-token"]') as HTMLMetaElement).content,+ Accept: 'text/vnd.turbo-stream.html',+ },+ });++ if (response.ok) {+ const text = await response.text();+ Turbo.renderStreamMessage(text);+ }+ }++ setCursorAtEnd(inputElement:HTMLInputElement):void {+ if (document.activeElement === inputElement) {+ const valueLength = inputElement.value.length;+ inputElement.setSelectionRange(valueLength, valueLength);+ }+}+}diff --git a/modules/meeting/app/components/meeting_agenda_items/form_component.html.erb b/modules/meeting/app/components/meeting_agenda_items/form_component.html.erbindex 063d0fa056e..38140f36626 100644--- a/modules/meeting/app/components/meeting_agenda_items/form_component.html.erb+++ b/modules/meeting/app/components/meeting_agenda_items/form_component.html.erb@@ -55,6 +55,9 @@t("button_cancel")endend+ flex.with_column do+ render(MeetingAgendaItem::MeetingSectionForm.new(f, meeting_section: @meeting_section))+ endflex.with_column dorender(MeetingAgendaItem::Submit.new(f, type: @type))enddiff --git a/modules/meeting/app/components/meeting_agenda_items/form_component.rb b/modules/meeting/app/components/meeting_agenda_items/form_component.rbindex 39d90ce694a..427f542de7f 100644--- a/modules/meeting/app/components/meeting_agenda_items/form_component.rb+++ b/modules/meeting/app/components/meeting_agenda_items/form_component.rb@@ -32,10 +32,12 @@ module MeetingAgendaItemsinclude OpTurbo::Streamableinclude OpPrimer::ComponentHelpers- def initialize(meeting:, meeting_agenda_item:, method:, submit_path:, cancel_path:, type: :simple, display_notes_input: nil)+ def initialize(meeting:, meeting_section:, meeting_agenda_item:, method:, submit_path:, cancel_path:, type: :simple,+ display_notes_input: nil)super@meeting = meeting+ @meeting_section = meeting_section@meeting_agenda_item = meeting_agenda_item@method = method@submit_path = submit_pathdiff --git a/modules/meeting/app/components/meeting_agenda_items/item_component/edit_component.rb b/modules/meeting/app/components/meeting_agenda_items/item_component/edit_component.rbindex 7833da7e7d5..662733396e8 100644--- a/modules/meeting/app/components/meeting_agenda_items/item_component/edit_component.rb+++ b/modules/meeting/app/components/meeting_agenda_items/item_component/edit_component.rb@@ -43,6 +43,7 @@ module MeetingAgendaItemsrender(Primer::Box.new(pl: 3)) dorender(MeetingAgendaItems::FormComponent.new(meeting: @meeting_agenda_item.meeting,+ meeting_section: @meeting_agenda_item.meeting_section,meeting_agenda_item: @meeting_agenda_item,method: :put,submit_path: meeting_agenda_item_path(@meeting_agenda_item.meeting, @meeting_agenda_item, format: :turbo_stream),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 95bb68b2a04..bcda9adafef 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@@ -13,7 +13,7 @@)endflex.with_row do- render(Primer::Beta::BorderBox.new(position: :relative)) do |border_box|+ render(Primer::Beta::BorderBox.new(mt: 1, position: :relative)) do |border_box|if @meeting.agenda_items.empty? && @form_hiddenborder_box.with_body(scheme: :default@@ -34,9 +34,9 @@endendend- 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))- end+ # 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/list_component.rb b/modules/meeting/app/components/meeting_agenda_items/list_component.rbindex 79bb962b064..e5b549b5e37 100644--- a/modules/meeting/app/components/meeting_agenda_items/list_component.rb+++ b/modules/meeting/app/components/meeting_agenda_items/list_component.rb@@ -50,12 +50,12 @@ module MeetingAgendaItems}end- def insert_target_modified?- true- end+ # def insert_target_modified?+ # true+ # end- def insert_target_modifier_id- "meeting-agenda-items-new-item"- end+ # def insert_target_modifier_id+ # "meeting-agenda-items-new-item"+ # endendenddiff --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 f892534554b..5e9d85afa6d 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@@ -1,7 +1,7 @@<%=component_wrapper(class: "mt-3", style: "position: relative") dorender(Primer::Alpha::ActionMenu.new) do |component|- component.with_show_button(scheme: :primary, disabled: @disabled) do |button|+ component.with_show_button(scheme: button_scheme, disabled: @disabled) do |button|button.with_leading_visual_icon(icon: :plus)t("button_add")end@@ -9,7 +9,7 @@label: t("activerecord.models.meeting_agenda_item", count: 1),tag: :a,content_arguments: {- href: new_meeting_agenda_item_path(@meeting, type: "simple"),+ href: new_meeting_agenda_item_path(@meeting, type: "simple", meeting_section_id: @meeting_section&.id),data: { "turbo-stream": true }})@@ -17,18 +17,20 @@label: t("activerecord.models.work_package", count: 1),tag: :a,content_arguments: {- href: new_meeting_agenda_item_path(@meeting, type: "work_package"),+ href: new_meeting_agenda_item_path(@meeting, type: "work_package", meeting_section_id: @meeting_section&.id),data: { "turbo-stream": true }})- component.with_item(- label: "Section",- tag: :a,- content_arguments: {- href: meeting_sections_path(@meeting),- data: { "turbo-stream": true, "turbo-method": :post }- }- )+ unless @meeting_section+ component.with_item(+ label: "Section",+ tag: :a,+ content_arguments: {+ href: meeting_sections_path(@meeting),+ data: { "turbo-stream": true, "turbo-method": :post }+ }+ )+ endendend%>diff --git a/modules/meeting/app/components/meeting_agenda_items/new_button_component.rb b/modules/meeting/app/components/meeting_agenda_items/new_button_component.rbindex bfc9b1af307..06ad902fe00 100644--- a/modules/meeting/app/components/meeting_agenda_items/new_button_component.rb+++ b/modules/meeting/app/components/meeting_agenda_items/new_button_component.rb@@ -32,16 +32,26 @@ module MeetingAgendaItemsinclude OpTurbo::Streamableinclude OpPrimer::ComponentHelpers- def initialize(meeting:, meeting_agenda_item: nil, disabled: false)+ def initialize(meeting:, meeting_section: nil, disabled: false)super@meeting = meeting- @meeting_agenda_item = meeting_agenda_item || MeetingAgendaItem.new(meeting:, author: User.current)+ @meeting_section = meeting_section@disabled = @meeting.closed? || disabledend+ private++ def wrapper_uniq_by+ @meeting_section&.id+ end+def render?User.current.allowed_in_project?(:manage_agendas, @meeting.project)end++ def button_scheme+ @meeting_section ? :secondary : :primary+ endendenddiff --git a/modules/meeting/app/components/meeting_agenda_items/new_component.html.erb b/modules/meeting/app/components/meeting_agenda_items/new_component.html.erbindex 75d91649eae..8aae29ad1fe 100644--- a/modules/meeting/app/components/meeting_agenda_items/new_component.html.erb+++ b/modules/meeting/app/components/meeting_agenda_items/new_component.html.erb@@ -6,9 +6,10 @@render(MeetingAgendaItems::FormComponent.new(meeting: @meeting,meeting_agenda_item: @meeting_agenda_item,+ meeting_section: @meeting_section,method: :post,submit_path: meeting_agenda_items_path(@meeting, format: :turbo_stream),- cancel_path: cancel_new_meeting_agenda_items_path(@meeting),+ cancel_path: cancel_new_meeting_agenda_items_path(@meeting, meeting_section_id: @meeting_section&.id),type: @type))enddiff --git a/modules/meeting/app/components/meeting_agenda_items/new_component.rb b/modules/meeting/app/components/meeting_agenda_items/new_component.rbindex f20d74affa8..9bcaa249035 100644--- a/modules/meeting/app/components/meeting_agenda_items/new_component.rb+++ b/modules/meeting/app/components/meeting_agenda_items/new_component.rb@@ -32,10 +32,11 @@ module MeetingAgendaItemsinclude OpTurbo::Streamableinclude OpPrimer::ComponentHelpers- def initialize(meeting:, meeting_agenda_item: nil, hidden: true, type: :simple)+ def initialize(meeting:, meeting_section:, meeting_agenda_item: nil, hidden: true, type: :simple)super@meeting = meeting+ @meeting_section = meeting_section@meeting_agenda_item = meeting_agenda_item || build_agenda_item@hidden = hidden@type = type@@ -43,6 +44,10 @@ module MeetingAgendaItemsprivate+ def wrapper_uniq_by+ @meeting_section.id+ end+def build_agenda_itemMeetingAgendaItem.new(meeting: @meeting,diff --git a/modules/meeting/app/components/meeting_sections/header_component.html.erb b/modules/meeting/app/components/meeting_sections/header_component.html.erbindex f06e791b3a2..e1f89dc32a4 100644--- a/modules/meeting/app/components/meeting_sections/header_component.html.erb+++ b/modules/meeting/app/components/meeting_sections/header_component.html.erb@@ -32,9 +32,14 @@model: @meeting_section,method: :put,url: meeting_section_path(@meeting_section.meeting, @meeting_section),+ data: {+ "controller": "meeting-section-form",+ "application-target": "dynamic",+ "meeting-section-form-cancel-url-value": cancel_edit_meeting_section_path(@meeting_section.meeting, @meeting_section)+ }) do |f|flex_layout do |editable_title_form|- editable_title_form.with_column(flex: 1, mr: 2) do+ editable_title_form.with_column(flex: 1, mr: 2, pl: 3) dorender(MeetingSection::Name.new(f))enddiff --git a/modules/meeting/app/components/meeting_sections/show_component.html.erb b/modules/meeting/app/components/meeting_sections/show_component.html.erbindex 0f65419b15c..eb3207cf2d7 100644--- a/modules/meeting/app/components/meeting_sections/show_component.html.erb+++ b/modules/meeting/app/components/meeting_sections/show_component.html.erb@@ -1,16 +1,19 @@<%=component_wrapper(class: "op-meeting-section-container", data: { test_selector: "meeting-section-container-#{@meeting_section.id}" }) do- render(Primer::Beta::BorderBox.new(mt: 3, data: drag_and_drop_target_config)) do |component|+ 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) do+ component.with_header(font_weight: :bold, pl: 0) dorender(MeetingSections::HeaderComponent.new(meeting_section: @meeting_section))endend- if @meeting_agenda_items.empty?+ if @meeting_agenda_items.empty? && @form_hiddencomponent.with_row(data: { 'empty-list-item': true }) doflex_layout(align_items: :center, justify_content: :space_between) do |empty_list_container|- empty_list_container.with_column(ml: 4, mr: 2) do- render(Primer::Beta::Text.new(color: :subtle)) { t("settings.project_attributes.label_no_project_custom_fields") }+ 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@@ -26,6 +29,9 @@)endend+ 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))+ endendend%>diff --git a/modules/meeting/app/components/meeting_sections/show_component.rb b/modules/meeting/app/components/meeting_sections/show_component.rbindex ccccd3f6cdf..e5004bb7226 100644--- a/modules/meeting/app/components/meeting_sections/show_component.rb+++ b/modules/meeting/app/components/meeting_sections/show_component.rb@@ -34,12 +34,15 @@ module MeetingSectionswith_collection_parameter :meeting_section- def initialize(meeting_section:, state: :show, first_and_last: [])+ def initialize(meeting_section:, first_and_last: [], form_hidden: true, form_type: :simple)super+ @meeting = meeting_section.meeting@meeting_section = meeting_section@meeting_agenda_items = meeting_section.agenda_items@first_and_last = first_and_last+ @form_hidden = form_hidden+ @form_type = form_typeendprivate@@ -52,6 +55,14 @@ module MeetingSections@meeting_section.meeting.sections.count > 1end+ def top_margin+ if @meeting_section.id == @first_and_last.first.id+ 1+ else+ 3+ end+ end+def drag_and_drop_target_config{"is-drag-and-drop-target": true,@@ -60,5 +71,13 @@ module MeetingSections"target-allowed-drag-type": "custom-field" # the type of dragged items which are allowed to be dropped in this target}end++ def insert_target_modified?+ true+ end++ def insert_target_modifier_id+ "meeting-agenda-items-new-item"+ endendenddiff --git a/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb b/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rbindex 51277e13daa..bb0c59754a3 100644--- a/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb+++ b/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb@@ -86,42 +86,73 @@ module Meetingscomponent: Meetings::Sidebar::ParticipantsFormComponent.new(meeting:),- status: :bad_request+ status: :bad_request # TODO: why bad_request?)enddef update_show_items_via_turbo_stream(meeting: @meeting)- agenda_items = meeting.agenda_items.with_includes_to_render- first_and_last = [agenda_items.first, agenda_items.last]+ # TODO: scope to specific section in cases where only one section is affected for less computation+ meeting.sections.each do |meeting_section|+ agenda_items = meeting_section.agenda_items.with_includes_to_render+ first_and_last = [agenda_items.first, agenda_items.last]- agenda_items.each do |meeting_agenda_item|- update_via_turbo_stream(- component: MeetingAgendaItems::ItemComponent::ShowComponent.new(meeting_agenda_item:, first_and_last:)- )+ agenda_items.each do |meeting_agenda_item|+ update_via_turbo_stream(+ component: MeetingAgendaItems::ItemComponent::ShowComponent.new(meeting_agenda_item:, first_and_last:)+ )+ endendend- def update_new_component_via_turbo_stream(hidden: false, meeting_agenda_item: nil, meeting: @meeting, type: :simple)+ def update_new_component_via_turbo_stream(hidden: false, meeting_section: @meeting_section, meeting_agenda_item: nil,+ meeting: @meeting, type: :simple)+ if meeting_section.nil? && meeting_agenda_item.nil?+ meeting_section = meeting.sections.last+ end++ if meeting_agenda_item.present?+ meeting_section = meeting_agenda_item.meeting_section+ end+update_via_turbo_stream(component: MeetingAgendaItems::NewComponent.new(hidden:,meeting:,+ meeting_section:,meeting_agenda_item:,type:))end- def update_new_button_via_turbo_stream(disabled: false, meeting_agenda_item: nil, meeting: @meeting)+ def update_new_button_via_turbo_stream(disabled: false, meeting: @meeting, meeting_section: nil)update_via_turbo_stream(component: MeetingAgendaItems::NewButtonComponent.new(disabled:,meeting:,- meeting_agenda_item:+ meeting_section:))end+ def render_agenda_item_form_via_turbo_stream(meeting: @meeting, meeting_section: @meeting_section, type: :simple)+ if meeting_section.nil?+ meeting_section = meeting.sections.last+ end++ if meeting_section.agenda_items.empty?+ update_section_via_turbo_stream(meeting_section:, form_hidden: false, form_type: type)+ else+ update_new_component_via_turbo_stream(+ hidden: false,+ meeting_section:,+ type:+ )+ end++ update_new_button_via_turbo_stream(disabled: true)+ end+def update_list_via_turbo_stream(meeting: @meeting, form_hidden: true, form_type: :simple)# replace needs to be called in order to mount the drag and drop handlers again# update would not do that and drag and drop would stop working after the first update@@ -152,14 +183,20 @@ module Meetingsif clear_slateupdate_list_via_turbo_stream(form_hidden: false, form_type: @agenda_item_type)else- add_before_via_turbo_stream(- component: MeetingAgendaItems::ItemComponent.new(- state: :show,- meeting_agenda_item:- ),- target_component: MeetingAgendaItems::ListComponent.new(meeting: @meeting)+ # TODO: more specific UI update as before+ update_section_via_turbo_stream(meeting_section: meeting_agenda_item.meeting_section)+ # add_before_via_turbo_stream(+ # component: MeetingAgendaItems::ItemComponent.new(+ # state: :show,+ # meeting_agenda_item:+ # ),+ # target_component: MeetingAgendaItems::ListComponent.new(meeting: @meeting)+ # )+ update_new_component_via_turbo_stream(+ hidden: false,+ meeting_section: meeting_agenda_item.meeting_section,+ type: @agenda_item_type)- update_new_component_via_turbo_stream(hidden: false, type: @agenda_item_type)update_show_items_via_turbo_streamendend@@ -169,13 +206,18 @@ module Meetingsupdate_list_via_turbo_streamelseupdate_show_items_via_turbo_stream- remove_via_turbo_stream(- component: MeetingAgendaItems::ItemComponent.new(- state: :show,- meeting_agenda_item:,- display_notes_input: nil+ if meeting_agenda_item.meeting_section.agenda_items.empty?+ # Show the empty section state by updating the whole section if items are empty+ update_section_via_turbo_stream(meeting_section: meeting_agenda_item.meeting_section)+ else+ remove_via_turbo_stream(+ component: MeetingAgendaItems::ItemComponent.new(+ state: :show,+ meeting_agenda_item:,+ display_notes_input: nil+ ))- )+ endendend@@ -194,7 +236,10 @@ module Meetingsmeeting_agenda_item: @meeting_agenda_item.lower_item)else- MeetingAgendaItems::ListComponent.new(meeting: @meeting)+ MeetingSections::ShowComponent.new(+ meeting_section: @meeting_agenda_item.meeting_section+ )+ # MeetingAgendaItems::ListComponent.new(meeting: @meeting)endadd_before_via_turbo_stream(component:, target_component:)update_show_items_via_turbo_stream@@ -215,6 +260,16 @@ module Meetings)end+ def update_section_via_turbo_stream(meeting_section: @meeting_section, form_hidden: true, form_type: :simple)+ update_via_turbo_stream(+ component: MeetingSections::ShowComponent.new(+ meeting_section:,+ form_type:,+ form_hidden:+ )+ )+ end+def update_all_via_turbo_streamupdate_header_component_via_turbo_streamupdate_sidebar_component_via_turbo_streamdiff --git a/modules/meeting/app/controllers/meeting_agenda_items_controller.rb b/modules/meeting/app/controllers/meeting_agenda_items_controller.rbindex dbef2a15100..615fd483f41 100644--- a/modules/meeting/app/controllers/meeting_agenda_items_controller.rb+++ b/modules/meeting/app/controllers/meeting_agenda_items_controller.rb@@ -40,8 +40,10 @@ class MeetingAgendaItemsController < ApplicationControllerdef newif @meeting.open?- update_new_component_via_turbo_stream(hidden: false, type: @agenda_item_type)- update_new_button_via_turbo_stream(disabled: true)+ if params[:meeting_section_id].present?+ meeting_section = @meeting.sections.find(params[:meeting_section_id])+ end+ render_agenda_item_form_via_turbo_stream(meeting_section:, type: @agenda_item_type)elseupdate_all_via_turbo_streamrender_error_flash_message_via_turbo_stream(message: t("text_meeting_not_editable_anymore"))@@ -51,7 +53,16 @@ class MeetingAgendaItemsController < ApplicationControllerenddef cancel_new- update_new_component_via_turbo_stream(hidden: true)+ if params[:meeting_section_id].present?+ meeting_section = @meeting.sections.find(params[:meeting_section_id])+ if meeting_section.agenda_items.empty?+ update_section_via_turbo_stream(form_hidden: true, meeting_section:)+ else+ update_new_button_via_turbo_stream(disabled: false, meeting_section:)+ end+ end++ update_new_component_via_turbo_stream(hidden: true, meeting_section:)update_new_button_via_turbo_stream(disabled: false)respond_with_turbo_streams@@ -197,7 +208,7 @@ class MeetingAgendaItemsController < ApplicationControllerdef meeting_agenda_item_paramsparams.require(:meeting_agenda_item)- .permit(:title, :duration_in_minutes, :presenter_id, :notes, :work_package_id, :lock_version)+ .permit(:title, :duration_in_minutes, :presenter_id, :notes, :work_package_id, :lock_version, :meeting_section_id)enddef generic_call_failure_response(call)diff --git a/modules/meeting/app/controllers/meeting_sections_controller.rb b/modules/meeting/app/controllers/meeting_sections_controller.rbindex 7cbb42db593..71c3c16a7f8 100644--- a/modules/meeting/app/controllers/meeting_sections_controller.rb+++ b/modules/meeting/app/controllers/meeting_sections_controller.rb@@ -61,7 +61,6 @@ class MeetingSectionsController < ApplicationController.new(user: current_user).call({- name: "Untitled", # TODO: i18nmeeting_id: @meeting.id})@@ -70,6 +69,8 @@ class MeetingSectionsController < ApplicationControllerif call.success?update_all_via_turbo_stream # TODO: more specific UI update+ update_section_header_via_turbo_stream(state: :edit)+ update_new_button_via_turbo_stream(disabled: true)elserender_base_error_in_flash_message_via_turbo_stream(call.errors)end@@ -89,7 +90,13 @@ class MeetingSectionsController < ApplicationControllerenddef cancel_edit- update_section_header_via_turbo_stream(state: :show)+ if @meeting_section.has_default_name? && @meeting_section.agenda_items.empty?+ # if the section has the default name and no agenda items, we can safely delete it+ destroy and return+ else+ update_section_header_via_turbo_stream(state: :show)+ update_new_button_via_turbo_stream(disabled: false)+ endrespond_with_turbo_streamsend@@ -101,6 +108,7 @@ class MeetingSectionsController < ApplicationControllerif call.success?update_section_header_via_turbo_stream(state: :show)+ update_new_button_via_turbo_stream(disabled: false)update_header_component_via_turbo_streamupdate_sidebar_details_component_via_turbo_streamelsediff --git a/modules/meeting/app/forms/meeting_agenda_item/meeting_section_form.rb b/modules/meeting/app/forms/meeting_agenda_item/meeting_section_form.rbnew file mode 100644index 00000000000..8e2c35031cb--- /dev/null+++ b/modules/meeting/app/forms/meeting_agenda_item/meeting_section_form.rb@@ -0,0 +1,40 @@+#-- 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.+#++++class MeetingAgendaItem::MeetingSectionForm < ApplicationForm+ form do |agenda_item_form|+ agenda_item_form.hidden(+ name: :meeting_section_id,+ value: @meeting_section&.id+ )+ end++ def initialize(meeting_section: nil)+ @meeting_section = meeting_section+ end+enddiff --git a/modules/meeting/app/forms/meeting_section/name.rb b/modules/meeting/app/forms/meeting_section/name.rbindex 41a69a094a4..81718c9b2ed 100644--- a/modules/meeting/app/forms/meeting_section/name.rb+++ b/modules/meeting/app/forms/meeting_section/name.rb@@ -32,9 +32,23 @@ class MeetingSection::Name < ApplicationFormname: :name,placeholder: Meeting.human_attribute_name(:title),label: Meeting.human_attribute_name(:title),+ value: init_value(meeting_section_form),visually_hide_label: true,required: true,- autofocus: true+ autofocus: true,+ data: {+ action: "keydown.esc->meeting-section-form#cancel"+ })end++ private++ def init_value(meeting_section_form)+ if meeting_section_form.builder.object.has_default_name?+ "" # will be set to "Untitled" in the model if left empty+ else+ meeting_section_form.builder.object.name+ end+ endenddiff --git a/modules/meeting/app/models/meeting_section.rb b/modules/meeting/app/models/meeting_section.rbindex 8198483b675..e3b547fe5a3 100644--- a/modules/meeting/app/models/meeting_section.rb+++ b/modules/meeting/app/models/meeting_section.rb@@ -36,10 +36,22 @@ class MeetingSection < ApplicationRecordvalidates :name, presence: true+ before_validation :set_default_name+acts_as_list scope: :meetingdefault_scope { order(:position) }+ def set_default_name+ if name.blank?+ self.name = "Untitled" # TODO: I18n+ end+ end++ def has_default_name?+ name == "Untitled" # TODO: I18n+ end+def editable?!meeting&.closed?end