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 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>
</button>
</div>
@ -2008,7 +2008,7 @@
<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">
style="z-index: 90" id="removeRifxR3Rx">
<ion-icon name="close-circle"></ion-icon>
</button>
</div>

View File

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