// 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 <efficas code> node so [1] is always the first level, the eficas command level
+ activeCommandKey = parentList[1].key; //fromNode.getParentList()[0] is always the <efficas current dataset> 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) {
})('#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
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, };
},
+ // 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');
// 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
- 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:
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);
},