From a719e0fcf213a84102ba279b8c5ee2714e58ea38 Mon Sep 17 00:00:00 2001 From: Andriy Iun Date: Fri, 3 Jan 2020 08:51:09 +0100 Subject: [PATCH 1/2] Added information about configuration management --- README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README.md b/README.md index a09b2e6d..3d5abac5 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,33 @@ See [OS2Forms code review policy](https://github.com/OS2Forms/docs#code-review) ### Git name convention See [OS2Forms git name convention](https://github.com/OS2Forms/docs#git-guideline) +## Important notes +### Webforms +Each webform, including all its settings, is stored as configuration in db and +will(could) be exported as `yml` file via Drupal configuration management +system. And afterwards could be tracked by `git`. + +It means that all webform settings from drupal database will +be syncronized (exported/imported) with state stored in `yml` files from +configuration folder stored in git repository. Without proper actions webforms +could be deleted or reverted to state in `yml` during synchronization. + +To avoid/prevent this behavior we recommend use `Config ignore` module, where +you can add all settings you do not want to export/import via configuration +management system. + +### Serviceplatformen plugins +Settings for CPR and CVR serviceplantormen plugins are storing as configuration +in db and will(could) be exported as `yml` file via Drupal configuration +management system. And afterwards could be tracked by `git`. + +If case you have public access to your git repository all setting from plugins +will be exposed for third persons. + +To avoid/prevent this behavior we recommend use `Config ignore` module, where +you can add all settings you do not want to export/import via configuration +management system. + ## Unstable features ### Export submissions to Word This feature is still not part of Webform and Entity print modules stable versions From 81822bf6ce6ee0052411c292e8bab1132727ca12 Mon Sep 17 00:00:00 2001 From: Stanislav Kutasevits Date: Mon, 10 Feb 2020 12:17:28 +0200 Subject: [PATCH 2/2] Fixing DAWA elements preview --- .../os2forms_dawa/os2forms_dawa.routing.yml | 8 +-- .../src/Controller/DawaElementController.php | 4 +- .../Element/DawaElementAddressMatrikula.php | 54 +++++++++++-------- .../Plugin/WebformElement/DawaElementBase.php | 1 - 4 files changed, 35 insertions(+), 32 deletions(-) diff --git a/modules/os2forms_dawa/os2forms_dawa.routing.yml b/modules/os2forms_dawa/os2forms_dawa.routing.yml index 270d3a38..458f5e0e 100644 --- a/modules/os2forms_dawa/os2forms_dawa.routing.yml +++ b/modules/os2forms_dawa/os2forms_dawa.routing.yml @@ -1,11 +1,7 @@ os2forms_dawa.element.autocomplete: - path: '/os2forms-dawa/{webform}/autocomplete/{element_type}' + path: '/os2forms-dawa/autocomplete/{element_type}' defaults: _controller: '\Drupal\os2forms_dawa\Controller\DawaElementController::autocomplete' _format: json - options: - parameters: - webform: - type: 'entity:webform' requirements: - _entity_access: 'webform.submission_page' + _permission: 'access content' diff --git a/modules/os2forms_dawa/src/Controller/DawaElementController.php b/modules/os2forms_dawa/src/Controller/DawaElementController.php index 45fdf76e..0da4be9d 100644 --- a/modules/os2forms_dawa/src/Controller/DawaElementController.php +++ b/modules/os2forms_dawa/src/Controller/DawaElementController.php @@ -17,15 +17,13 @@ class DawaElementController extends ControllerBase { * * @param \Symfony\Component\HttpFoundation\Request $request * The current request object containing the search string. - * @param \Drupal\webform\WebformInterface $webform - * A webform. * @param string $element_type * Type of the webform element. * * @return \Symfony\Component\HttpFoundation\JsonResponse * A JSON response containing the autocomplete suggestions. */ - public function autocomplete(Request $request, WebformInterface $webform, $element_type) { + public function autocomplete(Request $request, $element_type) { // Get autocomplete query. $query = $request->query; $q = $query->get('q') ?: ''; diff --git a/modules/os2forms_dawa/src/Element/DawaElementAddressMatrikula.php b/modules/os2forms_dawa/src/Element/DawaElementAddressMatrikula.php index 5c8d092f..ab6eab2d 100644 --- a/modules/os2forms_dawa/src/Element/DawaElementAddressMatrikula.php +++ b/modules/os2forms_dawa/src/Element/DawaElementAddressMatrikula.php @@ -19,19 +19,9 @@ class DawaElementAddressMatrikula extends WebformCompositeBase { public static function getCompositeElements(array $element) { $elements = []; if ($element) { - $matrikula_wrapper_id = $element['#webform_id'] . '-matrikula-wrapper'; - $elements['address'] = [ '#type' => 'os2forms_dawa_address', '#title' => isset($element['#address_field_title']) ? $element['#address_field_title'] : t('Address'), - '#ajax' => [ - 'callback' => [DawaElementAddressMatrikula::class, 'matrikulaUpdateSelectOptions'], - 'event' => 'change', - 'wrapper' => $matrikula_wrapper_id, - 'progress' => [ - 'type' => 'none', - ], - ], '#remove_place_name' => isset($element['#remove_place_name']) ? $element['#remove_place_name'] : FALSE, '#remove_code' => isset($element['#remove_code']) ? $element['#remove_code'] : FALSE, '#limit_by_municipality' => isset($element['#limit_by_municipality']) ? $element['#limit_by_municipality'] : FALSE, @@ -40,29 +30,49 @@ public static function getCompositeElements(array $element) { $elements['matrikula'] = [ '#type' => 'select', '#title' => isset($element['#matrikula_field_title']) ? $element['#matrikula_field_title'] : t('Matrikula'), - '#prefix' => '
', - '#suffix' => '
', '#options' => [], '#empty_value' => NULL, '#validated' => TRUE, '#attributes' => [ 'disabled' => 'disabled', ], + '#description' => t('Options autofill is disabled during the element preview'), ]; - if (isset($element['#value']) && !empty($element['#value']['address'])) { - $addressValue = $element['#value']['address']; + // 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); + $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); + // 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']); + // Make element enabled. + unset($elements['matrikula']['#attributes']['disabled']); + } } } } diff --git a/modules/os2forms_dawa/src/Plugin/WebformElement/DawaElementBase.php b/modules/os2forms_dawa/src/Plugin/WebformElement/DawaElementBase.php index 0ede86a1..fb818105 100644 --- a/modules/os2forms_dawa/src/Plugin/WebformElement/DawaElementBase.php +++ b/modules/os2forms_dawa/src/Plugin/WebformElement/DawaElementBase.php @@ -30,7 +30,6 @@ public function prepare(array &$element, WebformSubmissionInterface $webform_sub $element['#autocomplete_route_name'] = 'os2forms_dawa.element.autocomplete'; $element['#autocomplete_route_parameters'] = [ - 'webform' => $webform_submission->getWebform()->id(), 'element_type' => $element['#type'], ]; }