Skip to content

Commit 1c789ad

Browse files
committed
Merge branch '8.x' into 8.x-2.x
* 8.x: Fixing DAWA elements preview Added information about configuration management
2 parents 168e94a + 81822bf commit 1c789ad

File tree

5 files changed

+62
-32
lines changed

5 files changed

+62
-32
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,33 @@ See [OS2Forms code review policy](https://github.com/OS2Forms/docs#code-review)
5656
### Git name convention
5757
See [OS2Forms git name convention](https://github.com/OS2Forms/docs#git-guideline)
5858

59+
## Important notes
60+
### Webforms
61+
Each webform, including all its settings, is stored as configuration in db and
62+
will(could) be exported as `yml` file via Drupal configuration management
63+
system. And afterwards could be tracked by `git`.
64+
65+
It means that all webform settings from drupal database will
66+
be syncronized (exported/imported) with state stored in `yml` files from
67+
configuration folder stored in git repository. Without proper actions webforms
68+
could be deleted or reverted to state in `yml` during synchronization.
69+
70+
To avoid/prevent this behavior we recommend use `Config ignore` module, where
71+
you can add all settings you do not want to export/import via configuration
72+
management system.
73+
74+
### Serviceplatformen plugins
75+
Settings for CPR and CVR serviceplantormen plugins are storing as configuration
76+
in db and will(could) be exported as `yml` file via Drupal configuration
77+
management system. And afterwards could be tracked by `git`.
78+
79+
If case you have public access to your git repository all setting from plugins
80+
will be exposed for third persons.
81+
82+
To avoid/prevent this behavior we recommend use `Config ignore` module, where
83+
you can add all settings you do not want to export/import via configuration
84+
management system.
85+
5986
## Unstable features
6087
### Export submissions to Word
6188
This feature is still not part of Webform and Entity print modules stable versions
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
os2forms_dawa.element.autocomplete:
2-
path: '/os2forms-dawa/{webform}/autocomplete/{element_type}'
2+
path: '/os2forms-dawa/autocomplete/{element_type}'
33
defaults:
44
_controller: '\Drupal\os2forms_dawa\Controller\DawaElementController::autocomplete'
55
_format: json
6-
options:
7-
parameters:
8-
webform:
9-
type: 'entity:webform'
106
requirements:
11-
_entity_access: 'webform.submission_page'
7+
_permission: 'access content'

modules/os2forms_dawa/src/Controller/DawaElementController.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,13 @@ class DawaElementController extends ControllerBase {
1717
*
1818
* @param \Symfony\Component\HttpFoundation\Request $request
1919
* The current request object containing the search string.
20-
* @param \Drupal\webform\WebformInterface $webform
21-
* A webform.
2220
* @param string $element_type
2321
* Type of the webform element.
2422
*
2523
* @return \Symfony\Component\HttpFoundation\JsonResponse
2624
* A JSON response containing the autocomplete suggestions.
2725
*/
28-
public function autocomplete(Request $request, WebformInterface $webform, $element_type) {
26+
public function autocomplete(Request $request, $element_type) {
2927
// Get autocomplete query.
3028
$query = $request->query;
3129
$q = $query->get('q') ?: '';

modules/os2forms_dawa/src/Element/DawaElementAddressMatrikula.php

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,9 @@ class DawaElementAddressMatrikula extends WebformCompositeBase {
1919
public static function getCompositeElements(array $element) {
2020
$elements = [];
2121
if ($element) {
22-
$matrikula_wrapper_id = $element['#webform_id'] . '-matrikula-wrapper';
23-
2422
$elements['address'] = [
2523
'#type' => 'os2forms_dawa_address',
2624
'#title' => isset($element['#address_field_title']) ? $element['#address_field_title'] : t('Address'),
27-
'#ajax' => [
28-
'callback' => [DawaElementAddressMatrikula::class, 'matrikulaUpdateSelectOptions'],
29-
'event' => 'change',
30-
'wrapper' => $matrikula_wrapper_id,
31-
'progress' => [
32-
'type' => 'none',
33-
],
34-
],
3525
'#remove_place_name' => isset($element['#remove_place_name']) ? $element['#remove_place_name'] : FALSE,
3626
'#remove_code' => isset($element['#remove_code']) ? $element['#remove_code'] : FALSE,
3727
'#limit_by_municipality' => isset($element['#limit_by_municipality']) ? $element['#limit_by_municipality'] : FALSE,
@@ -40,29 +30,49 @@ public static function getCompositeElements(array $element) {
4030
$elements['matrikula'] = [
4131
'#type' => 'select',
4232
'#title' => isset($element['#matrikula_field_title']) ? $element['#matrikula_field_title'] : t('Matrikula'),
43-
'#prefix' => '<div id="' . $matrikula_wrapper_id . '">',
44-
'#suffix' => '</div>',
4533
'#options' => [],
4634
'#empty_value' => NULL,
4735
'#validated' => TRUE,
4836
'#attributes' => [
4937
'disabled' => 'disabled',
5038
],
39+
'#description' => t('Options autofill is disabled during the element preview'),
5140
];
5241

53-
if (isset($element['#value']) && !empty($element['#value']['address'])) {
54-
$addressValue = $element['#value']['address'];
42+
// If that is just element preview (no webform_id), then keep the
43+
// element simple. Don't add AJAX behaviour.
44+
if (isset($element['#webform_id'])) {
45+
$matrikula_wrapper_id = $element['#webform_id'] . '-matrikula-wrapper';
46+
47+
$elements['address']['#ajax'] = [
48+
'callback' => [DawaElementAddressMatrikula::class, 'matrikulaUpdateSelectOptions'],
49+
'event' => 'change',
50+
'wrapper' => $matrikula_wrapper_id,
51+
'progress' => [
52+
'type' => 'none',
53+
],
54+
];
55+
56+
$elements['matrikula'] += [
57+
'#prefix' => '<div id="' . $matrikula_wrapper_id . '">',
58+
'#suffix' => '</div>',
59+
];
60+
unset($elements['matrikula']['#description']);
61+
62+
if (isset($element['#value']) && !empty($element['#value']['address'])) {
63+
$addressValue = $element['#value']['address'];
5564

56-
$matrikulaOptions = self::getMatrikulaOptions($addressValue, $element);
65+
$matrikulaOptions = self::getMatrikulaOptions($addressValue, $element);
5766

58-
// Populating the element.
59-
if (!empty($matrikulaOptions)) {
60-
$elements['matrikula']['#options'] = $matrikulaOptions;
61-
$matrikulaOptionKeys = array_keys($matrikulaOptions);
62-
$elements['matrikula']['matrikula']['#value'] = reset($matrikulaOptionKeys);
67+
// Populating the element.
68+
if (!empty($matrikulaOptions)) {
69+
$elements['matrikula']['#options'] = $matrikulaOptions;
70+
$matrikulaOptionKeys = array_keys($matrikulaOptions);
71+
$elements['matrikula']['matrikula']['#value'] = reset($matrikulaOptionKeys);
6372

64-
// Make element enabled.
65-
unset($elements['matrikula']['#attributes']['disabled']);
73+
// Make element enabled.
74+
unset($elements['matrikula']['#attributes']['disabled']);
75+
}
6676
}
6777
}
6878
}

modules/os2forms_dawa/src/Plugin/WebformElement/DawaElementBase.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public function prepare(array &$element, WebformSubmissionInterface $webform_sub
3030

3131
$element['#autocomplete_route_name'] = 'os2forms_dawa.element.autocomplete';
3232
$element['#autocomplete_route_parameters'] = [
33-
'webform' => $webform_submission->getWebform()->id(),
3433
'element_type' => $element['#type'],
3534
];
3635
}

0 commit comments

Comments
 (0)