function clickOnCommand(treeCssSelStr, msgCssSelStr, cmdName, key ) {
const tree = $.ui.fancytree.getTree(treeCssSelStr); //TODO : Une fonction pour récupérer le tree en paramètre soit par css ou objet
const datasetNode = tree.rootNode.children[0];
- if ( key != "") {
+ if ( key !== undefined && key != "") {
fromNode = tree.getNodeByKey(key);
} else {
fromNode = tree.activeNode;
const classeAccas = node.data.classeAccas; //TODO : Utiliser les types fancytree
const validite = node.data.validite;
const wValue = node.data.wValue;
+ const sdnom = node.data.sdnom;
const statut = node.data.statut;
const cmdName = node.data.nomCommande; // undefined if classeAccas != 'MCFACT'
const repeatable = node.data.repetable; // ?? undefined if classeAccas != 'MCFACT' ??
+ const into = node.data.into; // only used for SIMP
const infoOptionnels = node.data.infoOptionnels;
const key = node.key;
const name = node.title;
$tdList.eq(0).text(node.getIndexHier());
//Render Column #2 (icon color)
- if( validite ) { //TODO : les deux attributs crées un dépacement du input du row
+ switch(validite) { //TODO : les deux attributs crées un dépacement du input du row
+ case 1:
_attr='has-success has-feedback';
// $(".fancytree-exp-n > td:nth-child(2) span").filter(".fancytree-checkbox").css('background-color','blue')
//$tdList.eq(1).find("span").filter(".fancytree-checkbox").css('background-color','#00ff00'); // Update the checkbox validation state TODO: create a CSS class
$tdList.eq(2).find("span").filter(".fancytree-custom-icon").css('color','#00ff00'); // Update the checkbox validation state TODO: create a CSS class
- } else {
+ break;
+ case 0:
_attr='has-error has-feedback';
//$tdList.eq(1).css('background-color','red'); // Update the checkbox validation state TODO: create a CSS class
// $tdList.eq(1).find("span").filter(".fancytree-checkbox").css('background-color','#ff0000'); // Update the checkbox validation state TODO: create a CSS class
$tdList.eq(2).find("span").filter(".fancytree-custom-icon").css('color','#ff0000'); // Update the checkbox validation state TODO: create a CSS class
- } //TODO: paramétrer l'attribut/framework
+ break;
+ case 0:
+ _attr='has-warning has-feedback';
+ $tdList.eq(2).find("span").filter(".fancytree-custom-icon").css('color','#ffff00'); // Update the checkbox validation state TODO: create a CSS class
+ break;
+ default:
+ alert("The validite value : |"+validite+"| is not in range [0-2]"); //TODO afficher la chaine messageClasses
+ // code block
+ } //TODO: paramétrer l'attribut/framework
console.log("node.data.validite, _attr :"+validite+" , "+_attr);
+
+ // if( validite ) { //TODO : les deux attributs crées un dépacement du input du row
+ // _attr='has-success has-feedback';
+ // // $(".fancytree-exp-n > td:nth-child(2) span").filter(".fancytree-checkbox").css('background-color','blue')
+ // //$tdList.eq(1).find("span").filter(".fancytree-checkbox").css('background-color','#00ff00'); // Update the checkbox validation state TODO: create a CSS class
+ // $tdList.eq(2).find("span").filter(".fancytree-custom-icon").css('color','#00ff00'); // Update the checkbox validation state TODO: create a CSS class
+ // } else {
+ // _attr='has-error has-feedback';
+ // //$tdList.eq(1).css('background-color','red'); // Update the checkbox validation state TODO: create a CSS class
+ // // $tdList.eq(1).find("span").filter(".fancytree-checkbox").css('background-color','#ff0000'); // Update the checkbox validation state TODO: create a CSS class
+ // $tdList.eq(2).find("span").filter(".fancytree-custom-icon").css('color','#ff0000'); // Update the checkbox validation state TODO: create a CSS class
+ // } //TODO: paramétrer l'attribut/framework
//Render Column #3 (input field)
// Jaune Eficas #ffff00, Rouge Eficas #ff0000, Vert Eficas #00ff00
//VALIDATION STATES - Bootstrap includes validation styles for error, warning, and success messages.
//To use, add .has-warning, .has-error, or .has-success to the parent element
// $tdList.eq(3).html("<simp><input type='input' class='form-control-sm' id='simp1' placeholder='"+wValue+"' value='"+wValue+"'></simp>");
- $tdList.eq(3)
- .html(
- "<form>"+
- "<div class='form-group'>" +
- "<input type='input' class='form-control input-sm' id='"+key+"' placeholder='"
- + wValue + //TODO:intosugg
- "' value='"+wValue+"' required>"+
- // "<input type='input' class='form-control input-sm' id='"+key+"' placeholder='"
- // + wValue + //TODO:intosugg
- // "' value='"+wValue+"' required>"+
- "<div id='handsontable_"+key+"' />"+
- "</div>"+
- "</form>"
- )
- .addClass(_attr)
- .find("input").css('color','black'); //TODO : A placer ds le CSS
+
+ if (into == undefined ) {
+ $tdList.eq(3)
+ .html(
+ "<form>"+
+ "<div class='form-group'>" +
+ "<input type='input' class='form-control input-sm' id='"+key+"' placeholder='"
+ + wValue + //TODO:intosugg
+ "' value='"+wValue+"' required>"+
+ // "<input type='input' class='form-control input-sm' id='"+key+"' placeholder='"
+ // + wValue + //TODO:intosugg
+ // "' value='"+wValue+"' required>"+
+ "<div id='handsontable_"+key+"' />"+
+ "</div>"+
+ "</form>"
+ )
+ .addClass(_attr)
+ .find("input").css('color','black'); //TODO : A placer ds le CSS
+ } else {
+ $tdList.eq(3)
+ .html(
+ "<form>"+
+ "<div class='form-group'>" +
+ "<select class='form-control input-sm' id='"+key+"'"+
+ into.map((cV, index, arr) => { return "<option>"+cV+"</option>" }).join('') +
+// into.splice(0,1,"").map((cV, index, arr) => { return "<option>"+cV+"</option>" }).join('') +
+ "</div>"+
+ "</form>"
+ )
+ .addClass(_attr)
+ .find("input").css('color','black'); //TODO : A placer ds le CSS
+ }
+
// const container = document.getElementById('handsontable_'+key);
// const hot = new Handsontable(container, {
// data: handsontable_data0,
}; // Not classeAccas == "MCSIMP"
+ //Render Column #3 (input field)
+ // Jaune Eficas #ffff00, Rouge Eficas #ff0000, Vert Eficas #00ff00
+ if ( classeAccas == "OPERATEUR" ) {
+
+ // if (validite && (sdnom === undefined || sdnom == "") ) { //TODO : Mutualiser ailleurs
+ // _attr='has-warning has-feedback';
+ // $tdList.eq(2).find("span").filter(".fancytree-custom-icon").css('color','#ffff00'); // Update the checkbox validation state TODO: create a CSS class
+ // }
+
+ //VALIDATION STATES - Bootstrap includes validation styles for error, warning, and success messages.
+ //To use, add .has-warning, .has-error, or .has-success to the parent element
+ $tdList.eq(3)
+ .html(
+ "<form>"+
+ "<div class='form-group'>" +
+ "<input type='input' class='form-control input-sm' id='"+key+"' " +
+ "' value='"+sdnom+"' required>"+
+ // "<input type='input' class='form-control input-sm' id='"+key+"' placeholder='"
+ // + sdnom + //TODO:intosugg
+ // "' value='"+sdnom+"' required>"+
+ "</div>"+
+ "</form>"
+ )
+ .addClass(_attr)
+ .find("input").css('color','black'); //TODO : A placer ds le CSS
+
+ }; // Not classeAccas == "OPERATEUR"
+
+
+
// THREE ICONS MANAGEMENT : +,Trash,?
plusFunction = undefined;
//trashFunction = "alert(\"glyphicon-trash : "+key+"\")";
trashFunction = "clickOnRemove( \"#tree1\", \"#tree1-messages\", \""+key+"\" )";
- if ( classeAccas == "MCSIMP" ) {
+ if ( classeAccas == "MCSIMP" || classeAccas == "OPERATEUR" ) {
actionListIndex = 4; //TODO : Le paramétrer
} else {
//$tdList.eq(2).prop("colspan", 2).nextAll().remove(); //Merge unused columns for easy keyboard navigation
actionListIndex=3; //TODO : Le paramétrer
}
- if ( classeAccas == "PROCEDURE" || classeAccas == "OPER" ) {
+ if ( classeAccas == "PROCEDURE" || classeAccas == "OPERATEUR" ) {
plusFunction = "clickOnCommand( \"#tree1\", \"#tree1-messages\", \""+name+"\", \""+key+"\" )";
} else if ( classeAccas == "MCFACT" ) {
if (repeatable) {
console.log("event.type, data :"+event.type+" , "+data);
if (node.data.classeAccas == "MCSIMP") {
- $input=$(node.tr).find('input');
- value=$input.val();
+ let $input=$(node.tr).find('input');
+ let value=$input.val();
// Called when ENTER is pressed in cell-mode.
// Return false to prevent default
let checkCallBack = function(data) {
// Tester data == NULL !
- var changeIsAccepted = data.changeIsAccepted;
- var wValue = data.source['wValue'];
- var validite = data.source['validite'];
+ const changeIsAccepted = data.changeIsAccepted;
+ const wValue = data.source['wValue'];
+ const validite = data.source['validite'];
+ const rMessage = data.message
+
//node.fromDict()
//source=JSON.parse(getTree1())
if ( changeIsAccepted ) {
- // $.ui.fancytree.assert(value == wValue); il faut gérer les représentations des types pour activer cet assert (ex: string vs int)
+ // Il faudrait gérer les représentations des types pour activer cet assert (ex: string vs int)
+ // or on laisse le kernel eficas vérifier des strings.
+ // $.ui.fancytree.assert(value == wValue);
node.data.wValue = wValue
node.data.validite = validite
- treeMessage(_msgCssSelStr,"alert-success","Changing SIMP "+node.title+" value to "+value+" has been accepted.");
+ let message = "Changing SIMP "+node.title+" value to "+value+" has been accepted ("+rMessage+")";
+ treeMessage(_msgCssSelStr,"alert-success",message);
//node.data = data.source ?? A priori, il est inutile d'essayer de remplacer la source complète du noeud
console.log('wValue : '+wValue);
console.log('validite : '+validite);
} else {
// Gérer le input pour laisser le focus et passer en rouge
- let message = "Unsuccessfull SIMP processing for |" + node.getPath() + "|, value |"+value+"| has not been accepted.";
+ let message = "Unsuccessfull SIMP processing for |" + node.getPath() + "|, value |"+value+"| has not been accepted ("+rMessage+")";
treeMessage(_msgCssSelStr,"alert-warning",message) ;
};
node.render(true,false); //force rendering the node (not parents nor descendants)
callService('updateSimp', {id: node.key, value:value }, checkCallBack);
} // MCSIMP
+
+ if (node.data.classeAccas == "OPERATEUR") {
+ let $input=$(node.tr).find('input');
+ let value =$input.val();
+
+ // Called when ENTER is pressed in cell-mode.
+ // Return false to prevent default
+ // data.activeTd contains the currently active <td> element or null
+ // data.colIdx contains the 0-based column index or -1
+ if( !data.activeTd ) {
+ alert( "Custom default action for row: " + data.node.title );
+ // we don't return false, so default action is applied:
+ } else if ( data.colIdx != 3 ) {
+ // eslint-disable-next-line no-alert
+ alert( "Custom default action: " + data.node.title );
+ return false;
+ };
+
+ let checkCallBack = function(data) {
+ // Tester data == NULL !
+ var changeIsAccepted = data.changeIsAccepted
+ const rMessage = data.message
+
+ if ( changeIsAccepted ) {
+ node.data.sdnom = value
+ node.data.validite = 1
+ let message = "Changing OPERATOR "+node.title+" sdnom to |"+value+"| has been accepted ("+rMessage+")";
+ treeMessage(_msgCssSelStr,"alert-success",message);
+ //node.data = data.source ?? A priori, il est inutile d'essayer de remplacer la source complète du noeud
+ console.log('sdnom : '+value);
+ } else {
+ // Gérer le input pour laisser le focus et passer en rouge
+ let message = "Unsuccessfull OPERATOR processing for |" + node.getPath() + "|, sdnom |"+value+"| has not been accepted ("+rMessage+")";
+ treeMessage(_msgCssSelStr,"alert-warning",message) ;
+ };
+ node.render(true,false); //force rendering the node (not parents nor descendants)
+ //node.renderStatus(); //CSS element updates
+ };
+
+ callService('updateSDName', {id: node.key, sdnom:value }, checkCallBack);
+
+ } // OPERATEUR
+
},
lazyLoad: function(event, data) {
var node = data.node;