From: Eric Fayolle Date: Wed, 6 Apr 2022 13:49:50 +0000 (+0200) Subject: Gestion des OPERs X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4e84f9044286896572c4c979382eae3059075b9c;p=tools%2Feficas.git Gestion des OPERs --- diff --git a/WebTest/cata_essai.py b/WebTest/cata_essai.py index f4577dff..15234cc4 100644 --- a/WebTest/cata_essai.py +++ b/WebTest/cata_essai.py @@ -14,7 +14,7 @@ MonProc = PROC(nom='MonProc', MonProc2 = PROC(nom='MonProc2', param1 = SIMP(statut='o',typ='R'), param11 = SIMP(statut='f',typ='R'), - param12= SIMP(statut='o',typ='R'), + param12= SIMP(statut='o',typ='R',into=[1,2,3,4,9],), b1 = BLOC (condition = 'param1 == 2', param1_inBloc = SIMP(statut='o',typ='R', defaut = 2), B11 = BLOC (condition = 'param1_inBloc == 2', diff --git a/WebTest/web_tres_simple_avec_2Fact.comm b/WebTest/web_tres_simple_avec_2Fact.comm index 74a5d04a..629026e3 100644 --- a/WebTest/web_tres_simple_avec_2Fact.comm +++ b/WebTest/web_tres_simple_avec_2Fact.comm @@ -1,10 +1,11 @@ - +toto=MonOper(param1=28.0); MonProc2(param1=2.0, param12=None, param1_inBloc=2.0, param1_inBlocDeBloc=2.0, paramDernier=2.0, param2_inBloc=None, +# Fact1=(_F(paramInFact1=[43.0,45.2],), Fact1=(_F(paramInFact1=43.0,), _F(paramInFact1=44.0,),),); #CHECKSUM:c778cd63627a4fe1df3110268ee1154a -:FIN CHECKSUM \ No newline at end of file diff --git a/testFlask/mdm.py b/testFlask/mdm.py index 73a58e24..19deb8a1 100755 --- a/testFlask/mdm.py +++ b/testFlask/mdm.py @@ -152,11 +152,9 @@ def updateSDName(): # Print the dictionary print(req) print(req['id']) - id=req['id'];value=req['value'] - # id, value = req.values() # Dangereux correspondance implicite - value = str(value) #On peut écrire Pi - rId,message,changeDone = monConnecteur.updateSDName(id,value); - assert(rId==id) + id=req['id'];sdnom=req['sdnom'] + sdnom = str(sdnom) #On peut écrire Pi + changeDone,message = monConnecteur.updateSDName(id,sdnom); #changeDone = True print ("changeDone : ",changeDone) diff --git a/testFlask/templates/commandes_2.html b/testFlask/templates/commandes_2.html index 0a5b86f4..7ddfbe3c 100644 --- a/testFlask/templates/commandes_2.html +++ b/testFlask/templates/commandes_2.html @@ -269,7 +269,7 @@ function getParentCommandNode(node) { 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; @@ -564,9 +564,11 @@ $(function(){ 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; @@ -578,18 +580,40 @@ $(function(){ $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 @@ -597,22 +621,39 @@ $(function(){ //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(""); - $tdList.eq(3) - .html( - "
"+ - "
" + - ""+ - // ""+ - "
"+ - "
"+ - "" - ) - .addClass(_attr) - .find("input").css('color','black'); //TODO : A placer ds le CSS + + if (into == undefined ) { + $tdList.eq(3) + .html( + "
"+ + "
" + + ""+ + // ""+ + "
"+ + "
"+ + "" + ) + .addClass(_attr) + .find("input").css('color','black'); //TODO : A placer ds le CSS + } else { + $tdList.eq(3) + .html( + "
"+ + "
" + + ""+ + // ""+ + "
"+ + "
" + ) + .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 @@ -643,7 +714,7 @@ $(function(){ 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) { @@ -803,8 +874,8 @@ $(function(){ 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 @@ -821,22 +892,27 @@ $(function(){ 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) @@ -846,6 +922,49 @@ $(function(){ 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 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;