-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/lookup-commands
- Loading branch information
Showing
18 changed files
with
252 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
patches/drupal/os2forms/allow_composite_elements_in_maestro_notification_recipient.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
diff --git a/modules/os2forms_forloeb/src/MaestroHelper.php b/modules/os2forms_forloeb/src/MaestroHelper.php | ||
index ce0b5fb..dfa65ca 100644 | ||
--- a/modules/os2forms_forloeb/src/MaestroHelper.php | ||
+++ b/modules/os2forms_forloeb/src/MaestroHelper.php | ||
@@ -8,6 +8,7 @@ use Drupal\advancedqueue\Entity\QueueInterface; | ||
use Drupal\advancedqueue\Job; | ||
use Drupal\advancedqueue\JobResult; | ||
use Drupal\Component\Render\MarkupInterface; | ||
+use Drupal\Component\Utility\NestedArray; | ||
use Drupal\Core\Config\ConfigFactoryInterface; | ||
use Drupal\Core\Config\ImmutableConfig; | ||
use Drupal\Core\Entity\EntityStorageInterface; | ||
@@ -466,6 +467,17 @@ class MaestroHelper implements LoggerInterface { | ||
?? $data[$recipientElement] | ||
?? NULL; | ||
|
||
+ // Handle composite elements. | ||
+ if ($recipient === NULL) { | ||
+ // Composite subelement keys consist of | ||
+ // the composite element key and the subelement key separated by '__', | ||
+ // e.g. 'contact__name'. | ||
+ if (str_contains($recipientElement, '__')) { | ||
+ $keys = explode('__', $recipientElement); | ||
+ $recipient = NestedArray::getValue($data, $keys); | ||
+ } | ||
+ } | ||
+ | ||
if ($notificationType === self::NOTIFICATION_ESCALATION) { | ||
$recipient = $settings[MaestroNotificationHandler::NOTIFICATION][$notificationType][MaestroNotificationHandler::NOTIFICATION_RECIPIENT] ?? NULL; | ||
} | ||
diff --git a/modules/os2forms_forloeb/src/Plugin/WebformHandler/MaestroNotificationHandler.php b/modules/os2forms_forloeb/src/Plugin/WebformHandler/MaestroNotificationHandler.php | ||
index d0afc20..35c32d8 100644 | ||
--- a/modules/os2forms_forloeb/src/Plugin/WebformHandler/MaestroNotificationHandler.php | ||
+++ b/modules/os2forms_forloeb/src/Plugin/WebformHandler/MaestroNotificationHandler.php | ||
@@ -99,7 +99,7 @@ final class MaestroNotificationHandler extends WebformHandlerBase { | ||
'#title' => $this->t('Notification'), | ||
]; | ||
|
||
- $availableElements = $this->getRecipientElements(); | ||
+ $availableElements = $this->getRecipientElementOptions(); | ||
$form[self::NOTIFICATION][static::RECIPIENT_ELEMENT] = [ | ||
'#type' => 'select', | ||
'#title' => $this->t('Element that contains the recipient identifier (email, CPR or CVR) of the notification'), | ||
@@ -228,7 +228,7 @@ final class MaestroNotificationHandler extends WebformHandlerBase { | ||
/** | ||
* Get recipient elements. | ||
*/ | ||
- private function getRecipientElements(): array { | ||
+ private function getRecipientElementOptions(): array { | ||
$elements = $this->getWebform()->getElementsDecodedAndFlattened(); | ||
|
||
$elementTypes = [ | ||
@@ -240,16 +240,60 @@ final class MaestroNotificationHandler extends WebformHandlerBase { | ||
'cvr_value_element', | ||
'os2forms_person_lookup', | ||
]; | ||
+ | ||
+ $isAllowedElement = static fn ($e) => in_array($e['#type'], $elementTypes, TRUE); | ||
+ | ||
+ // Expand composite elements, NOT custom composite elements. | ||
+ foreach ($elements as $key => $element) { | ||
+ $formElement = $this->getWebform()->getElement($key); | ||
+ | ||
+ if ('webform_custom_composite' === $formElement['#type']) { | ||
+ continue; | ||
+ } | ||
+ | ||
+ if (isset($formElement['#webform_composite_elements'])) { | ||
+ foreach ($formElement['#webform_composite_elements'] as $compositeElement) { | ||
+ // If composite element is not accessible ignore it. | ||
+ if (!($compositeElement['#access'] ?? TRUE)) { | ||
+ continue; | ||
+ } | ||
+ | ||
+ if ($isAllowedElement($compositeElement)) { | ||
+ // Group composite subelements. | ||
+ $elements[$element['#title']][$compositeElement['#webform_composite_key']] = [ | ||
+ '#title' => $compositeElement['#title'], | ||
+ ]; | ||
+ | ||
+ $elements[$element['#title']]['#is_composite'] = TRUE; | ||
+ } | ||
+ } | ||
+ } | ||
+ } | ||
+ | ||
$elements = array_filter( | ||
$elements, | ||
- static function (array $element) use ($elementTypes) { | ||
- return in_array($element['#type'], $elementTypes, TRUE); | ||
- } | ||
+ static fn (array $element) => $isAllowedElement($element) | ||
+ // Composite elements are already filtered, | ||
+ // i.e. they do not need to be filtered here. | ||
+ || ($element['#is_composite'] ?? FALSE) | ||
); | ||
|
||
- return array_map(static function (array $element) { | ||
- return $element['#title']; | ||
- }, $elements); | ||
+ // Get titles of remaining elements. | ||
+ return array_map( | ||
+ static function (array $element) { | ||
+ if ($element['#is_composite'] ?? FALSE) { | ||
+ | ||
+ return array_map( | ||
+ static fn (array $compositeElement) => $compositeElement['#title'], | ||
+ // Consider only elements with a title, | ||
+ // i.e. the subelements we added earlier. | ||
+ array_filter($element, static fn ($e) => isset($e['#title']))); | ||
+ } | ||
+ | ||
+ return $element['#title']; | ||
+ }, | ||
+ $elements | ||
+ ); | ||
} | ||
|
||
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
npm run build | ||
cp -v build/static/js/main.*.js dist/main.js | ||
cp -v build/static/css/main.*.css dist/main.css |
Large diffs are not rendered by default.
Oops, something went wrong.
6 changes: 5 additions & 1 deletion
6
web/modules/custom/itkdev_booking/assets/src/components/loading-spinner.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.