Corretti bug sulle espressioni logiche

This commit is contained in:
Luca Trupiano 2025-02-18 12:49:18 +01:00
parent dc93993858
commit 4dd21da664
2 changed files with 71 additions and 27 deletions

View File

@ -1947,7 +1947,7 @@
</div> </div>
</div> </div>
<div class="col-md-auto p-0 m-0 text-right text-success"> <div class="col-md-auto p-0 m-0 text-right text-success">
<button class="btn btn-sm removeCla text-success border rounded px-1 pb-0" style="z-index: 90"> <button class="btn btn-sm removeCla text-success border rounded px-1 pb-0" style="z-index: 90" id="removeClaxX3Xx">
<ion-icon name="close-circle"></ion-icon> <ion-icon name="close-circle"></ion-icon>
</button> </button>
</div> </div>
@ -2008,7 +2008,7 @@
<div class="col-md-auto p-0 m-0 text-right text-success"> <div class="col-md-auto p-0 m-0 text-right text-success">
<button <button
class="btn btn-sm removeCla text-success border rounded px-1 pb-0" class="btn btn-sm removeCla text-success border rounded px-1 pb-0"
style="z-index: 90"> style="z-index: 90" id="removeRifxR3Rx">
<ion-icon name="close-circle"></ion-icon> <ion-icon name="close-circle"></ion-icon>
</button> </button>
</div> </div>

View File

