From 7f6bef5845d875b1a7b765e5b5a8e90cae170619 Mon Sep 17 00:00:00 2001 From: Stanislav Kutasevits Date: Tue, 20 Jun 2023 15:27:00 +0300 Subject: [PATCH 1/5] OS-55 - DAWA autocomplete required fix --- .../Element/DawaElementAddressMatrikula.php | 109 +++++++++--------- 1 file changed, 54 insertions(+), 55 deletions(-) diff --git a/modules/os2forms_dawa/src/Element/DawaElementAddressMatrikula.php b/modules/os2forms_dawa/src/Element/DawaElementAddressMatrikula.php index 9583cf90..16c7ba02 100644 --- a/modules/os2forms_dawa/src/Element/DawaElementAddressMatrikula.php +++ b/modules/os2forms_dawa/src/Element/DawaElementAddressMatrikula.php @@ -18,64 +18,63 @@ class DawaElementAddressMatrikula extends WebformCompositeBase { */ public static function getCompositeElements(array $element) { $elements = []; - if ($element) { - $elements['address'] = [ - '#type' => 'os2forms_dawa_address', - '#title' => $element['#address_field_title'] ?? t('Address'), - '#remove_place_name' => $element['#remove_place_name'] ?? FALSE, - '#remove_code' => $element['#remove_code'] ?? FALSE, - '#limit_by_municipality' => $element['#limit_by_municipality'] ?? FALSE, - ]; - $elements['matrikula'] = [ - '#type' => 'select', - '#title' => $element['#matrikula_field_title'] ?? t('Matrikula'), - '#options' => [], - '#empty_value' => NULL, - '#validated' => TRUE, - '#attributes' => [ - 'disabled' => 'disabled', + $elements['address'] = [ + '#type' => 'os2forms_dawa_address', + '#title' => $element['#address_field_title'] ?? t('Address'), + '#remove_place_name' => $element['#remove_place_name'] ?? FALSE, + '#remove_code' => $element['#remove_code'] ?? FALSE, + '#limit_by_municipality' => $element['#limit_by_municipality'] ?? FALSE, + ]; + + $elements['matrikula'] = [ + '#type' => 'select', + '#title' => $element['#matrikula_field_title'] ?? t('Matrikula'), + '#options' => [], + '#empty_value' => NULL, + '#validated' => TRUE, + '#attributes' => [ + 'disabled' => 'disabled', + ], + '#description' => t('Options autofill is disabled during the element preview'), + ]; + + // If that is just element preview (no webform_id), then keep the + // element simple. Don't add AJAX behaviour. + if (isset($element['#webform_id'])) { + $matrikula_wrapper_id = $element['#webform_id'] . '-matrikula-wrapper'; + + $elements['address']['#ajax'] = [ + 'callback' => [ + DawaElementAddressMatrikula::class, + 'matrikulaUpdateSelectOptions', + ], + 'event' => 'change', + 'wrapper' => $matrikula_wrapper_id, + 'progress' => [ + 'type' => 'none', ], - '#description' => t('Options autofill is disabled during the element preview'), ]; - // If that is just element preview (no webform_id), then keep the - // element simple. Don't add AJAX behaviour. - if (isset($element['#webform_id'])) { - $matrikula_wrapper_id = $element['#webform_id'] . '-matrikula-wrapper'; - - $elements['address']['#ajax'] = [ - 'callback' => [ - DawaElementAddressMatrikula::class, - 'matrikulaUpdateSelectOptions', - ], - 'event' => 'change', - 'wrapper' => $matrikula_wrapper_id, - 'progress' => [ - 'type' => 'none', - ], - ]; - - $elements['matrikula'] += [ - '#prefix' => '
', - '#suffix' => '
', - ]; - unset($elements['matrikula']['#description']); - - if (isset($element['#value']) && !empty($element['#value']['address'])) { - $addressValue = $element['#value']['address']; - - $matrikulaOptions = self::getMatrikulaOptions($addressValue, $element); - - // Populating the element. - if (!empty($matrikulaOptions)) { - $elements['matrikula']['#options'] = $matrikulaOptions; - $matrikulaOptionKeys = array_keys($matrikulaOptions); - $elements['matrikula']['matrikula']['#value'] = reset($matrikulaOptionKeys); - - // Make element enabled. - unset($elements['matrikula']['#attributes']['disabled']); - } + $elements['matrikula'] += [ + '#prefix' => '
', + '#suffix' => '
', + ]; + unset($elements['matrikula']['#description']); + + if (isset($element['#value']) && !empty($element['#value']['address'])) { + $addressValue = $element['#value']['address']; + + $matrikulaOptions = self::getMatrikulaOptions($addressValue, $element); + + // Populating the element. + if (!empty($matrikulaOptions)) { + $elements['matrikula']['#options'] = $matrikulaOptions; + $matrikulaOptionKeys = array_keys($matrikulaOptions); + $elements['matrikula']['matrikula']['#value'] = reset($matrikulaOptionKeys); + + // Make element enabled. + unset($elements['matrikula']['#attributes']['disabled']); } } } @@ -152,5 +151,5 @@ public static function matrikulaUpdateSelectOptions(array &$form, FormStateInter } return $matrikula_element['matrikula']; } - + } From 5e628e936595786746483ff3bc15ec5fa2b6ef91 Mon Sep 17 00:00:00 2001 From: Stanislav Kutasevits Date: Tue, 20 Jun 2023 15:50:58 +0300 Subject: [PATCH 2/5] OS-56 - splitting compsosite element values in sbsys --- .../src/Element/WebformAttachmentSbsysXml.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/os2forms_sbsys/src/Element/WebformAttachmentSbsysXml.php b/modules/os2forms_sbsys/src/Element/WebformAttachmentSbsysXml.php index 3cf707f2..70f080b6 100644 --- a/modules/os2forms_sbsys/src/Element/WebformAttachmentSbsysXml.php +++ b/modules/os2forms_sbsys/src/Element/WebformAttachmentSbsysXml.php @@ -230,6 +230,7 @@ protected static function getWebformElementsAsList(WebformSubmissionInterface $w $field_name = $key; $field_name = preg_replace('/\W/', '_', $field_name); $webform_element['#type']; + if ($webform_element['#type'] == 'markup') { $elements_list[$field_name] = $webform_element['value']; } @@ -240,10 +241,19 @@ protected static function getWebformElementsAsList(WebformSubmissionInterface $w } } else { - $elements_list[$field_name] = $data[$key]; + // For arrays (for example: composite elements), splitting values. + if (is_array($data[$key])) { + foreach ($data[$key] as $child_key => $child_data) { + $elements_list[$field_name . "_" . $child_key] = $child_data; + } + } + else { + $elements_list[$field_name] = $data[$key]; + } } } } + return $elements_list; } From 9024f5fa46d9d0f9bc214b000aab8529f0aa7132 Mon Sep 17 00:00:00 2001 From: Stanislav Kutasevits Date: Tue, 20 Jun 2023 15:54:43 +0300 Subject: [PATCH 3/5] Fixing PDF attachment styles --- modules/os2forms_attachment/os2forms_attachment.module | 6 +++--- .../src/Os2formsAttachmentPrintBuilder.php | 7 ++++++- .../os2forms-attachment--webform-submission.html.twig | 9 +++++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/modules/os2forms_attachment/os2forms_attachment.module b/modules/os2forms_attachment/os2forms_attachment.module index c122ba93..9f8892c9 100644 --- a/modules/os2forms_attachment/os2forms_attachment.module +++ b/modules/os2forms_attachment/os2forms_attachment.module @@ -198,7 +198,7 @@ function _os2forms_attachment_print_form_add_template_override(array &$element, '#options' => $header_options, '#description' => t('Select default header that will be used on all forms (use standard for no override)'), '#empty_option' => t('Use standard'), - '#default_value' => $template_settings['os2forms_header'] ?? '', + '#default_value' => $template_settings['os2form_header'] ?? '', '#weight' => -1, ]; @@ -208,7 +208,7 @@ function _os2forms_attachment_print_form_add_template_override(array &$element, '#options' => $colophon_options, '#description' => t('Select default colophon that will be used on all forms (use standard for no override)'), '#empty_option' => t('Use standard'), - '#default_value' => $template_settings['os2forms_colophon'] ?? '', + '#default_value' => $template_settings['os2form_colophon'] ?? '', '#weight' => -1, ]; @@ -218,7 +218,7 @@ function _os2forms_attachment_print_form_add_template_override(array &$element, '#options' => $footer_options, '#description' => t('Select default footer that will be used on all forms (use standard for no override)'), '#empty_option' => t('Use standard'), - '#default_value' => $template_settings['os2forms_footer'] ?? '', + '#default_value' => $template_settings['os2form_footer'] ?? '', '#weight' => 0, ]; diff --git a/modules/os2forms_attachment/src/Os2formsAttachmentPrintBuilder.php b/modules/os2forms_attachment/src/Os2formsAttachmentPrintBuilder.php index 4ae09ee2..67a0c99a 100644 --- a/modules/os2forms_attachment/src/Os2formsAttachmentPrintBuilder.php +++ b/modules/os2forms_attachment/src/Os2formsAttachmentPrintBuilder.php @@ -46,7 +46,12 @@ protected function prepareRenderer(array $entities, PrintEngineInterface $print_ '#attached' => [], ]; - $print_engine->addPage($renderer->generateHtml($entities, $render, $use_default_css, TRUE)); + // Adding hardcoded negative margin to avoid margins in
+ // structure. That margin is automatically added in PDF and PDF only. + $generatedHtml = (string) $renderer->generateHtml($entities, $render, $use_default_css, TRUE); + $generatedHtml .= ""; + + $print_engine->addPage($generatedHtml); return $renderer; } diff --git a/modules/os2forms_attachment/templates/os2forms-attachment--webform-submission.html.twig b/modules/os2forms_attachment/templates/os2forms-attachment--webform-submission.html.twig index 817de37c..17917103 100644 --- a/modules/os2forms_attachment/templates/os2forms-attachment--webform-submission.html.twig +++ b/modules/os2forms_attachment/templates/os2forms-attachment--webform-submission.html.twig @@ -68,6 +68,15 @@ .table { width: 100%; } + + legend, summary, .details-wrapper, fieldset { + padding: 0; + } + + fieldset { + margin: 0; + border: 0; + } From e345a2d00702ead4d9c732c69940c71925557b1e Mon Sep 17 00:00:00 2001 From: Stanislav Kutasevits Date: Thu, 22 Jun 2023 11:14:58 +0300 Subject: [PATCH 4/5] OS-56 - duplicating composite element in XML as combined values --- .../src/Element/WebformAttachmentSbsysXml.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/os2forms_sbsys/src/Element/WebformAttachmentSbsysXml.php b/modules/os2forms_sbsys/src/Element/WebformAttachmentSbsysXml.php index 70f080b6..b08fc042 100644 --- a/modules/os2forms_sbsys/src/Element/WebformAttachmentSbsysXml.php +++ b/modules/os2forms_sbsys/src/Element/WebformAttachmentSbsysXml.php @@ -241,15 +241,15 @@ protected static function getWebformElementsAsList(WebformSubmissionInterface $w } } else { - // For arrays (for example: composite elements), splitting values. + $elements_list[$field_name] = $data[$key]; + + // For arrays (for example: composite elements), + // values are aldo duplicated by splitting them. if (is_array($data[$key])) { foreach ($data[$key] as $child_key => $child_data) { $elements_list[$field_name . "_" . $child_key] = $child_data; } } - else { - $elements_list[$field_name] = $data[$key]; - } } } } From 1bf6e0437c7922047bd1bdd693edfc53de143890 Mon Sep 17 00:00:00 2001 From: Stanislav Kutasevits Date: Wed, 23 Aug 2023 10:37:27 +0300 Subject: [PATCH 5/5] Preparing deploy --- CHANGELOG.md | 3 +++ .../os2forms_dawa/src/Element/DawaElementAddressMatrikula.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dcd7baae..3fbe0c8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ before starting to add changes. Use example [placed in the end of the page](#exa ## [Unreleased] +- [OSF-55] DAWA Address-Matrikula (autocomplete) (required) +- [OSF-56] DAWA Address-Matrikula (autocomplete) (value in XML-file) + ## [3.6.0] 2023-06-07 - [OSF-25] added modules/os2forms_forloeb diff --git a/modules/os2forms_dawa/src/Element/DawaElementAddressMatrikula.php b/modules/os2forms_dawa/src/Element/DawaElementAddressMatrikula.php index 16c7ba02..fcaf3c51 100644 --- a/modules/os2forms_dawa/src/Element/DawaElementAddressMatrikula.php +++ b/modules/os2forms_dawa/src/Element/DawaElementAddressMatrikula.php @@ -151,5 +151,5 @@ public static function matrikulaUpdateSelectOptions(array &$form, FormStateInter } return $matrikula_element['matrikula']; } - + }