Skip to content

Commit

Permalink
Move of Do Action and Action manager plugin from GCWeb to wet-boew
Browse files Browse the repository at this point in the history
  • Loading branch information
duboisp committed Oct 4, 2023
1 parent caf9af7 commit 9f7e54e
Show file tree
Hide file tree
Showing 22 changed files with 3,529 additions and 0 deletions.
859 changes: 859 additions & 0 deletions site/pages/docs/ref/doaction/doaction-en.hbs

Large diffs are not rendered by default.

844 changes: 844 additions & 0 deletions site/pages/docs/ref/doaction/doaction-fr.hbs

Large diffs are not rendered by default.

607 changes: 607 additions & 0 deletions src/plugins/actionmng/actionmng.js

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions src/plugins/doaction/demo/data-en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"city": {
"gat": "Gatineau",
"ott": "Ottawa",
"vdm": "Val-des-monts"
},
"fruit": "Perry",
"country": {
"name": "Canada",
"province": {
"qc": "Quebec",
"on": "Ontario",
"ma": "Manitoba"
}
}
}
16 changes: 16 additions & 0 deletions src/plugins/doaction/demo/data-fr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"ville": {
"gat": "Gatineau",
"ott": "Ottawa",
"vdm": "Val-des-monts"
},
"fruit": "poire",
"pays": {
"nom": "Canada",
"province": {
"qc": "Québec",
"on": "Ontario",
"ma": "Manitoba"
}
}
}
15 changes: 15 additions & 0 deletions src/plugins/doaction/demo/doaction-date-en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"test" : "test found!",
"express" : {
"bad-date" : "Date not found",
"2019-06-10" : "2019-06-13",
"2019-06-11" : "2019-06-14",
"2019-06-12" : "2019-06-15"
},
"standard" : {
"bad-date" : "Date not found",
"2019-06-10" : "2019-06-20",
"2019-06-11" : "2019-06-21",
"2019-06-12" : "2019-06-22"
}
}
15 changes: 15 additions & 0 deletions src/plugins/doaction/demo/doaction-date-fr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"test" : "test trouvé!",
"express" : {
"bad-date" : "Date introuvable",
"2019-06-10" : "2019-06-13",
"2019-06-11" : "2019-06-14",
"2019-06-12" : "2019-06-15"
},
"standard" : {
"bad-date" : "Date introuvable",
"2019-06-10" : "2019-06-20",
"2019-06-11" : "2019-06-21",
"2019-06-12" : "2019-06-22"
}
}
1 change: 1 addition & 0 deletions src/plugins/doaction/demo/empty.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ }
3 changes: 3 additions & 0 deletions src/plugins/doaction/demo/file-1-fr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"data": "Du fichier JSON 1"
}
3 changes: 3 additions & 0 deletions src/plugins/doaction/demo/file-1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"data": "From JSON file 1"
}
3 changes: 3 additions & 0 deletions src/plugins/doaction/demo/file-2-fr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"data": "+Du fichier JSON 2"
}
3 changes: 3 additions & 0 deletions src/plugins/doaction/demo/file-2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"data": "+From JSON file 2"
}
3 changes: 3 additions & 0 deletions src/plugins/doaction/demo/file-3-fr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"data": "-Du fichier JSON 3"
}
3 changes: 3 additions & 0 deletions src/plugins/doaction/demo/file-3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"data": "-From JSON file 3"
}
3 changes: 3 additions & 0 deletions src/plugins/doaction/demo/file-4-fr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"data": "&Du fichier JSON 4"
}
3 changes: 3 additions & 0 deletions src/plugins/doaction/demo/file-4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"data": "&From JSON file 4"
}
61 changes: 61 additions & 0 deletions src/plugins/doaction/doaction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**
* @title WET-BOEW URL mapping
* @overview Execute pre-configured action based on url query string
* @license wet-boew.github.io/wet-boew/License-en.html / wet-boew.github.io/wet-boew/Licence-fr.html
* @author @duboisp
*/
( function( $, window, wb ) {
"use strict";

/*
* Variable and function definitions.
* These are global to the plugin - meaning that they will be initialized once per page,
* not once per instance of plugin on the page. So, this is a good place to define
* variables that are common to all instances of the plugin on a page.
*/
var componentName = "wb-doaction",
selector = "a[data-" + componentName + "],button[data-" + componentName + "]",
runActions = "do.wb-actionmng",
$document = wb.doc;

$document.on( "click", selector, function( event ) {

var elm = event.target,
$elm = $( elm );

// Get the selector when click on a child of it, like click on a figure wrapped in a anchor with doaction.
if ( event.currentTarget !== event.target ) {
$elm = $elm.parentsUntil( "main", selector );
elm = $elm[ 0 ];
}

// Ensure that we only execute for anchor and button
if ( elm.nodeName === "BUTTON" || elm.nodeName === "A" ) {

if ( !elm.id ) {
elm.id = wb.getId();
}

if ( wb.isReady ) {

// Execute actions if any.
$elm.trigger( {
type: runActions,
actions: wb.getData( $elm, componentName )
} );
} else {

// Execution of the action after WET will be ready
$document.one( "wb-ready.wb", function( ) {
$elm.trigger( {
type: runActions,
actions: wb.getData( $elm, componentName )
} );
} );
}
return false;
}
} );


} )( jQuery, window, wb );
66 changes: 66 additions & 0 deletions src/plugins/doaction/index.json-ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"@context": {
"@version": 1.1,
"dct": "http://purl.org/dc/terms/",
"title": { "@id": "dct:title", "@container": "@language" },
"description": { "@id": "dct:description", "@container": "@language" },
"modified": "dct:modified"
},
"title": {
"en": "Do action",
"fr": "Exécuter des actions"
},
"description": {
"en": "Execute action, like filter a table, based on pre-established set of configuration.",
"fr": "Exécute des actions, tel que filtrer un tableau, selon une configuration pré-établis."
},
"modified": "2019-1-12",
"componentName": "wb-doaction",
"status": "stable",
"pages": {
"examples": [
{
"title": "Table",
"language": "en",
"path": "tblfilter-en.html"
},
{
"title": "Filtrer un tableau",
"language": "fr",
"path": "tblfilter-fr.html"
},
{
"title": "JSON",
"language": "en",
"path": "json-en.html"
},
{
"title": "JSON",
"language": "fr",
"path": "json-fr.html"
},
{
"title": "JSON manager patches",
"language": "en",
"path": "../wb-jsonmanager/jsonmanager-doaction-en.html"
},
{
"title": "Gestionnaire JSON avec l'exécuteur d'action de patches",
"language": "fr",
"path": "../wb-jsonmanager/jsonmanager-doaction-fr.html"
}
],
"docs": [
{
"title": "Do action",
"language": "en",
"path": "doaction-doc-en.html"
},
{
"title": "Exécuter des actions",
"language": "fr",
"path": "doaction-doc-fr.html"
}
]
}
}

0 comments on commit 9f7e54e

Please sign in to comment.