Aggiunte condizioni annidate nella GUI da query salvate

This commit is contained in:
Luca Trupiano 2022-10-10 18:52:06 +02:00
parent 4fa1641734
commit 0fa822bead
1 changed files with 24 additions and 33 deletions

View File

@ -128,11 +128,11 @@ $(document).ready(function() {
$('#cla' + tabID + '-tab').tab('show'); $('#cla' + tabID + '-tab').tab('show');
break; break;
case "andCond": case "andCond":
addLogicCond("AND") addLogicCond("AND","#sortable0")
refreshConnectWith(); refreshConnectWith();
break; break;
case "orCond": case "orCond":
addLogicCond("OR") addLogicCond("OR","#sortable0")
refreshConnectWith(); refreshConnectWith();
break; break;
default: default:
@ -638,7 +638,7 @@ $(document).ready(function() {
} }
// Funzione di creazione del LI delle condizioni logiche // Funzione di creazione del LI delle condizioni logiche
function addLogicCond(condtype){ function addLogicCond(condtype,sortableNum){
condListLen++; condListLen++;
if (condtype == "AND") { if (condtype == "AND") {
var LItext = condLIpart1 + condListLen + condLIpart2and + condListLen + condLIpart3and + condListLen + condLIpart4; var LItext = condLIpart1 + condListLen + condLIpart2and + condListLen + condLIpart3and + condListLen + condLIpart4;
@ -648,7 +648,7 @@ $(document).ready(function() {
if ($("#H-cla0")[0]) { if ($("#H-cla0")[0]) {
$("#H-cla0")[0].remove(); $("#H-cla0")[0].remove();
}; };
$("#sortable0").append(LItext); $(sortableNum).append(LItext);
$("#sortable" + condListLen).sortable(); $("#sortable" + condListLen).sortable();
$("#sortable" + condListLen).sortable( "option", "appendTo", document.body ); $("#sortable" + condListLen).sortable( "option", "appendTo", document.body );
$("#sortable" + condListLen).sortable({ $("#sortable" + condListLen).sortable({
@ -931,6 +931,7 @@ $(document).ready(function() {
}; };
function makeUpGui(queryJson) { function makeUpGui(queryJson) {
$("#risultatitesto").val(queryJson["LogicaGui"]);
// 1. verifica json legit --> TO DO // 1. verifica json legit --> TO DO
// 2. pulire interfaccia --> OK // 2. pulire interfaccia --> OK
// 3. clausola0 --> OK // 3. clausola0 --> OK
@ -961,32 +962,39 @@ $(document).ready(function() {
}; };
// 4 e 5: // 4 e 5:
guiLogicString = queryJson.LogicaGui; guiLogicString = queryJson.LogicaGui;
var clauCount = 0;
var clau2Make = ""; var clau2Make = "";
var treeLevel = [];
var claParent = [];
for (var i=0; i < guiLogicString.length; i++) { for (var i=0; i < guiLogicString.length; i++) {
//console.log("- " + logicExpr[i]);
switch (guiLogicString[i]) { switch (guiLogicString[i]) {
case "(": case "(":
//console.log("(");
break; break;
case ")": case ")":
//console.log(")"); treeLevel.pop();
break; break;
case "OR": case "OR":
addLogicCond("OR"); addLogicCond("OR",treeLevel[treeLevel.length - 1]);
treeLevel.push("#sortable" + condListLen);
guiLogicString[i] = "#sortable" + condListLen;
refreshConnectWith(); refreshConnectWith();
break; break;
case "AND": case "AND":
if (i > 1) { if (i > 1) {
addLogicCond("AND"); addLogicCond("AND",treeLevel[treeLevel.length - 1]);
treeLevel.push("#sortable" + condListLen);
refreshConnectWith(); refreshConnectWith();
guiLogicString[i] = "#sortable" + condListLen;
} else {
guiLogicString[1] = "#sortable0";
treeLevel.push("#sortable0");
}; };
break; break;
default: default:
clauCount++ claParent.push(treeLevel[treeLevel.length - 1]);
}; };
}; };
for (var i=1; i <= clauCount; i++) { //console.log(claParent);
for (var i=1; i <= claParent.length; i++) {
clau2Make = queryJson["Clausola" + i].TipoClausola; clau2Make = queryJson["Clausola" + i].TipoClausola;
active = queryJson["Clausola" + i].Attiva active = queryJson["Clausola" + i].Attiva
switch (clau2Make) { switch (clau2Make) {
@ -997,19 +1005,6 @@ $(document).ready(function() {
$("#cla" + tabID + " .catgram").val(selectedValue); $("#cla" + tabID + " .catgram").val(selectedValue);
addCatgramSubcla("cla" + tabID,selectedValue); addCatgramSubcla("cla" + tabID,selectedValue);
var ks = Object.keys(queryJson["Clausola" + i]); var ks = Object.keys(queryJson["Clausola" + i]);
/* for (var j = 5; j < ks.length; j++) {
switch ($("#cla" + i + ks[j])[0].type) {
case "fieldset":
var sval = queryJson["Clausola" + i][ks[j]]
$("#cla" + tabID + sval.replace(/\s/g, '')).attr("checked",true);
console.log(sval);
break;
case "select-one":
$("#cla" + i + ks[j]).val([queryJson["Clausola" + i][ks[j]]])
break;
default:
};
}; */
for (var j = 5; j < ks.length; j++) { for (var j = 5; j < ks.length; j++) {
var test="cla" + i + ks[j]; var test="cla" + i + ks[j];
var melement = document.getElementById(test); var melement = document.getElementById(test);
@ -1044,17 +1039,13 @@ $(document).ready(function() {
case "Struttura": case "Struttura":
addStruCla(active); addStruCla(active);
break; break;
/* case "andCond":
addLogicCond("AND");
refreshConnectWith();
break;
case "orCond":
addLogicCond("OR");
refreshConnectWith();
break; */
default: default:
}; };
var ind = guiLogicString.indexOf("Clausola" + i);
guiLogicString[ind] = "#cla" + tabID;
}; };
// 6:
//console.log(guiLogicString);
refreshTabList(); refreshTabList();
refreshClaList(); refreshClaList();
refreshSortables(); refreshSortables();