Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Use empty section title as untitled

Oliver Günther134b567ebdec
diff --git a/modules/meeting/app/components/meeting_sections/header_component.html.erb b/modules/meeting/app/components/meeting_sections/header_component.html.erb
index d421dc95986..f15d8c6f5ca 100644
--- a/modules/meeting/app/components/meeting_sections/header_component.html.erb
+++ b/modules/meeting/app/components/meeting_sections/header_component.html.erb
@@ -9,7 +9,7 @@
end
grid.with_area(:content, tag: :span) do
render(Primer::Beta::Text.new(font_weight: :bold, mr: 2)) do
- @meeting_section.title
+ @meeting_section.title.presence || I18n.t("meeting_section.untitled_title")
end
end
if @meeting_section.agenda_items_sum_duration_in_minutes > 0
@@ -25,7 +25,7 @@
menu.with_show_button(icon: "kebab-horizontal", 'aria-label': t("settings.project_attributes.label_section_actions"), scheme: :invisible)
edit_action_item(menu)
unless first? && last?
- menu.with_divider
+ menu.with_divider
move_actions(menu)
end
menu.with_divider
diff --git a/modules/meeting/app/contracts/meeting_sections/create_contract.rb b/modules/meeting/app/contracts/meeting_sections/create_contract.rb
index 7486bf1c1a0..f0b6794cf94 100644
--- a/modules/meeting/app/contracts/meeting_sections/create_contract.rb
+++ b/modules/meeting/app/contracts/meeting_sections/create_contract.rb
@@ -28,7 +28,12 @@
module MeetingSections
class CreateContract < BaseContract
- validate :user_allowed_to_add, :validate_meeting_existence
+ validate :user_allowed_to_add,
+ :validate_meeting_existence
+
+ # We allow an empty title to mark an untitled/implicit section
+ # but users should not be able to create it with an empty title
+ validates :title, presence: true
def self.assignable_meetings(user)
StructuredMeeting
diff --git a/modules/meeting/app/models/meeting_agenda_item.rb b/modules/meeting/app/models/meeting_agenda_item.rb
index cd52da17a98..3f26a4c8221 100644
--- a/modules/meeting/app/models/meeting_agenda_item.rb
+++ b/modules/meeting/app/models/meeting_agenda_item.rb
@@ -78,7 +78,7 @@ class MeetingAgendaItem < ApplicationRecord
meeting_section = meeting.sections.order(position: :asc).last
if meeting_section.nil?
- meeting_section = meeting.sections.build(title: "Untitled")
+ meeting_section = meeting.sections.build(title: "")
end
self.meeting_section = meeting_section
diff --git a/modules/meeting/app/models/meeting_section.rb b/modules/meeting/app/models/meeting_section.rb
index 0acb98b6824..21184bc660f 100644
--- a/modules/meeting/app/models/meeting_section.rb
+++ b/modules/meeting/app/models/meeting_section.rb
@@ -34,10 +34,6 @@ class MeetingSection < ApplicationRecord
has_many :agenda_items, dependent: :destroy, class_name: "MeetingAgendaItem"
has_one :project, through: :meeting
- validates :title, presence: true
-
- before_validation :set_default_title
-
after_save :trigger_meeting_agenda_item_time_slots_calculation, if: Proc.new { |section|
section.position_previously_changed?
}
@@ -50,18 +46,12 @@ class MeetingSection < ApplicationRecord
meeting.calculate_agenda_item_time_slots
end
- def set_default_title
- if title.blank?
- self.title = I18n.t("meeting_section.default_title")
- end
- end
-
def has_default_title?
title == I18n.t("meeting_section.default_title")
end
def untitled?
- title == I18n.t("meeting_section.untitled_title")
+ title.blank?
end
def editable?
diff --git a/modules/meeting/db/migrate/20240516102219_fix_untitled_meetings.rb b/modules/meeting/db/migrate/20240516102219_fix_untitled_meetings.rb
new file mode 100644
index 00000000000..6909ee6af41
--- /dev/null
+++ b/modules/meeting/db/migrate/20240516102219_fix_untitled_meetings.rb
@@ -0,0 +1,9 @@
+class FixUntitledMeetings < ActiveRecord::Migration[7.1]
+ def up
+ MeetingSection.where(title: "Untitled").update_all(title: "")
+ end
+
+ def down
+ MeetingSection.where(title: "").update_all(title: "Untitled")
+ end
+end