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
Make a distinction of modifying and editing agenda items for better handling of deleted wps. Fix bug on rendering edit errors on agenda items with wps.
Dombi Attila637864c8ac25
diff --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 e0cd4ebb163..594eaceef7e 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@@ -35,11 +35,7 @@ module MeetingAgendaItemssuper@meeting_agenda_item = meeting_agenda_item- @type = if @meeting_agenda_item.work_package.present?- :work_package- else- :simple- end+ @type = @meeting_agenda_item.item_type.to_symenddef calldiff --git a/modules/meeting/app/contracts/meeting_agenda_items/editable_item.rb b/modules/meeting/app/contracts/meeting_agenda_items/editable_item.rbindex 5a2a0d3e6e6..dfdf3f8c67c 100644--- a/modules/meeting/app/contracts/meeting_agenda_items/editable_item.rb+++ b/modules/meeting/app/contracts/meeting_agenda_items/editable_item.rb@@ -37,7 +37,7 @@ module MeetingAgendaItemsprotecteddef validate_editable- unless model.editable?+ unless model.modifiable?errors.add :base, I18n.t(:text_meeting_not_editable_anymore)endenddiff --git a/modules/meeting/app/models/meeting_agenda_item.rb b/modules/meeting/app/models/meeting_agenda_item.rbindex 665afd2728d..4bff2675971 100644--- a/modules/meeting/app/models/meeting_agenda_item.rb+++ b/modules/meeting/app/models/meeting_agenda_item.rb@@ -46,7 +46,10 @@ class MeetingAgendaItem < ApplicationRecordvalidates :meeting_id, presence: truevalidates :title, presence: true, if: Proc.new { |item| item.simple? }validates :work_package_id, presence: true, if: Proc.new { |item| item.work_package? }, on: :create-+ validates :work_package_id,+ presence: true,+ if: Proc.new { |item| item.work_package? && item.work_package_id_changed? },+ on: :updatevalidates :duration_in_minutes,numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 1440 },allow_nil: true@@ -70,10 +73,14 @@ class MeetingAgendaItem < ApplicationRecordenddef deleted_work_package?- persisted? && item_type == "work_package" && work_package_id.nil?+ persisted? && item_type == "work_package" && work_package_id_was.nil?enddef editable?!meeting&.closed? && !deleted_work_package?end++ def modifiable?+ !meeting&.closed? && !(deleted_work_package? && work_package_id.present?)+ endenddiff --git a/modules/meeting/spec/models/meeting_agenda_item_spec.rb b/modules/meeting/spec/models/meeting_agenda_item_spec.rbindex 2eef69aecc1..4553d5af7a6 100644--- a/modules/meeting/spec/models/meeting_agenda_item_spec.rb+++ b/modules/meeting/spec/models/meeting_agenda_item_spec.rb@@ -249,16 +249,36 @@ RSpec.describe MeetingAgendaItem docontext 'and the agenda_item is persisted' dolet(:meeting_agenda_item) { build_stubbed(:meeting_agenda_item, meeting:, **attributes) }- context 'and work_package_id is missing' do+ context 'and work_package_id was originally missing' dolet(:work_package_id) { nil }- it { is_expected.to be true }+ context 'and now is present' do+ before do+ meeting_agenda_item.work_package_id = 1+ end++ it { is_expected.to be true }+ end++ context 'and now is also missing' do+ it { is_expected.to be true }+ endend- context 'and work_package_id is present' do+ context 'and work_package_id was originally present' dolet(:work_package_id) { 1 }- it { is_expected.to be false }+ context 'and now is also present' do+ it { is_expected.to be false }+ end++ context 'and now is missing' do+ before do+ meeting_agenda_item.work_package_id = nil+ end++ it { is_expected.to be false }+ endendendend