Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Action manager: adding action to select input by default #2273

Merged
merged 2 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions _data/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -1132,6 +1132,16 @@
"language": "fr",
"path": "patches-fr.html"
},
{
"title": "Select input",
"language": "en",
"path": "selectinput-en.html"
},
{
"title": "Sélectionner un champ de saisie",
"language": "fr",
"path": "selectinput-fr.html"
},
{
"title": "Geomap",
"language": "en",
Expand Down
14 changes: 7 additions & 7 deletions _data/sites.json
Original file line number Diff line number Diff line change
Expand Up @@ -959,8 +959,8 @@
"fr": "Standard (wet-boew)"
},
"introduction": {
"en": "This implementation is meant for developers/publishers adding the component manually while using the latest version of GCWeb along with the implementation of the page details version 3.0 and above.",
"fr": "Cette implémentation est destinée aux développeurs/éditeurs qui ajoutent le composant manuellement en utilisant la dernière version de GCWeb avec l'implémentation de la version 3.0 ou plus du détails de la page."
"en": "This implementation is meant for developers/publishers adding the component manually while using the latest version of GCWeb along with the implementation of the page details version 2.0 and above.",
"fr": "Cette implémentation est destinée aux développeurs/éditeurs qui ajoutent le composant manuellement en utilisant la dernière version de GCWeb avec l'implémentation de la version 2.0 ou plus du détails de la page."
},
"instructions": {
"en": [
Expand All @@ -971,7 +971,7 @@
],
"fr": [
"Vérifier que la version <a href=\"https://github.com/wet-boew/GCWeb/releases\">v13.9.0 ou plus récente</a> de GCWeb est implémentée.",
"Vérifier que la <a href=\"../page-details/page-details-docs-en.html\">version 3.0, ou plus récente, du détails de la page</a> est implémentée.",
"Vérifier que la <a href=\"../page-details/page-details-docs-en.html\">version 2.1, ou plus récente, du détails de la page</a> est implémentée.",
"Pour afficher le formulaire de rétroaction sur la page, créez un <code>&lt;div class=\"wb-disable-allow\"&gt;</code> avec les attributs suivants&nbsp;:<ul><li>Obligatoire&nbsp;: <code>data-ajax-replace=\"https://www.canada.ca/etc/designs/canada/wet-boew/assets/feedback/page-feedback-fr.html\"</code></li><li>Optionnel&nbsp;: <code>data-feedback-theme=\"[Texte définissant le thème de votre page]\"</code></li><li>Optionnel&nbsp;: <code>data-feedback-section=\"[Texte définissant la section où réside votre page]\"</code></li></ul>",
"De plus, vous pouvez définir les métadonnées suivantes&nbsp;: <code>&lt;meta name=\"dcterms.creator\" content=\"[Department name]\"&gt;</code>"
]
Expand All @@ -991,7 +991,7 @@
{
"@type": "source-code",
"description": "Code sample:",
"code": "<div class=\"wb-disable-allow\" \ndata-ajax-replace=\"https://www.canada.ca/etc/designs/canada/wet-boew/assets/feedback/page-feedback-en.html\" \ndata-feedback-section=\"[Text defining the section where your page resides]\" \ndata-feedback-theme=\"[Text defining the theme of your page]\"></div>"
"code": "&lt;div class=\"wb-disable-allow\" \ndata-ajax-replace=\"https://www.canada.ca/etc/designs/canada/wet-boew/assets/feedback/page-feedback-en.html\" \ndata-feedback-section=\"[Text defining the section where your page resides]\" \ndata-feedback-theme=\"[Text defining the theme of your page]\"&gt;&lt;/div&gt;"
},
{
"@type": "source-code",
Expand All @@ -1007,7 +1007,7 @@
{
"@type": "source-code",
"description": "Exemple de code :",
"code": "<div class=\"wb-disable-allow\" \ndata-ajax-replace=\"https://www.canada.ca/etc/designs/canada/wet-boew/assets/feedback/page-feedback-fr.html\" \ndata-feedback-section=\"[Texte définissant la section où réside votre page]\" \ndata-feedback-theme=\"[Texte définissant le thème de votre page]\"></div>"
"code": "&lt;div class=\"wb-disable-allow\" \ndata-ajax-replace=\"https://www.canada.ca/etc/designs/canada/wet-boew/assets/feedback/page-feedback-fr.html\" \ndata-feedback-section=\"[Texte définissant la section où réside votre page]\" \ndata-feedback-theme=\"[Texte définissant le thème de votre page]\"&gt;&lt;/div&gt;"
},
{
"@type": "source-code",
Expand Down Expand Up @@ -1147,7 +1147,7 @@
{
"@type": "source-code",
"description": "Code sample:",
"code": "<div class=\"wb-disable-allow\" \ndata-ajax-replace=\"https://www.canada.ca/etc/designs/canada/wet-boew/assets/feedback/page-feedback-en.html\" \ndata-feedback-section=\"[Text defining the section where your page resides]\" \ndata-feedback-theme=\"[Text defining the theme of your page]\" \ndata-feedback-link=\"[Contact link text]\" \ndata-feedback-url=\"[Contact link URL]\"></div>"
"code": "&lt;div class=\"wb-disable-allow\" \ndata-ajax-replace=\"https://www.canada.ca/etc/designs/canada/wet-boew/assets/feedback/page-feedback-en.html\" \ndata-feedback-section=\"[Text defining the section where your page resides]\" \ndata-feedback-theme=\"[Text defining the theme of your page]\" \ndata-feedback-link=\"[Contact link text]\" \ndata-feedback-url=\"[Contact link URL]\"&gt;&lt;/div&gt;"
},
{
"@type": "source-code",
Expand All @@ -1163,7 +1163,7 @@
{
"@type": "source-code",
"description": "Exemple de code :",
"code": "<div class=\"wb-disable-allow\" \ndata-ajax-replace=\"https://www.canada.ca/etc/designs/canada/wet-boew/assets/feedback/page-feedback-fr.html\" \ndata-feedback-section=\"[Texte définissant la section où réside votre page]\" \ndata-feedback-theme=\"[Texte définissant le thème de votre page]\" \ndata-feedback-link=\"[Texte du lien de contact]\" \ndata-feedback-url=\"[URL du lien de contact]\"></div>"
"code": "&lt;div class=\"wb-disable-allow\" \ndata-ajax-replace=\"https://www.canada.ca/etc/designs/canada/wet-boew/assets/feedback/page-feedback-fr.html\" \ndata-feedback-section=\"[Texte définissant la section où réside votre page]\" \ndata-feedback-theme=\"[Texte définissant le thème de votre page]\" \ndata-feedback-link=\"[Texte du lien de contact]\" \ndata-feedback-url=\"[URL du lien de contact]\"&gt;&lt;/div&gt;"
},
{
"@type": "source-code",
Expand Down
18 changes: 18 additions & 0 deletions components/wb-actionmng/actionmng.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var $document = wb.doc,
"removeClass",
"tblfilter",
"withInput",
"selectInput",
"run"
].join( "." + actionEvent + " " ) + "." + actionEvent,

Expand Down Expand Up @@ -416,6 +417,20 @@ var $document = wb.doc,
}

},
selectInputAct = function( event, data ) {
var sourceElm = document.querySelector( data.source ) || event.currentTarget,
inputs;

inputs = sourceElm.querySelectorAll( "[value=\"" + data.value + "\"]" );

inputs.forEach( input => {
if ( input.nodeName === "OPTION" ) {
input.setAttribute( "selected", true );
} else if ( input.nodeName === "INPUT" ) {
input.setAttribute( "checked", true );
}
} );
},
patchFixArray = function( patchArray, val, basePointer ) {

var i, i_len = patchArray.length, i_cache,
Expand Down Expand Up @@ -582,6 +597,9 @@ $document.on( actionMngEvent, selector, function( event, data ) {
case "patch":
patchAct( event, data );
break;
case "selectInput":
selectInputAct( event, data );
break;
case "mapfilter":
geomapAOIAct( event, data );
break;
Expand Down
Loading
Loading