diff --git a/History.md b/History.md index b72cb767f9..c2cb3bff6c 100644 --- a/History.md +++ b/History.md @@ -18,15 +18,13 @@ - The motion list can now be filtered for To Do items (that is, motions/amendments that need to be screened) and also shows the To Do action for items on that list as part of the Status. - The motion list now persists its filter and sort settings for each user session, until changed or reset. - If an amendment is set to show the full text by default, this now also affects the PDF export. +- Merging a single amendment into a motion now also handles amendments only changing the title of the motion. +- The maintenance mode page is now specific to a consultation; that is, delegates bookmarking a link to a consultation that is still in maintenance mode can open that bookmark later and get to theat very consultation, not the generic home page. - Bugfix: If a draft of a revised motion (by merging amendments) existed and the motion list was opened, the original motion was not shown anymore by default. - Bugfix: Some edge cases around uploaded logos breaking the PDF export or not being shown on the page were resolved. - Bugfix: Super-admins could lock themselves out of protected consultations. - Bugfix: Putting a active speaker back into the speaking waiting list did not work - the speaker vanished from the list completely. - Bugfix: Closing the full screen mode of a speaking list was leading to an error page. - -### Version 4.12.1 [not released yet] - -- The maintenance mode page is now specific to a consultation; that is, delegates bookmarking a link to a consultation that is still in maintenance mode can open that bookmark later and get to theat very consultation, not the generic home page. - Bugfix: If not-logged-in users are allowed to support motions/amendments, they showed up as empty bullet points in the supporter list. Now they have to enter their name. - Bugfix: The delete button in the admin motion list was shown even if no delete permissions were granted and it was therefore non-functional. - Bugfix: If a motion collecting supporters was edited by an admin, then no publication mail was sent later when it was actually published. diff --git a/controllers/AmendmentMergingTrait.php b/controllers/AmendmentMergingTrait.php index 4efb2c717d..ab618eb977 100644 --- a/controllers/AmendmentMergingTrait.php +++ b/controllers/AmendmentMergingTrait.php @@ -133,7 +133,7 @@ public function actionMerge(string $motionSlug, int $amendmentId): ResponseInter $this->getPostValue('motionTitlePrefix'), $this->getPostValue('motionVersion'), $this->getPostValue('amendmentStatus'), - $this->getPostValue('newParas'), + $this->getPostValue('newParas', []), $this->getPostValue('amendmentOverride', []), $newAmendmentStatuses ); diff --git a/models/forms/MergeSingleAmendmentForm.php b/models/forms/MergeSingleAmendmentForm.php index e031b6a05a..1d39b934b7 100644 --- a/models/forms/MergeSingleAmendmentForm.php +++ b/models/forms/MergeSingleAmendmentForm.php @@ -11,32 +11,18 @@ class MergeSingleAmendmentForm { public Motion $oldMotion; public ?Motion $newMotion = null; - public string $newTitlePrefix; - public string $newVersion; - public Amendment $mergeAmendment; - public int $mergeAmendStatus; - public array $otherAmendStatuses; - public array $otherAmendOverrides; - public array $paragraphs; public function __construct( - Amendment $amendment, - string $newTitlePrefix, - string $newVersion, - int $newStatus, - array $paragraphs, - array $otherAmendOverrides, - array $otherAmendStatuses + public Amendment $mergeAmendment, + public string $newTitlePrefix, + public string $newVersion, + public int $mergeAmendStatus, + public array $paragraphs, + public array $otherAmendOverrides, + public array $otherAmendStatuses ) { - $this->newTitlePrefix = $newTitlePrefix; - $this->newVersion = $newVersion; - $this->oldMotion = $amendment->getMyMotion(); - $this->mergeAmendment = $amendment; - $this->mergeAmendStatus = $newStatus; - $this->paragraphs = $paragraphs; - $this->otherAmendStatuses = $otherAmendStatuses; - $this->otherAmendOverrides = $otherAmendOverrides; + $this->oldMotion = $mergeAmendment->getMyMotion(); } private function getNewHtmlParas(): array @@ -141,6 +127,9 @@ private function createNewMotionSections(): void $newSection->dataRaw = ''; } } + if ($section->getSettings()->type === ISectionType::TYPE_TITLE && $this->mergeAmendment->getSection($section->sectionId)) { + $newSection->setData($this->mergeAmendment->getSection($section->sectionId)->getData()); + } if (!$newSection->save()) { throw new DB($newSection->getErrors()); } @@ -175,6 +164,15 @@ private function rewriteOtherAmendments(): void throw new DB($section->getErrors()); } } + foreach ($amendment->getActiveSections(ISectionType::TYPE_TITLE) as $section) { + foreach ($this->oldMotion->sections as $motionSection) { + if ($motionSection->sectionId === $section->sectionId && $motionSection->getData() === $section->getData() && $this->mergeAmendment->getSection($section->sectionId)) { + // Change the title of amendments that didn't try to change the title of the motion + $section->setData($this->mergeAmendment->getSection($section->sectionId)->getData()); + $section->save(); + } + } + } $amendment->motionId = $this->newMotion->id; $amendment->cache = ''; $amendment->status = $this->otherAmendStatuses[$amendment->id]; @@ -232,6 +230,8 @@ public function performRewrite(): Motion $consultation->save(); } + $this->newMotion->refreshTitle(); + $this->newMotion->save(); $this->newMotion->trigger(Motion::EVENT_MERGED, new MotionEvent($this->newMotion)); return $this->newMotion;