diff --git a/CHANGELOG.md b/CHANGELOG.md index 3912803..3feb966 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,22 @@ before starting to add changes. Use example [placed in the end of the page](#exa ## [Unreleased] +## Patch release selvbetjening 4.7.0 + +- [PR-222](https://github.com/OS2Forms/os2forms/pull/222) + - Correctly sets sender label on Maestro digital post notifications. +- [PR-215](https://github.com/OS2Forms/os2forms/pull/215) + - Added condition to maestro notification submission handler +- [PR-192](https://github.com/OS2Forms/os2forms/pull/192) + - Fix bug in MitidChildrenSelectAjaxBehaviour.php +- [PR-187](https://github.com/OS2Forms/os2forms/pull/187) + - Avoid double-saving submissions when handling name and address protection. +- [PR-184](https://github.com/OS2Forms/os2forms/pull/184) + - Patches `coc_forms_auto_export` to ensure settings can be saved upon initial + attempt, cf. [Unable to save initial settings due to unfocusable form control](https://www.drupal.org/project/coc_forms_auto_export/issues/3531004) + +## Patch release selvbetjening 4.6.0 + - [PR-189](https://github.com/OS2Forms/os2forms/pull/189) - Added support for MeMo 1.2 and added additional validation of MeMo actions. - [PR-202](https://github.com/OS2Forms/os2forms/pull/202) diff --git a/composer.json b/composer.json index 8a95071..acf3151 100644 --- a/composer.json +++ b/composer.json @@ -115,7 +115,8 @@ "enable-patching": true, "patches": { "drupal/coc_forms_auto_export": { - "3256951: - Unable to receive attachments in emails sent": "https://git.drupalcode.org/project/coc_forms_auto_export/-/merge_requests/11.diff" + "3256951: - Unable to receive attachments in emails sent": "https://git.drupalcode.org/project/coc_forms_auto_export/-/merge_requests/11.diff", + "3531004: Unable to save initial settings due to unfocusable form control": "https://www.drupal.org/files/issues/2025-06-19/text_area_with_text_edit_always_fails_reqired_set_via_states.patch" }, "drupal/entity_print": { "2733781 - Add Export to Word Support": "https://www.drupal.org/files/issues/2019-11-22/2733781-47.patch" diff --git a/modules/os2forms_forloeb/src/MaestroHelper.php b/modules/os2forms_forloeb/src/MaestroHelper.php index 42dbd77..950e488 100644 --- a/modules/os2forms_forloeb/src/MaestroHelper.php +++ b/modules/os2forms_forloeb/src/MaestroHelper.php @@ -246,6 +246,7 @@ private function sendNotification( || $handler->isDisabled() || $handler->isExcluded() || !$handler->isNotificationEnabled($notificationType) + || !$handler->checkConditions($submission) ) { continue; } @@ -257,13 +258,14 @@ private function sendNotification( 'subject' => $subject, 'taskUrl' => $taskUrl, 'actionLabel' => $actionLabel, + 'senderLabel' => $senderLabel, ] = $this->renderNotification($submission, $handler->getHandlerId(), $notificationType, $templateTask, $maestroQueueID); if ('email' === $contentType) { $this->sendNotificationEmail($recipient, $subject, $content, $submission, $notificationType); } else { - $this->sendNotificationDigitalPost($recipient, $subject, $content, $taskUrl, $actionLabel, $submission, $notificationType); + $this->sendNotificationDigitalPost($recipient, $subject, $content, $taskUrl, $actionLabel, $submission, $notificationType, $senderLabel); } } } @@ -313,7 +315,7 @@ private function loadQueue(): QueueInterface { * @param \Drupal\webform\WebformSubmissionInterface $submission * The webform submission. * @param string $notificationType - * The notification type (one of the NOTIFICATION_* constannts). + * The notification type (one of the NOTIFICATION_* constants). */ private function sendNotificationEmail( string $recipient, @@ -378,7 +380,9 @@ private function sendNotificationEmail( * @param \Drupal\webform\WebformSubmissionInterface $submission * The webform submission. * @param string $notificationType - * The notification type (one of the NOTIFICATION_* constannts). + * The notification type (one of the NOTIFICATION_* constants). + * @param string $senderLabel + * The sender label. */ private function sendNotificationDigitalPost( string $recipient, @@ -388,6 +392,7 @@ private function sendNotificationDigitalPost( string $actionLabel, WebformSubmissionInterface $submission, string $notificationType, + string $senderLabel, ): void { try { $document = new Document( @@ -396,7 +401,6 @@ private function sendNotificationDigitalPost( $subject . '.pdf' ); - $senderLabel = $subject; $messageLabel = $subject; // Remove all non-digits from recipient identifier. @@ -449,13 +453,13 @@ private function sendNotificationDigitalPost( * @param string $handlerId * The handler ID. * @param string $notificationType - * The notification type (one of the NOTIFICATION_* constannts). + * The notification type (one of the NOTIFICATION_* constants). * @param array $templateTask * The Maestro template task. * @param int $maestroQueueID * The Maestro queue ID. * @param string|null $contentType - * Optional content type. If not set the content type will be compoted based + * Optional content type. If not set the content type will be computed based * on the recipient. * * @return array @@ -466,6 +470,7 @@ private function sendNotificationDigitalPost( * - subject * - taskUrl (for digital post) * - actionLabel (for digital post) + * - senderLabel (for digital post) * * @see self::renderHtml() */ @@ -473,6 +478,12 @@ public function renderNotification(WebformSubmissionInterface $submission, strin $handler = $submission->getWebform()->getHandler($handlerId); $settings = $handler->getSettings(); + $senderLabel = $settings[MaestroNotificationHandler::NOTIFICATION][MaestroNotificationHandler::SENDER_LABEL] ?? NULL; + + if (NULL === $senderLabel) { + throw new RuntimeException(sprintf('Cannot get setting for Maestro notification: %s', MaestroNotificationHandler::SENDER_LABEL)); + } + $data = $submission->getData(); $recipientElement = $settings[MaestroNotificationHandler::NOTIFICATION][MaestroNotificationHandler::RECIPIENT_ELEMENT] ?? NULL; // Handle os2forms_person_lookup element. @@ -571,6 +582,7 @@ public function renderNotification(WebformSubmissionInterface $submission, strin 'subject' => $subject, 'taskUrl' => $taskUrl, 'actionLabel' => $actionLabel, + 'senderLabel' => $senderLabel, ]; } diff --git a/modules/os2forms_nemid/os2forms_nemid.module b/modules/os2forms_nemid/os2forms_nemid.module index 2d11ae8..b224847 100644 --- a/modules/os2forms_nemid/os2forms_nemid.module +++ b/modules/os2forms_nemid/os2forms_nemid.module @@ -469,5 +469,4 @@ function os2forms_nemid_submission_set_address_protected(array $form, FormStateI $data = $webformSubmission->getData(); $data['os2forms_nemid_elements_nemid_address_protected'] = TRUE; $webformSubmission->setData($data); - $webformSubmission->save(); } diff --git a/modules/os2forms_nemid/src/Element/MitidChildrenSelectAjaxBehaviour.php b/modules/os2forms_nemid/src/Element/MitidChildrenSelectAjaxBehaviour.php index e88c218..c38f94c 100644 --- a/modules/os2forms_nemid/src/Element/MitidChildrenSelectAjaxBehaviour.php +++ b/modules/os2forms_nemid/src/Element/MitidChildrenSelectAjaxBehaviour.php @@ -45,6 +45,10 @@ public static function mitidChildrenSelectAjax(array &$form, FormStateInterface if ($cprPlugin->isReady()) { $cprLookupResult = $cprPlugin->lookup($childCpr); + if (!$cprLookupResult->isSuccessful()) { + return $response; + } + /** @var \Drupal\webform\WebformSubmissionForm $webformSubmissionForm */ $webformSubmissionForm = $form_state->getFormObject(); /** @var \Drupal\webform\WebformSubmissionInterface $webformSubmission */ diff --git a/modules/os2forms_nemid/src/Plugin/WebformElement/NemidAddress.php b/modules/os2forms_nemid/src/Plugin/WebformElement/NemidAddress.php index fc3ba6f..2f64332 100644 --- a/modules/os2forms_nemid/src/Plugin/WebformElement/NemidAddress.php +++ b/modules/os2forms_nemid/src/Plugin/WebformElement/NemidAddress.php @@ -47,9 +47,18 @@ public function alterForm(array &$element, array &$form, FormStateInterface $for // Only manipulate element on submission create form. if (!$webformSubmission->isCompleted()) { if ($cprLookupResult && $cprLookupResult->isNameAddressProtected()) { - $element['#info_message'] = 'adresse beskyttelse'; NestedArray::setValue($form['elements'], $element['#webform_parents'], $element); - $form['actions']['submit']['#submit'][] = 'os2forms_nemid_submission_set_address_protected'; + + // It is important the 'os2forms_nemid_submission_set_address_protected' + // submit action is executed before the 'save' action. Otherwise, + // submissions are both created and completed, resulting in unexpected + // behavior, e.g. handlers being run twice. + if (isset($form['actions']['submit']['#submit']) && is_array($form['actions']['submit']['#submit'])) { + array_unshift($form['actions']['submit']['#submit'], 'os2forms_nemid_submission_set_address_protected'); + } + else { + $form['actions']['submit']['#submit'][] = 'os2forms_nemid_submission_set_address_protected'; + } } } else { diff --git a/modules/os2forms_nemid/src/Plugin/WebformElement/NemidPrepopulateFieldInterface.php b/modules/os2forms_nemid/src/Plugin/WebformElement/NemidPrepopulateFieldInterface.php index c107105..74867f7 100644 --- a/modules/os2forms_nemid/src/Plugin/WebformElement/NemidPrepopulateFieldInterface.php +++ b/modules/os2forms_nemid/src/Plugin/WebformElement/NemidPrepopulateFieldInterface.php @@ -14,7 +14,7 @@ interface NemidPrepopulateFieldInterface { /** * String representation of the prepopulate field key. * - * Is used to prepopulate the field from the corresponding plugin.. + * Is used to prepopulate the field from the corresponding plugin. * * @param array $element * The element to prepopulate value for. diff --git a/modules/os2forms_nemid/src/Service/FormsHelper.php b/modules/os2forms_nemid/src/Service/FormsHelper.php index 7ac569e..f4a7fe8 100644 --- a/modules/os2forms_nemid/src/Service/FormsHelper.php +++ b/modules/os2forms_nemid/src/Service/FormsHelper.php @@ -268,7 +268,7 @@ public function retrieveCompanyLookupResult(FormStateInterface $form_state) { } /** - * Performs lookup of the company data.. + * Performs lookup of the company data. * * Uses CVR or P-number based services depending on the available values. *