Skip to content

Commit

Permalink
Merge pull request #62 from openeuropa/EPIC-EWPP-2700-Contact-languages
Browse files Browse the repository at this point in the history
EWPP-2700: Contact form language options.
  • Loading branch information
22Alexandra authored Nov 3, 2022
2 parents 02a19ae + 209eab2 commit 98f4506
Show file tree
Hide file tree
Showing 39 changed files with 1,028 additions and 26 deletions.
10 changes: 7 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=7.4",
"cweagans/composer-patches": "~1.4",
"drupal/core": "^9.3",
"drupal/contact_storage": "^1.2",
"drupal/contact_storage_export": "^1.14",
"drupal/core": "^9.3",
"drupal/csv_serialization": "^2.0",
"drupal/multivalue_form_element": "^1.0.0-beta4",
"drupal/token": "^1.8",
"openeuropa/rdf_skos": "^1.0",
"openeuropa/oe_corporate_countries": "^2.0",
"php": ">=7.4"
"openeuropa/rdf_skos": "^1.0"
},
"require-dev": {
"composer/installers": "~1.11",
Expand Down Expand Up @@ -69,6 +70,9 @@
"drupal/contact_storage_export": {
"https://www.drupal.org/project/contact_storage_export/issues/2996037": "https://www.drupal.org/files/issues/2021-10-22/contact_storage_export-breaks-on-high-load-balancer-2996037-17.patch",
"https://www.drupal.org/project/contact_storage_export/issues/3049010": "https://www.drupal.org/files/issues/2020-04-14/php73-3049010-15.patch"
},
"drupal/multivalue_form_element": {
"latest-master": "https://github.com/openeuropa/multivalue_form_element/compare/1.0.0-beta4...1.0.x.diff"
}
},
"drupal-scaffold": {
Expand Down
22 changes: 22 additions & 0 deletions config/schema/oe_contact_forms.schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,31 @@ contact.form.*.third_party.oe_contact_forms:
oe_country_residence:
type: string
label: 'Country of residence'
oe_preferred_language:
type: string
label: 'Preferred contact language'
oe_alternative_language:
type: string
label: 'Alternative contact language'
oe_telephone:
type: string
label: 'Phone'
override_languages:
type: mapping
label: 'Override languages'
mapping:
oe_preferred_language_options:
type: sequence
label: 'Preferred contact language options'
sequence:
type: string
label: 'Skos term'
oe_alternative_language_options:
type: sequence
label: 'Alternative contact language options'
sequence:
type: string
label: 'Skos term'
topics:
type: sequence
sequence:
Expand Down
37 changes: 37 additions & 0 deletions js/related_checkboxes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* @file
* "Related checkboxes" library file.
*/
(function (Drupal, $) {
'use strict';

/**
* Sets state of "Alternative contact language" checkbox based on "Preferred contact language" state.
*
* @type {Drupal~behavior}
*
* @prop {Drupal~behaviorAttach} attach
* Attaches the behavior for oeContactFormsRelatedCheckboxes.
*/
Drupal.behaviors.oeContactFormsRelatedCheckboxes = {
attach: function (context) {
let prefered_language_checkbox = $(context).find('input[name="corporate_fields[optional_fields][oe_preferred_language]"]');
let alternative_language_checkbox = $(context).find('input[name="corporate_fields[optional_fields][oe_alternative_language]"]');

// Disable "Alternative contact language" if "Preferred contact language" is disabled after page load.
if (prefered_language_checkbox.prop('checked') !== true) {
alternative_language_checkbox.attr('disabled', true);
}

// Disable/enable "Alternative contact language" based on "Preferred contact language" state.
prefered_language_checkbox.once().click({checkbox: alternative_language_checkbox}, function(e) {
if (!$(this).prop('checked')) {
e.data.checkbox.prop('checked', false);
e.data.checkbox.change();
}
e.data.checkbox.attr('disabled', !$(this).prop('checked'));
});
},
};

})(Drupal, jQuery);
5 changes: 5 additions & 0 deletions oe_contact_forms.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ dependencies:
- contact_storage_export:contact_storage_export
- rdf_skos:rdf_skos
- oe_corporate_countries:oe_corporate_countries
- multivalue_form_element:multivalue_form_element

'interface translation project': oe_contact_forms
# The path to the actual translations is defined in
# oe_contact_forms_translation_projects_alter().
1 change: 1 addition & 0 deletions oe_contact_forms.install
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function oe_contact_forms_install($is_syncing) {
if (!$is_syncing) {
$graphs = [
'country' => 'http://publications.europa.eu/resource/authority/country',
'language' => 'http://publications.europa.eu/resource/authority/language',
];
\Drupal::service('rdf_skos.skos_graph_configurator')->addGraphs($graphs);
}
Expand Down
6 changes: 6 additions & 0 deletions oe_contact_forms.libraries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
related_checkboxes:
js:
js/related_checkboxes.js: {}
dependencies:
- core/drupal
- core/jquery
Loading

0 comments on commit 98f4506

Please sign in to comment.