)
# etape = str(escape(request.args.get("etape", "")))
+## WebApp -> Eficas (signaux) :
+# Pour SIMP : Ajoute, Supprime (MC facultatif), Change la valeur
+# Pour FACT : Ajoute, Supprime
+# Pour PROC : Ajoute, Supprime
+# Pour OPER : Ajoute, Supprime, Nomme, Renomme
# @app.route('/post/<uuid:post_id>')
@app.route("/updateSimp", methods=['POST'])
def updateSimp():
# Print the dictionary
print(req)
print(req['id'])
- id,data=req.values()
- data=str(data) #Oups PN
- r=monConnecteur.changeValeur(id,data);
- print (r)
+ id,data = req.values()
+ data = str(data) #Oups PN
+ #comments,changeIsAccepted = monConnecteur.changeValeur(id,data);
+ changeDone = monConnecteur.changeValeur(id,data);
+ changeDone = False
+ print ("changeDone : ",changeDone)
+ # Ne pas récupérer le noeud dans le cas du SIMP (le changeDone et l''ancienne valeur ds la WebApp suffit
+ node = monConnecteur.getDicoForFancy(monConnecteur.monEditeur.getNodeById(id))
+ print("node :",node)
# myTreeDico=monConnecteur.getDicoObjetsCompletsPourTree(req['id'])
# print("myTreeDico :",myTreeDico)
# return jsonify([myTreeDico])
# return make_response(json.dumps([myTreeDico]))
- return make_response(json.dumps([monConnecteur.getDicoObjetsCompletsPourTree(monConnecteur.monEditeur.tree.racine)]))
- # return make_response(json.dumps([monConnecteur.getDicoObjetsCompletsPourTree(monConnecteur.monEditeur.getNodeById(req['id']))]))
+ #return make_response(json.dumps([monConnecteur.getDicoObjetsCompletsPourTree(monConnecteur.monEditeur.tree.racine)]))
+ return make_response(json.dumps( {'source':node, 'changeIsAccepted' : changeDone} ))
# # Return a string along with an HTTP status code
# return "JSON received!", 200
-
else:
# The request body wasn't JSON so return a 400 HTTP status code
return "Request was not JSON", 400
-
+
+## SSE from Eficas signals :
+# - Validite
+# - Ajouter un noeud (et ses enfants)
+# - Supprimer un noeud (et ses enfants),
+# - ReAffichage d'un noeud (et ses enfants)
+# - Changement d'un nom de mot-clé référencé
+
@app.route("/forward/", methods=['POST'])
def move_forward():
#Moving forward code
<!-- <script src="{{ url_for('static', filename='jquery/dist/jquery.js') }}"></script> -->
+ <!-- jQuery library -->
<script src="//code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="//code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<!-- jQuery library -->
</style>
- <script type="text/javascript">
- var glyph_opts = {
- preset: "bootstrap3",
- map: {
- }
- };
+ <!-- <script type="text/javascript"> -->
+ <!-- var glyph_opts = { -->
+ <!-- preset: "bootstrap3", -->
+ <!-- map: { -->
+ <!-- } -->
+ <!-- }; -->
- $(function(){
- $("#tree10").fancytree({
- extensions: ["dnd5", "edit", "glyph", "wide"],
- checkbox: true,
- selectMode: 3,
- dnd5: {
- dragStart: function(node, data) { return true; },
- dragEnter: function(node, data) { return true; },
- dragDrop: function(node, data) { data.otherNode.copyTo(node, data.hitMode); }
- },
- glyph: glyph_opts,
- source: [
- {title: "Node 1", key: "1"},
- {title: "Folder 2", key: "2", folder: true, children: [
- {title: "Node 2.1", key: "3"},
- {title: "Node 2.2", key: "4"}
- ]}
- ],
- wide: {
- iconWidth: "1em", // Adjust this if @fancy-icon-width != "16px"
- iconSpacing: "0.5em", // Adjust this if @fancy-icon-spacing != "3px"
- labelSpacing: "0.1em", // Adjust this if padding between icon and label != "3px"
- levelOfs: "1.5em" // Adjust this if ul padding != "16px"
- },
- icon: function(event, data){
- // if( data.node.isFolder() ) {
- // return "glyphicon glyphicon-book";
- // }
- },
- //lazyLoad: function(event, data) {
- // data.result = {url: "ajax-sub2.json", debugDelay: 1000};
- //}
- });
- });
- </script>
+ <!-- $(function(){ -->
+ <!-- $("#tree10").fancytree({ -->
+ <!-- extensions: ["dnd5", "edit", "glyph", "wide"], -->
+ <!-- checkbox: true, -->
+ <!-- selectMode: 3, -->
+ <!-- dnd5: { -->
+ <!-- dragStart: function(node, data) { return true; }, -->
+ <!-- dragEnter: function(node, data) { return true; }, -->
+ <!-- dragDrop: function(node, data) { data.otherNode.copyTo(node, data.hitMode); } -->
+ <!-- }, -->
+ <!-- glyph: glyph_opts, -->
+ <!-- source: [ -->
+ <!-- {title: "Node 1", key: "1"}, -->
+ <!-- {title: "Folder 2", key: "2", folder: true, children: [ -->
+ <!-- {title: "Node 2.1", key: "3"}, -->
+ <!-- {title: "Node 2.2", key: "4"} -->
+ <!-- ]} -->
+ <!-- ], -->
+ <!-- wide: { -->
+ <!-- iconWidth: "1em", // Adjust this if @fancy-icon-width != "16px" -->
+ <!-- iconSpacing: "0.5em", // Adjust this if @fancy-icon-spacing != "3px" -->
+ <!-- labelSpacing: "0.1em", // Adjust this if padding between icon and label != "3px" -->
+ <!-- levelOfs: "1.5em" // Adjust this if ul padding != "16px" -->
+ <!-- }, -->
+ <!-- icon: function(event, data){ -->
+ <!-- // if( data.node.isFolder() ) { -->
+ <!-- // return "glyphicon glyphicon-book"; -->
+ <!-- // } -->
+ <!-- }, -->
+ <!-- //lazyLoad: function(event, data) { -->
+ <!-- // data.result = {url: "ajax-sub2.json", debugDelay: 1000}; -->
+ <!-- //} -->
+ <!-- }); -->
+ <!-- }); -->
+ <!-- </script> -->
<!-- <script> -->
<!-- $(document).ready(function(){ -->
<div class="row">
<hr>
- <h2>Searchable Tree</h2>
+ <h2>MyDataModel : Testing the WebAPP approach</h2>
<div class="col-sm-4">
- <h2>Input</h2>
+ <h2>Searching</h2>
<!-- <form> -->
<div class="form-group">
<label for="input-search" class="sr-only">Search Tree:</label>
<!-- </form> -->
</div>
<div class="col-sm-4">
- <h2>Tree</h2>
+ <h2>My dataset</h2>
<!-- <div id="treeview-searchable" class=""></div> -->
<!-- <div id="tree1" class="table table-condensed table-hover table-striped fancytree-fade-expander"> -->
<table id="tree1" class="table table-condensed table-hover table-striped fancytree-fade-expander">
<!-- $("#tree1").fancytree({ source: JSON.parse(getTree1()), }) -->
-
+ //Doublon cf. base.html
var glyph_opts = {
preset: "bootstrap3",
map: {
}
};
- $(function(){
- $("#tree1").fancytree({
- //extensions: ["dnd5", "edit", "glyph", "wide", "table", "gridnav"],
- extensions: [ "glyph", "table", "ariagrid"],
- checkbox: true,
- <!-- selectMode: 3, -->
- selectMode: 1,
- dnd5: {
+ $(function(){
+ $("#tree1").fancytree({
+ //extensions: ["dnd5", "edit", "glyph", "wide", "table", "gridnav"],
+ extensions: [ "glyph", "table", "ariagrid"],
+ //extensions: [ "glyph", "table", "gridnav"],
+ checkbox: true, // Activate the use of checkboxes next to the nodes
+ <!-- selectMode: 3, -->
+ selectMode: 1,
+ dnd5: {
dragStart: function(node, data) { return true; },
dragEnter: function(node, data) { return true; },
dragDrop: function(node, data) { data.otherNode.copyTo(node, data.hitMode); }
// labelSpacing: "0.1em", // Adjust this if padding between icon and label != "3px"
// levelOfs: "1.5em" // Adjust this if ul padding != "16px"
//},
- icon: function(event, data){
+ icon: function(event, data) {
if( data.node.isFolder() ) {
return "glyphicon glyphicon-book";
}
},
- table: {
- checkboxColumnIdx: 1,
- nodeColumnIdx: 2
+ table: { // Options for the table extension
+ checkboxColumnIdx: 1, // Tree Nodes Checkboxes are rendered at column #1 (numbered from #0)
+ nodeColumnIdx: 2, // Tree Nodes are rendered at column #2
+ indentation : 10 // Tree Nodes indentation between levels
},
gridnav: {
autofocusInput: true, // Focus first embedded input if node gets activated
handleCursorKeys: true // Allow UP/DOWN in inputs to move to prev/next node
},
+ ariagrid: {
+ cellFocus: 'allow'
+ },
//lazyLoad: function(event, data) {
// data.result = {url: "ajax-sub2.json", debugDelay: 1000};
//}
+
renderColumns: function(event, data) {
-//var tree=$.ui.fancytree.getTree("#tree1")
-//p1=tree.getNodeByKey('8304986a334211ec853cac220bca9aa6')
-//$(p1.tr).find(">td")
+
+ //var tree=$.ui.fancytree.getTree("#tree1")
+ //p1=tree.getNodeByKey('8304986a334211ec853cac220bca9aa6')
+ //$(p1.tr).find(">td")
+
var node = data.node,
$tdList = $(node.tr).find(">td");
+ var _attr=''
+
+ //Render Column #0
$tdList.eq(0).text(node.getIndexHier());
- //$tdList.eq(3).text(!!node.folder);
-//$tdList.eq(3).text(node.data.wValue);
-//if ( $tdList.eq(3).hasClass("EFC_SIMP") )
- //if ( node.data.class ~ "EFC_SIMP" )
-// if ( node.title === "param1" ) {
+
+ //Render Column #3
+ // Jaune Eficas #ffff00
+ // Rouge Eficas #ff0000
+ // Vert Eficas #00ff00
if (node.data.classeAccas == "MCSIMP") {
-// $tdList.eq(3).html("<simp><input type='input' class='form-control-sm' id='simp1' placeholder='"+node.data.wValue+"' value='"+node.data.wValue+"'></simp>");
- $tdList.eq(3).html("<form class='was-validated'><div class='form-group'><input type='input' class='form-control-sm' id='simp1' placeholder='"+node.data.wValue+"' value='"+node.data.wValue+"' required><div class='valid-feedback'>Valid.</div><div class='invalid-feedback'>Please fill out this field.</div></div></form>");
-//$tdList.eq(3).css('color','black') //td
- $tdList.eq(3).find("input").css('color','black')
+ //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
+ if( node.data.validite ) {
+ _attr='has-success';
+ // $(".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
+ } else {
+ _attr='has-error';
+ //$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
+ } //TODO: paramétrer l'attribut/framework
+ //console.log("node.data.validite, _attr :"+node.data.validite+" , "+_attr);
+ // $tdList.eq(3).html("<simp><input type='input' class='form-control-sm' id='simp1' placeholder='"+node.data.wValue+"' value='"+node.data.wValue+"'></simp>");
+ $tdList.eq(3)
+ .html(
+ "<form class='was-validated'>"+ //'was-validated' ??
+ "<div class='form-group'>" +
+ // "<div class='form-group "+ _attr + "'>" +
+ // "<div class='form-group has-error'>" +
+ "<input type='input' class='form-control' id='simp1' placeholder='" + node.data.wValue + //TODO:intosugg
+ "' value='"+node.data.wValue+"' required>"+
+ //"<div class='valid-feedback'>Valid.</div>"+
+ //"<div class='invalid-feedback'>Please fill out this field.</div>"+
+ "</div>"+
+ "</form>"
+ )
+ .addClass(_attr)
+ .find("input").css('color','black'); //TODO : A placer ds le CSS
+ //$tdList.eq(1).css('back-ground,'green') // Update the checkbox validation state TODO: create a CSS class
+
+ //$tdList.eq(3).css('color','black') //td
+ //$tdList.eq(3).find("input").css('color','black')
<!-- $tdList.eq(3).html("<simp>"+node.data.wValue+"</simp>"); -->
- }
+ } else {
+ $tdList.eq(2).prop("colspan", 3).nextAll().remove();
+ return;
+ }
},
+
icon: function(event, data) {
if( data.node.type ) {
return "ft-ico-" + data.node.type;
activate: function(event, data) {
console.log("event.type, data :"+event.type+" , "+data);
},
+ focusTree: function(event, data) {
+ console.log("event.type, data :"+event.type+" , "+data);
+ },
activateCell: function(event, data) {
console.log("event.type, data :"+event.type+" , "+data);
},
defaultGridAction: function( event, data ) {
var node = data.node
- input=$(node.tr).find('input')
- // Called when ENTER is pressed in cell-mode.
- // Return false to prevent default
- 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:
- } else if ( data.colIdx != 3 ) {
- // eslint-disable-next-line no-alert
- alert( "Custom default action: " + data.node.title );
- return false;
- };
- $.ajax({
- type: "POST",
- url: "{{ url_for('updateSimp') }}",
- data: JSON.stringify({id: node.key, data:input.val() }),
-// data: JSON.stringify({id: 5}),
- contentType: "application/json; charset=utf-8",
- dataType: "json",
- // The callback function when the web service return success.
- success: function(data, status) {
- alert("Data: " + data + "\nStatus: " + status +"\nId :", $(this).attr("id") );
- console.log( {'data': data } );
- },
- // The callback function when the web service return fail.
- failure: function(errMsg) {
- alert(errMsg);
- }
- });
+ var rValue,rValidite
+
+ if (node.data.classeAccas == "MCSIMP") {
+ $input=$(node.tr).find('input')
+ value=$input.val()
+
+ // Called when ENTER is pressed in cell-mode.
+ // Return false to prevent default
+ 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:
+ } else if ( data.colIdx != 3 ) {
+ // eslint-disable-next-line no-alert
+ alert( "Custom default action: " + data.node.title );
+ return false;
+ };
+
+ $.ajax({
+ type : "POST",
+ url : "{{ url_for('updateSimp') }}",
+ data : JSON.stringify({id: node.key, data:value }),
+ contentType : "application/json; charset=utf-8",
+ dataType : "json",
+ // The callback function when the web service return success.
+ success: function(data, status) {
+ alert("Data: " + data + "\nStatus: " + status +"\ndata.changeIsAccepted :" +data.changeIsAccepted );
+ rValue=data.source['wValue']; rValidite=data.source['validite'];
+ console.log( {'data': data } );
+ console.log( {'rValue': rValue } );
+ console.log( {'rValidite': rValidite } );
+//node.fromDict()
+//source=JSON.parse(getTree1())
+node.data.wValue = rValue
+node.data.validite = rValidite
+console.log('rValue : '+rValue);
+console.log('rValidite : '+rValidite);
+node.render(true,false); //force rendering the node (not parents nor descendants)
+ },
+ // The callback function when the web service return fail.
+ failure: function(errMsg) {
+ alert(errMsg);
+ }
+ })
+//node.render(true,false); //force rendering the node (not parents nor descendants)
+//node.renderStatus(); //CSS element updates
+ }
},
lazyLoad: function(event, data) {
var node = data.node;