From e6c81c50637705563933edae34df0fe5cfab3d19 Mon Sep 17 00:00:00 2001 From: Eric Fayolle Date: Thu, 10 Feb 2022 16:41:55 +0100 Subject: [PATCH] =?utf8?q?Gestion=20du=20passage=20d'un=20SIMP=20=C3=A0=20?= =?utf8?q?un=20autre=20sans=20la=20touche=20enter=20:=20phase=201'?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- testFlask/mdm.py | 4 +- testFlask/templates/base.html | 4 ++ testFlask/templates/commandes_2.html | 69 +++++++++++++++++++++------- testFlask/templates/main_menu.html | 9 ++-- 4 files changed, 64 insertions(+), 22 deletions(-) diff --git a/testFlask/mdm.py b/testFlask/mdm.py index bb54b54f..2ca61570 100755 --- a/testFlask/mdm.py +++ b/testFlask/mdm.py @@ -227,11 +227,11 @@ app.fromConnecteur=fromConnecteur # - Changement d'un nom de mot-cle reference def propageValide(id, valid): - #print ('Flask/propageValide: ', id, valid) + print ('Flask/propageValide: ', id, valid) sse.publish( {'id':id, 'valid':valid, 'message': "Hello from propageValide!"}, type='propageValide') def updateNodeInfo(id, info): - #print ('Flask/updateNodeInfo: ', id, info) + print ('Flask/updateNodeInfo: ', id, info) sse.publish( {'id':id, 'info':info, 'message': "Hello from updateNodeInfo!"}, type='updateNodeInfo') def appendChildren(id, fcyTreeJson, pos): diff --git a/testFlask/templates/base.html b/testFlask/templates/base.html index 9e7b4e08..95b50ed8 100644 --- a/testFlask/templates/base.html +++ b/testFlask/templates/base.html @@ -155,6 +155,10 @@ z-index: 8500; } + #available_catalogs { + z-index: 8500; + } + diff --git a/testFlask/templates/commandes_2.html b/testFlask/templates/commandes_2.html index 4fa42f62..c70e059a 100644 --- a/testFlask/templates/commandes_2.html +++ b/testFlask/templates/commandes_2.html @@ -235,39 +235,55 @@ function getParentCommandNode(node) { // TODO Vérif assertion : Les functions clickOn ont des arguments en chaîne de caractères pour être facilement // utilsées dans les attributs des elements html on="clickOn('arg1','arg2',)" function clickOnCommand(treeCssSelStr, msgCssSelStr, cmdName, key ) { - const tree = $.ui.fancytree.getTree(treeCssSelStr); + 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 != "") { fromNode = tree.getNodeByKey(key); } else { fromNode = tree.activeNode; }; if ( fromNode == null) { - index=0; pos=0; + pos=0; } else { parentList = fromNode.getParentList(); // default : (false,false)==(rootNode exclus, not self) console.log("clickOnCommand : parentList "+parentList) - if ( parentList.length == 0 ) { // TODO : Verif, ne devrait pas être possible + if ( parentList.length == 0 ) { //If the current dataset filename node is activated console.log("clickOnCommand : index is forced = 0"); - index=0; pos=0; // The first node is always the code name + pos=0; // The first node is always the current dataset filename } else { if ( parentList.length == 1 ) { activeCommandKey = fromNode.key; } else { - activeCommandKey = parentList[1].key; //fromNode.getParentList()[0] is always the node so [1] is always the first level, the eficas command level + activeCommandKey = parentList[1].key; //fromNode.getParentList()[0] is always the node so [1] is always the eficas command level }; console.log("clickOnCommand : activeCommandKey "+activeCommandKey) - commandList = tree.rootNode.getChildren()[0].getChildren(); // le premier node est actuellement le nom de code - index = commandList.findIndex(function(n){return n.key == activeCommandKey;}); pos=index+1; + commandList = datasetNode.getChildren(); // le premier node est le nom de fichier du dataset d'ou le getChildren() supplémentaire + index = commandList.findIndex(function(n){return n.key == activeCommandKey;}); + pos=index+1; } } - console.log("clickOnCommand : index = "+index); - sendAppendChild( tree.rootNode.children[0].key, cmdName, pos); + console.log("clickOnCommand : pos = "+pos); + sendAppendChild( datasetNode.key, cmdName, pos); + datasetNode.setExpanded(); //BUG: Si le sendAppendChild n'est pas fini, il n'y a rien à déployer -> promise + if ( tree.activeNode == null ) datasetNode.setActive() + + //tree.activeNode.scrollIntoView(true) + //$(tree.activeNode).scrollTop(20) + //tree.activeNode.tr.offsetTop + + $(document).scrollTop(tree.activeNode.tr.offsetTop); //Replace the active node in order to see the added command }; //GESTION DES EVENEMENTS PROVENANT DU SERVEUR const source = new EventSource("{{ url_for('sse.stream') }}"); +source.addEventListener('error', function(event) { + alert("Failed to connect to event stream. Is Redis running?"); +}, false); +source.addEventListener('message', function(event) { + alert("An event message has been received."); +}, false); // --- propageValid --- (function (treeCssSelStr, msgCssSelStr) { @@ -391,9 +407,6 @@ const source = new EventSource("{{ url_for('sse.stream') }}"); })('#tree1','#tree1-messages'); -source.addEventListener('error', function(event) { - alert("Failed to connect to event stream. Is Redis running?"); -}, false); function getTree1() { // Some logic to retrieve, or generate tree structure @@ -639,7 +652,11 @@ $(function(){ const parentKey = parent != null ? parent.key : null; // const parentTitle = parent != null ? parent.title : "" ; if ( targetType == 'title' ) { - sendAppendChild( parentKey, title, null); + sendAppendChild( parentKey, title, null); //TODO : retun node and apply expanded + + // tree.visit(function(node){ + // node.setExpanded(true); + // }); }; }, source: optTreeSrc, }; @@ -713,10 +730,31 @@ $(function(){ }, + // blur: function(event, data) { + // console.log("------ event.type, data :"+event.type+" , "+data); + // //TODO: Générer un event defaultGridAction si le input a été modifié ! + // const widget = data.widget + // const node = data.node + // const tree = data.node.tree + // const options = data.options + // //const e = jQuery.Event("fancytreedefaultgridaction",data); //pas de sens + // //$(node).trigger(e) + // //$(widget).trigger(e) + // //TODO : Je n'ai pas trouvé comment lancer un evenement pour qu'il soit pris en compte par fancytree + // options.defaultGridAction(event,data) + + // // var e = jQuery.Event( "keydown", { keyCode: 64 } ); + // // $(tree1).trigger(e) + + // // $td = $(event.target).closest("td"); + // // $(event.target).is(":input") + + // }, defaultGridAction: function( event, data ) { //(used by ext-aria) The user hit enter on the active row or cell. const node = data.node // var rValue,rValidite,rChangeIsAccepted const _msgCssSelStr='#tree1-messages'; //TODO: A déplacer + console.log("event.type, data :"+event.type+" , "+data); if (node.data.classeAccas == "MCSIMP") { $input=$(node.tr).find('input'); @@ -726,7 +764,7 @@ $(function(){ // Return false to prevent default // data.activeTd contains the currently active element or null // data.colIdx contains the 0-based column index or -1 - console.log("event.type, data :"+event.type+" , "+data); + // console.log("event.type, data :"+event.type+" , "+data); if( !data.activeTd ) { alert( "Custom default action for row: " + data.node.title ); // we don't return false, so default action is applied: @@ -797,9 +835,6 @@ $(function(){ click: function(event, data) { console.log("event.type, data :"+event.type+" , "+data); }, - blur: function(event, data) { - console.log("event.type, data :"+event.type+" , "+data); - }, blurTree: function(event, data) { console.log("event.type, data :"+event.type+" , "+data); }, diff --git a/testFlask/templates/main_menu.html b/testFlask/templates/main_menu.html index d80fc019..f18332d4 100644 --- a/testFlask/templates/main_menu.html +++ b/testFlask/templates/main_menu.html @@ -23,9 +23,12 @@ -- 2.39.2