@ -408,6 +408,7 @@ $(document).ready(function() {
$(tabPanelId).attr("data-claActive", 0); $(tabPanelId).attr("data-claActive", 0);
$(this).closest('li').find('.clatext').fadeTo( "slow", 0.6 ); $(this).closest('li').find('.clatext').fadeTo( "slow", 0.6 );
} }
refreshClaList();
refreshSortables(); refreshSortables();
}); });
@ -1003,17 +1004,34 @@ $(document).ready(function() {
queryJson.Clausola0.contesto = JSON.stringify(window.context0); queryJson.Clausola0.contesto = JSON.stringify(window.context0);
queryJson.unitaRicerca = $("#unitaRicerca")[0].options[$("#unitaRicerca")[0].selectedIndex].value; queryJson.unitaRicerca = $("#unitaRicerca")[0].options[$("#unitaRicerca")[0].selectedIndex].value;
var claLiArray = $("#sortable0").find(".claLI"); var claLiArray = $("#sortable0").find(".claLI");
var countActCla = 0;
var buttonID = "";
if ($(claLiArray).length) { if ($(claLiArray).length) {
if ($("#li-cla0")[0]) { if ($("#li-cla0")[0]) {
$("#li-cla0")[0].remove(); $("#li-cla0")[0].remove();
}; };
$(claLiArray).each(function(){ $(claLiArray).each(function(){
var claIdNum = $(this).attr('id').substr(6); var claIdNum = $(this).attr('id').substr(6);
if ($(this).find(".claAct").prop('checked')) {
countActCla++;
}
updateClaListItem(claIdNum, "#sortable0"); updateClaListItem(claIdNum, "#sortable0");
}); });
if ($(claLiArray).length == 1) { if ($(claLiArray).length == 1) {
var remCla = claLiArray.find(".removeCla"); var remCla = claLiArray.find(".removeCla");
remCla.addClass("disabled"); remCla.addClass("disabled");
var actCla = claLiArray.find(".claAct");
actCla.prop('disabled', true);
} else {
if ( countActCla == 1 ) {
claLiArray.find(".claAct").each(function(){
if ($(this).prop('checked')) {
$(this).prop('disabled', true);
buttonID = "removeCla" + $(this).attr('id').substr(9);
$('#'+buttonID).addClass("disabled");
}
});
}
}; };
} else { } else {
if (claListLen == 0 && condListLen == 0) { if (claListLen == 0 && condListLen == 0) {
@ -1026,16 +1044,32 @@ $(document).ready(function() {
var rifLiArray = $("#sortableRif0").find(".rifLI"); var rifLiArray = $("#sortableRif0").find(".rifLI");
if ($(rifLiArray).length) { if ($(rifLiArray).length) {
countActCla = 0;
if ($("#li-rif0")[0]) { if ($("#li-rif0")[0]) {
$("#li-rif0")[0].remove(); $("#li-rif0")[0].remove();
}; };
$(rifLiArray).each(function(){ $(rifLiArray).each(function(){
var rifIdNum = $(this).attr('id').substr(6); var rifIdNum = $(this).attr('id').substr(6);
if ($(this).find(".claAct").prop('checked')) {
countActCla++;
}
updateRifListItem(rifIdNum, "#sortableRif0"); updateRifListItem(rifIdNum, "#sortableRif0");
}); });
if ($(rifLiArray).length == 1) { if ($(rifLiArray).length == 1) {
var remCla = rifLiArray.find(".removeCla"); var remCla = rifLiArray.find(".removeCla");
remCla.addClass("disabled"); remCla.addClass("disabled");
var actCla = rifLiArray.find(".claAct");
actCla.prop('disabled', true);
} else {
if ( countActCla == 1 ) {
rifLiArray.find(".claAct").each(function(){
if ($(this).prop('checked')) {
$(this).prop('disabled', true);
buttonID = "removeRif" + $(this).attr('id').substr(9);
$('#'+buttonID).addClass("disabled");
}
});
}
}; };
} else { } else {
if (rifLiArray == 0 && condListRifLen == 0) { if (rifLiArray == 0 && condListRifLen == 0) {
@ -1076,33 +1110,38 @@ $(document).ready(function() {
checkInsert = ' checked="checked"'; checkInsert = ' checked="checked"';
}; };
var remCla = $("#" + rifListItemId).find(".removeCla"); var remCla = $("#" + rifListItemId).find(".removeCla");
if (remCla.hasClass("disabled")){ if (remCla.hasClass("disabled")) {
remCla.removeClass("disabled"); remCla.removeClass("disabled");
} }
rifSubParList.each(function(){ var actCla = $("#" + rifListItemId).find(".claAct");
var claSubParType = $(this)[0].type; if (actCla.attr('disabled')) {
if (claSubParType == "select-one") { actCla.prop('disabled', false);
if (!($(this).prop("disabled"))) { }
rifText = rifText + $(this)[0].title + ': <span class="font-italic">' + $(this)[0].options[$(this)[0].selectedIndex].text + '</span>; ';
}; rifSubParList.each(function() {
jsonTextToParse = jsonTextToParse + ', "' + $(this)[0].id.replace(rifIdNum,"") + '": "' + $(this)[0].options[$(this)[0].selectedIndex].value + '"'; var claSubParType = $(this)[0].type;
if ($(this)[0].id.startsWith("Tipo_Riferimento")) { if (claSubParType == "select-one") {
if ($(this)[0][3].selected) { if (!($(this).prop("disabled"))) {
$('#Tipo_Citazione'+rifIdNum)[0].removeAttribute("style"); rifText = rifText + $(this)[0].title + ': <span class="font-italic">' + $(this)[0].options[$(this)[0].selectedIndex].text + '</span>; ';
$('#Tipo_Citazione'+rifIdNum).prop('disabled', false);
} else {
$('#Tipo_Citazione'+rifIdNum)[0].selectedIndex = 0;
$('#Tipo_Citazione'+rifIdNum)[0].setAttribute("style", "opacity: 0.6;");
$('#Tipo_Citazione'+rifIdNum).prop('disabled', true);
}
};
}; };
if (claSubParType == "text" && $(this)[0].value) { jsonTextToParse = jsonTextToParse + ', "' + $(this)[0].id.replace(rifIdNum, "") + '": "' + $(this)[0].options[$(this)[0].selectedIndex].value + '"';
rifText = rifText + $(this)[0].name + ': <span class="font-italic">"' + $(this)[0].value + '"</span>; '; if ($(this)[0].id.startsWith("Tipo_Riferimento")) {
jsonTextToParse = jsonTextToParse + ', "' + $(this)[0].id.replace(rifIdNum,"") + '": "' + $(this)[0].value + '"'; if ($(this)[0][3].selected) {
$('#Tipo_Citazione' + rifIdNum)[0].removeAttribute("style");
$('#Tipo_Citazione' + rifIdNum).prop('disabled', false);
} else {
$('#Tipo_Citazione' + rifIdNum)[0].selectedIndex = 0;
$('#Tipo_Citazione' + rifIdNum)[0].setAttribute("style", "opacity: 0.6;");
$('#Tipo_Citazione' + rifIdNum).prop('disabled', true);
}
}; };
}); };
jsonTextToParse = jsonTextToParse.replace('{, ','{') + '}' if (claSubParType == "text" && $(this)[0].value) {
rifText = rifText + $(this)[0].name + ': <span class="font-italic">"' + $(this)[0].value + '"</span>; ';
jsonTextToParse = jsonTextToParse + ', "' + $(this)[0].id.replace(rifIdNum, "") + '": "' + $(this)[0].value + '"';
};
});
jsonTextToParse = jsonTextToParse.replace('{, ', '{') + '}'
if ($("#" + rifListItemId)[0]) { if ($("#" + rifListItemId)[0]) {
$("#" + rifListItemId + " .clatext").replaceWith('<span class="small clatext">' + rifText + '<br>Contesto: <span class="font-italic">' + contextText + '</span></span>'); $("#" + rifListItemId + " .clatext").replaceWith('<span class="small clatext">' + rifText + '<br>Contesto: <span class="font-italic">' + contextText + '</span></span>');
} else { } else {
@ -1130,6 +1169,11 @@ $(document).ready(function() {
if (remCla.hasClass("disabled")){ if (remCla.hasClass("disabled")){
remCla.removeClass("disabled"); remCla.removeClass("disabled");
} }
var actCla = $("#" + claListItemId).find(".claAct");
if (actCla.attr('disabled')) {
actCla.prop('disabled', false);
}
switch (claType) { switch (claType) {
case "Clausola": case "Clausola":
var l_f = $("form #lemma_forma" + claIdNum)[0].options[$("form #lemma_forma" + claIdNum)[0].selectedIndex].value; var l_f = $("form #lemma_forma" + claIdNum)[0].options[$("form #lemma_forma" + claIdNum)[0].selectedIndex].value;