Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
e235368
Fix certificate testing, and allowing RSA certs as well as pkcs12
inuitviking Oct 25, 2023
37a7cb2
Certificate testing now properly checks PEM as well as pkcs12 certifi…
inuitviking Oct 27, 2023
9bc4e80
Updated changelog
inuitviking Oct 27, 2023
1dab170
Add empty line at end of changelog
inuitviking Oct 27, 2023
60f842f
Added empty line at end of SettingsForm.php
inuitviking Oct 27, 2023
2cd53b4
Fix markdown formatting in changelog
inuitviking Oct 27, 2023
d86a28c
Fix deprecation error in SettingsForm.php
inuitviking Oct 27, 2023
03106e6
Fix markdownlint error
inuitviking Oct 27, 2023
b6dc947
Fix too many empty lines
inuitviking Oct 27, 2023
963382c
Handled nested elements in webform inherit
rimi-itk Oct 27, 2023
2b28709
SUPP0RT-1293: Allowed composite elements in Maestro notification reci…
jekuaitk Nov 8, 2023
0bb05b0
SUPP0RT-1293: Updated CHANGELOG
jekuaitk Nov 8, 2023
4bfe843
SUPP0RT-1293: Cleanup
jekuaitk Nov 8, 2023
4303abd
SUPP0RT-1293: Applied coding standards
jekuaitk Nov 8, 2023
3c4fda0
SUPP0RT-1293: Cleanup
jekuaitk Nov 8, 2023
6822b80
SUPP0RT-1293: Applied coding standards
jekuaitk Nov 8, 2023
da8190a
Merge pull request #73 from itk-dev/feature/nested-inherited-webform-…
rimi-itk Nov 8, 2023
b4a8755
Merge branch 'develop' into feature/SUPP0RT-1293-allow-composite-elem…
rimi-itk Nov 8, 2023
0e30622
SUPP0RT-1293: Ignored custom composite elements
jekuaitk Nov 9, 2023
a19b7b6
SUPP0RT-1293: Applied coding standards
jekuaitk Nov 9, 2023
fa446a4
Undo all of my previous changes
inuitviking Nov 9, 2023
48526ac
Add an empty line as required by coding standards.
inuitviking Nov 9, 2023
a335a74
Add an empty line as required by coding standards.
inuitviking Nov 9, 2023
e5437ac
Fix newlines in the end of files
inuitviking Nov 9, 2023
b24cc4d
Fix newline on CHANGELOG
inuitviking Nov 9, 2023
a667657
Fix tab formatting
inuitviking Nov 9, 2023
0b4f9ad
Remove mention of #72 in CHANGELOG.md
inuitviking Nov 10, 2023
cfb3c1c
Merge pull request #75 from OS2Forms/inuitviking/removing_my_own_darn…
inuitviking Nov 10, 2023
1efe75e
Fixed submission logging
rimi-itk Nov 27, 2023
ee3ce19
changed color field types from input_color to textfield
jeppekroghitk Nov 29, 2023
5646a2b
updated changelog
jeppekroghitk Nov 30, 2023
344e816
Merge pull request #77 from itk-dev/feature/map-additions
jeppekroghitk Dec 4, 2023
2c47532
Merge pull request #74 from OS2Forms/feature/SUPP0RT-1293-allow-compo…
jekuaitk Dec 5, 2023
068cb52
Merge branch 'develop' into feature/digital-post-submission-logging
jekuaitk Dec 5, 2023
a62008d
Merge pull request #76 from itk-dev/feature/digital-post-submission-l…
jekuaitk Dec 5, 2023
f443f67
Preparing 3.13.3
jekuaitk Dec 5, 2023
664589b
Merge pull request #78 from OS2Forms/release/3.13.3
jekuaitk Dec 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ before starting to add changes. Use example [placed in the end of the page](#exa

## [Unreleased]

## [3.13.3] 2023-12-05

- [#76](https://github.com/OS2Forms/os2forms/pull/76)
Fixed digital post logging on submissions.
- [#74](https://github.com/OS2Forms/os2forms/pull/74)
Allow composite elements in Maestro notification recipient
- [#73](https://github.com/OS2Forms/os2forms/pull/73a)
Fix issue with nested elements in webform inherit
- [#77](https://github.com/OS2Forms/os2forms/pull/77)
Fix color picker fields in os2forms_webform_maps

## [3.13.2] 2023-10-19

- Fixing CPR fetch pattern
Expand Down Expand Up @@ -179,7 +190,28 @@ before starting to add changes. Use example [placed in the end of the page](#exa
- Security in case of vulnerabilities.
```

[Unreleased]: https://github.com/OS2Forms/os2forms/compare/3.5.0...HEAD
[3.5.0]: https://github.com/OS2Forms/os2forms/compare/3.2.5...3.5.0
[Unreleased]: https://github.com/OS2Forms/os2forms/compare/3.13.3...HEAD
[3.13.3]: https://github.com/OS2Forms/os2forms/compare/3.13.2...3.13.3
[3.13.2]: https://github.com/OS2Forms/os2forms/compare/3.13.1...3.13.2
[3.13.1]: https://github.com/OS2Forms/os2forms/compare/3.13.0...3.13.1
[3.13.0]: https://github.com/OS2Forms/os2forms/compare/3.12.2...3.13.0
[3.12.2]: https://github.com/OS2Forms/os2forms/compare/3.12.1...3.12.2
[3.12.1]: https://github.com/OS2Forms/os2forms/compare/3.12.0...3.12.1
[3.12.0]: https://github.com/OS2Forms/os2forms/compare/3.11.0...3.12.0
[3.11.0]: https://github.com/OS2Forms/os2forms/compare/3.10.0...3.11.0
[3.10.0]: https://github.com/OS2Forms/os2forms/compare/3.9.0...3.10.0
[3.9.0]: https://github.com/OS2Forms/os2forms/compare/3.8.3...3.9.0
[3.8.3]: https://github.com/OS2Forms/os2forms/compare/3.8.2...3.8.3
[3.8.2]: https://github.com/OS2Forms/os2forms/compare/3.8.1...3.8.2
[3.8.1]: https://github.com/OS2Forms/os2forms/compare/3.8.0...3.8.1
[3.8.0]: https://github.com/OS2Forms/os2forms/compare/3.7.0...3.8.0
[3.7.0]: https://github.com/OS2Forms/os2forms/compare/3.6.0...3.7.0
[3.6.0]: https://github.com/OS2Forms/os2forms/compare/3.5.0...3.6.0
[3.5.0]: https://github.com/OS2Forms/os2forms/compare/3.4.0...3.5.0
[3.4.0]: https://github.com/OS2Forms/os2forms/compare/3.3.0...3.4.0
[3.3.0]: https://github.com/OS2Forms/os2forms/compare/3.2.9...3.3.0
[3.2.9]: https://github.com/OS2Forms/os2forms/compare/3.2.8...3.2.9
[3.2.8]: https://github.com/OS2Forms/os2forms/compare/3.2.7...3.2.8
[3.2.7]: https://github.com/OS2Forms/os2forms/compare/3.2.6...3.2.7
[3.2.6]: https://github.com/OS2Forms/os2forms/compare/3.2.5...3.2.6
[3.2.5]: https://github.com/OS2Forms/os2forms/compare/3.2.4...3.2.5
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:

logger.channel.os2forms_digital_post_submission:
parent: logger.channel_base
arguments: [ 'os2forms_digital_post_submission' ]
arguments: [ 'webform_submission' ]

Drupal\os2forms_digital_post\Helper\Settings:
arguments:
Expand Down
18 changes: 8 additions & 10 deletions modules/os2forms_digital_post/src/Helper/WebformHelperSF1601.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ public function log($level, $message, array $context = []): void {
*/
public function createJob(WebformSubmissionInterface $webformSubmission, array $handlerConfiguration): ?Job {
$context = [
'handler_id' => 'os2forms_digital_post',
'webform_submission' => $webformSubmission,
];

Expand All @@ -230,15 +231,13 @@ public function createJob(WebformSubmissionInterface $webformSubmission, array $
$queue->enqueueJob($job);
$context['@queue'] = $queue->id();
$this->notice('Job for sending digital post add to the queue @queue.', $context + [
'handler_id' => 'os2forms_digital_post',
'operation' => 'digital post queued for sending',
]);

return $job;
}
catch (\Exception $exception) {
$this->error('Error creating job for sending digital post.', $context + [
'handler_id' => 'os2forms_digital_post',
'operation' => 'digital post failed',
]);
return NULL;
Expand All @@ -253,6 +252,10 @@ public function createJob(WebformSubmissionInterface $webformSubmission, array $
public function processJob(Job $job): JobResult {
$payload = $job->getPayload();

$context = [
'handler_id' => 'os2forms_digital_post',
'operation' => 'digital post send',
];
try {
$submissionId = $payload['submissionId'];
$submission = $this->loadSubmission($submissionId);
Expand All @@ -267,21 +270,16 @@ public function processJob(Job $job): JobResult {
$message));
}

$context['webform_submission'] = $submission;
$this->sendDigitalPost($submission, $payload['handlerConfiguration']);

$this->notice('Digital post sent', [
'handler_id' => 'os2forms_digital_post',
'operation' => 'digital post send',
'webform_submission' => $submission,
]);
$this->notice('Digital post sent', $context);

return JobResult::success();
}
catch (\Exception $e) {
$this->error('Error: @message', [
$this->error('Error: @message', $context + [
'@message' => $e->getMessage(),
'handler_id' => 'os2forms_digital_post',
'operation' => 'digital post send',
]);

return JobResult::failure($e->getMessage());
Expand Down
12 changes: 12 additions & 0 deletions modules/os2forms_forloeb/src/MaestroHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
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;
Expand Down Expand Up @@ -466,6 +467,17 @@ public function renderNotification(WebformSubmissionInterface $submission, strin
?? $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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

namespace Drupal\os2forms_forloeb\Plugin\EngineTasks;

use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Form\FormStateInterface;
use Drupal\maestro\Engine\MaestroEngine;
use Drupal\maestro_webform\Plugin\EngineTasks\MaestroWebformTask;
use Drupal\webform\Entity\Webform;
use Drupal\webform\Entity\WebformSubmission;
use Drupal\webform\Utility\WebformArrayHelper;

Expand Down Expand Up @@ -152,9 +154,18 @@ public static function webformSubmissionFormAlter(array &$form, FormStateInterfa
if ('webform_submission' === ($entityIdentifier['entity_type'] ?? NULL)) {
$submission = WebformSubmission::load($entityIdentifier['entity_id']);
$data = $submission->getData();
foreach ($data as $key => $value) {
if (isset($form['elements'][$key])) {
$form['elements'][$key]['#default_value'] = $value;

// The target element may be hidden inside sections or field groups
// on the target form. Therefore, we need to load that form and get
// element information to properly set default element values nested
// inside the form.
if ($targetWebform = Webform::load($form['#webform_id'] ?? NULL)) {
foreach ($data as $key => $value) {
if ($targetElement = $targetWebform->getElement($key)) {
if ($element = &NestedArray::getValue($form['elements'], $targetElement['#webform_parents'])) {
$element['#default_value'] = $value;
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $formStat
'#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'),
Expand Down Expand Up @@ -228,7 +228,7 @@ public function validateConfigurationForm(array &$form, FormStateInterface $form
/**
* Get recipient elements.
*/
private function getRecipientElements(): array {
private function getRecipientElementOptions(): array {
$elements = $this->getWebform()->getElementsDecodedAndFlattened();

$elementTypes = [
Expand All @@ -240,16 +240,60 @@ private function getRecipientElements(): array {
'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
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public function form(array $form, FormStateInterface $form_state) {
],
],
'polyline_color' => [
'#type' => 'input_color',
'#type' => 'textfield',
'#title' => 'Color',
'#description' => $this->t('Enter value as HEX or CSS color'),
],
Expand All @@ -199,7 +199,7 @@ public function form(array $form, FormStateInterface $form_state) {
'#title' => 'Prevent Intersection',
],
'polyline_error_color' => [
'#type' => 'input_color',
'#type' => 'textfield',
'#title' => 'Error color',
'#description' => $this->t('Enter value as HEX or CSS color'),
'#states' => [
Expand Down Expand Up @@ -233,7 +233,7 @@ public function form(array $form, FormStateInterface $form_state) {
],
],
'rectangle_color' => [
'#type' => 'input_color',
'#type' => 'textfield',
'#title' => 'Color',
'#description' => $this->t('Enter value as HEX or CSS color'),
],
Expand All @@ -253,7 +253,7 @@ public function form(array $form, FormStateInterface $form_state) {
],
],
'polygon_color' => [
'#type' => 'input_color',
'#type' => 'textfield',
'#title' => 'Color',
'#description' => $this->t('Enter value as HEX or CSS color'),
],
Expand All @@ -262,7 +262,7 @@ public function form(array $form, FormStateInterface $form_state) {
'#title' => 'Prevent Intersection',
],
'polygon_error_color' => [
'#type' => 'input_color',
'#type' => 'textfield',
'#title' => 'Error color',
'#states' => [
'invisible' => [
Expand Down Expand Up @@ -296,7 +296,7 @@ public function form(array $form, FormStateInterface $form_state) {
],
],
'circle_color' => [
'#type' => 'input_color',
'#type' => 'textfield',
'#title' => 'Color',
'#description' => $this->t('Enter value as HEX or CSS color'),
],
Expand Down
1 change: 1 addition & 0 deletions src/Form/SettingsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
}

$this->messenger()->addStatus($this->t('The configuration options have been saved.'));

}

}