Risolto visualizzazione clausole selezionate

This commit is contained in:
nicola 2024-12-11 18:39:17 +01:00
parent 354fd674a7
commit 2d07be7177
2 changed files with 127 additions and 177 deletions

View File

@ -703,7 +703,7 @@
id="lemma_formaINIT">
<option value="forma">La forma</option>
<option value="lemma">Il lemma</option>
<option disabled value="testo">Il testo</option>
<!-- <option disabled value="testo">Il testo</option> -->
</select> <input type="text"
class="form-control form-control-sm monMe"
id="queryTextINIT" placeholder="inserisci un termine"
@ -732,7 +732,7 @@
</div>
<select
class="form-control custom-select custom-select-sm catgram monMe bg-light text-muted border btn-outline-success"
name="typeGramm0" id="grammtypesN"
name="typeGramm0" id="grammtypesN" data-claType="Grammaticale"
title="Categoria grammaticale" value="oggetto">
<option value="all">Categoria grammaticale</option>
<optgroup label="Volgare">
@ -786,8 +786,7 @@
</div>
<div
class="container form-group pl-3 pr-2 mb-0 pt-1 pb-0 dettaglifiltri"
id="dettagliGrammaticale">
</div>
id="dettagliGrammaticale"></div>
<!-- FINE GRAMMATICALE -->
<!-- TIPO SINTATTICO -->
<div class="col-12 tab-pane px-0" id="tiposintatticoN"
@ -801,7 +800,7 @@
</div>
<select
class="form-control custom-select custom-select-sm monMe bg-light text-muted border btn-outline-success"
name="typeSyntax0" id="synttypes"
name="typeSyntax0" id="synttypes" data-claType="Sintattico"
title="Tipo sintattico" value="oggetto">
<option value=".+" class="w-10"
onclick="myformsyntax.functionSyntax0.disabled = false;">
@ -1424,7 +1423,7 @@
</div>
<select
class="form-control custom-select custom-select-sm monMe bg-light text-muted border btn-outline-success"
name="functionSyntax" id="syntfunc"
name="functionSyntax" id="syntfunc" data-claType="Sintattico"
title="Livello di subordinazione">
<option value=".+">Livello di subordinazione</option>
@ -1471,7 +1470,7 @@
</div>
</div>
</div>
<div class="bg-light well m-0" id="contextDivN"></div>
</div>
<!-- Div grammatica e sintassi -->
@ -1535,7 +1534,7 @@
<span>&nbsp;</span>
</div>
<div
class=" form-group form-inline input-group px-0 pt-1 pb-3 m-0"
class=" form-group form-inline input-group px-0 pt-1 pb-1 m-0"
action="">
<div class="input-group-prepend">
<label class="input-group-text"><ion-icon
@ -1552,21 +1551,34 @@
<option value="filtraStringente">Stilema</option>
<option value="filtraEsplicita">Topografia</option>
<option value="filtraEsplicita">Teoria</option>
</select> <span>&nbsp;</span> <select
class="form-control custom-select custom-select-sm monMe bg-light text-muted border btn-outline-success"
id="filtraRapportoTestoFonte">
<option value="tipo">Rapporto testo/fonte:</option>
<option value="filtraConferma">Conferma</option>
<option value="filtraContraddice">Contraddice</option>
<option value="filtraEstende">Estende</option>
</select>
</div>
</select> <span>&nbsp;</span> <input type="text"
class="form-control form-control-sm monMe"
id="filtraRiferimento" placeholder="Riferimento"
aria-describedby="name-desc" name="query">
</div>
<div
class=" form-group form-inline input-group px-0 pt-1 pb-2 m-0"
action="">
<div class="input-group-prepend">
<label class="input-group-text"><ion-icon
name="document-text"></ion-icon></label>
</div>
<select
class="form-control custom-select custom-select-sm monMe bg-light text-muted border btn-outline-success"
id="filtraRapportoTestoFonte">
<option value="tipo">Rapporto testo/fonte:</option>
<option value="filtraConferma">Conferma</option>
<option value="filtraContraddice">Contraddice</option>
<option value="filtraEstende">Estende</option>
</select>
</div>
</div>
</div>
<div class=" well m-0 pb-2" id="contextDiv0" style="display: none;">
<div class=" well m-0 pb-2" id="contextDiv0"
style="display: none;">
<div id="contextTable-xX0"
class="row no-gutters p-1 pt-0 bg-lida08" >
class="row no-gutters p-1 pt-0 bg-lida08">
<div class="col-12 py-0 pl-1">
<span class=" align-bottom">Restringi il contesto
di ricerca:</span>
@ -1906,7 +1918,7 @@
<div id="collapseLogic" class="collapse show"
style="display: none;" aria-labelledby="headingLogic"
data-parent="#accordionSearch">
<div class="card-body p-0">
<div class="card-body p-0">
<div class="row card tab-content bg-lida10 m-0 p-0"
id="cla-TabContent">
<div class="col-12 pt-2">

View File

@ -314,7 +314,7 @@ $(document).ready(function() {
});
// Evento: modifica di un campo clausole
$("form #lemma_forma,#queryText,#opzioni_testo").on('change', function() {
$("form #lemmaforma_,#queryText,#opzioni_testo").on('change', function() {
if ($(this)[0].id == "queryText") {
var orgSelection = "forma" // $('#lemma_forma option:selected')[0].value
var qText = $(this)[0].value;
@ -328,22 +328,9 @@ $(document).ready(function() {
$('#cla-TabContent').on('change', '.monMe', function() {
// Nik
var fieldId = $(this)[0].id;
var claid = 9999;
if (fieldId.startsWith("query")) {
$("form #queryText").val($("#" + fieldId).val());
claid = fieldId.substring(9);
} else {
if (fieldId.startsWith("lemma")) {
$("form #lemma_forma").val($("#" + fieldId).val());
claid = fieldId.substring(11);
} else {
if (fieldId.startsWith("opzioni")) {
$("form #opzioni_testo").val($("#" + fieldId).val());
claid = fieldId.substring(13);
}
}
}
refreshClaList(claid);
var ids = fieldId.split('_');
var claType = $("#" + fieldId+":parent").attr('data-claType');
refreshClaList(ids[1],claType);
});
// Evento: click sull'icona rimuovi clausola
@ -357,7 +344,7 @@ $(document).ready(function() {
thisIs.remove();
delete queryJson["Clausola" + claIdNum];
delete window["context" + claIdNum];
refreshClaList();
refreshClaList(claIdNum);
refreshSortables();
});
});
@ -381,13 +368,15 @@ $(document).ready(function() {
tabID++;
addGramCla("#sortable0", 1, tabID, 1,1);
$('#collapseLogic').attr('style', "display: d-flex;");
$("#unitaRicerca").prop('disabled',true);
$("#unitaRicerca").prop('disabled',true);
refreshClaList(tabID);
});
$('#btnAddOr').on('click', function() {
tabID++;
addGramCla("#sortable0", 1, tabID, 1,2);
$('#collapseLogic').attr('style', "display: d-flex;");
$("#unitaRicerca").prop('disabled',true);
$("#unitaRicerca").prop('disabled',true);
refreshClaList(tabID);
});
// Evento: clausola spostata nella lista
$('#sortable0').sortable({
@ -445,7 +434,7 @@ $(document).ready(function() {
$('#rigaRicerca').on('click', '.trashClaCont', function() {
var claIdNum = $(this)[0].id.substring(15);
resetContext(claIdNum);
refreshClaList();
refreshClaList(tabID);
});
// Evento: click sull'icona di add del contesto
@ -463,7 +452,7 @@ $(document).ready(function() {
if ($(this).closest('.card').find('span:visible').length == 1) {
$(this).closest('.card').find('div .sel-canti-intro').text("Selezionati tutti i canti.");
};
refreshClaList();
refreshClaList(claIdNum);
});
// Evento: click sull'icona di save local
@ -506,8 +495,10 @@ $(document).ready(function() {
$("#grammtypesN").on('change', function(e) {
var selectedValue = $(this).val();
var tabPaneId = ($(this).closest('.tab-pane').attr("id"));
var id = tabPaneId.replace("tipogrammaticale","cla");
var id = tabPaneId.replace("tipogrammaticale_","cla");
addCatgramSubcla(id, selectedValue);
//id = id.substr(3);
//refreshClaList(id);
});
// Evento: Submit form
$("form").submit(function(e) {
@ -795,7 +786,7 @@ $(document).ready(function() {
var checkInsert = '';
};
var claText = ""; //Categoria grammaticale: <br>";
var claText = ""; // "Categoria grammaticale: <br>";
addLIitem(sortableId, tabID, claText, checkInsert, toExpand, cond);
var claClone = $("#grammaticaEsintassi").clone(true);
claClone.attr("id", "cla" + tabID);
@ -803,13 +794,15 @@ $(document).ready(function() {
claClone.attr("aria-labelledby", "cla" + tabID + "-tab");
claClone.attr("style", "");
$('#claBody' + tabID).append(claClone);
// se non cambio l'id della select react non rileva l'evento onchange:
$('#cla' + tabID + " #grammtypesN").attr("id", "grammtypes" + tabID);
$('#cla' + tabID + " #lemma_formaN").attr("id", "lemma_forma" + tabID);
$('#cla' + tabID + " #queryTextN").attr("id", "queryText" + tabID);
$('#cla' + tabID + " #opzioni_testoN").attr("id", "opzioni_testo" + tabID);
$('#cla' + tabID + " #contextDivN").attr("id", "contextDiv" + tabID);
$('#cla' + tabID + " #tipogrammaticaleN").attr("id","tipogrammaticale" + tabID);
$('#cla' + tabID + " #grammtypesN").attr("id", "grammtypes_" + tabID);
$('#cla' + tabID + " #lemma_formaINIT").attr("id", "lemmaforma_" + tabID);
$('#cla' + tabID + " #queryTextINIT").attr("id", "queryText_" + tabID);
$('#cla' + tabID + " #opzioni_testoINIT").attr("id", "opzionitesto_" + tabID);
$('#cla' + tabID + " #contextDivN").attr("id", "contextDiv_" + tabID);
$('#cla' + tabID + " #tipogrammaticaleN").attr("id","tipogrammaticale_" + tabID);
$('#cla' + tabID + " #tiposintatticoN").attr("id","tiposintattico_" + tabID);
$('#cla' + tabID + " #synttypes").attr("id","synttypes_" + tabID);
$('#cla' + tabID + " #syntfunc").attr("id","syntfunc_" + tabID);
$("#contextDiv0").attr('style', "display: none");
addClaContext(tabID);
@ -935,7 +928,7 @@ $(document).ready(function() {
contClone = contClone.replace(/sel-canto/g, "sel-canto suxess");
$("#contextDiv" + tabID).append($(contClone)[0]);
$("#contextDiv_" + tabID).append($(contClone)[0]);
resetContext(tabID);
$("#selectable-xX" + tabID).selectable({
filter: ".sel-canto",
@ -1004,23 +997,11 @@ $(document).ready(function() {
};
// Funzione di refresh della lista clausole nella tab principale e del json della query
function refreshClaList(editCard = 9999) {
var l_f = $("#lemma_formaINIT").val();
var qText = $("#queryTextINIT").val();
var optText = $("#opzioni_testoINIT").val();
/*var l_f = "";
var qText = "";
var optText = "";
var unitaDiRicerca = $("#unitaRicerca")[0].options[$("#unitaRicerca")[0].selectedIndex].value;
if (unitaDiRicerca == "lemma" || unitaDiRicerca == "forma") {
l_f = unitaDiRicerca;
qText = $("#queryTextUnita")[0].value;
optText = $("#opzioni_testoUnita")[0].value;
} else {
l_f = $("#lemma_formaINIT")[0].options[$("#lemma_formaINIT")[0].selectedIndex].value;
qText = $("#queryTextINIT")[0].value;
optText = $("#opzioni_testoINIT")[0].value;
}*/
function refreshClaList(editCard = 9999, claType) {
var l_f = $("#lemmaforma_"+editCard).val();
var qText = $("#queryText_"+editCard).val();
var optText = $("#opzionitesto_"+editCard).val();
if (qText == "") { //disattivo clausola 0 se il testo e' vuoto
var claActive = 0
@ -1037,7 +1018,7 @@ $(document).ready(function() {
};
$(tabsContent).each(function() {
var claIdNum = $(this).attr('id').substr(6);
updateClaListItem(claIdNum, "#sortable0", editCard);
updateClaListItem(claIdNum, "#sortable0",claType);
});
} else {
if (claListLen == 0 && condListLen == 0) {
@ -1057,93 +1038,72 @@ $(document).ready(function() {
}
// Funzione di creazione del LI nella lista delle clausole nel tab principale, aggiunta della clausola nel JSON
function updateClaListItem(claIdNum, sortableId, editCard) {
function updateClaListItem(claIdNum, sortableId, type) {
var claText = '';
var termText = '';
var checkInsert = '';
var claId = "cla" + claIdNum;
var claListItemId = "li-cla" + claIdNum;
var claType = $("#" + claId).attr('data-claType');
var claType = type;//$("#" + claId).attr('data-claType');
var claActive = $("#" + claId).attr('data-claActive');
var tabsContentLenght = ($("#sortable0").find(".claLI").length);
if (claActive > 0) {
checkInsert = ' checked="checked"';
};
var l_f = "";
var l_f_t = "";
var qText = "";
var optText = "";
var optText_t = "";
var articolo = "Il ";
//Nik verificare in cao di modifica delle clausola
//var unitaDiRicerca = $("#unitaRicerca")[0].options[$("#unitaRicerca")[0].selectedIndex].value;
if (editCard == 9999) {
l_f = $("#lemma_formaINIT").val();
l_f_t = $("#lemma_formaINIT").text();
qText = $("#queryTextINIT").val();
optText = $("#opzioni_testoINIT").val();
optText_t = $("#opzioni_testoINIT").text();
} else {
l_f = $("#lemma_forma" + editCard)[0].options[$("#lemma_forma" + editCard)[0].selectedIndex].value;
l_f_t = $("#lemma_forma" + editCard)[0].options[$("#lemma_forma" + editCard)[0].selectedIndex].text;
qText = $("#queryText" + editCard)[0].value;
optText = $("#opzioni_testo" + editCard)[0].value;
optText_t = $("#opzioni_testo" + editCard)[0].options[$("#opzioni_testo" + editCard)[0].selectedIndex].text;
}
var l_f = $("#lemmaforma_"+claIdNum).val();
var l_f_t = $("#lemmaforma_"+claIdNum+" option:selected").text();
var qText = $("#queryText_"+claIdNum).val();
var optText = $("#opzionitesto_"+claIdNum).val();
var optText_t = $("#opzionitesto_"+claIdNum+" option:selected").text();
if (qText != "") {
termText = l_f_t + ' <span class="text-dark font-weight-bold">' + qText + '</span> ' + optText_t + '.<br>';
termText = l_f_t + ' <span class="text-dark font-weight-bold">' + qText + '</span> ' + optText_t + '.';
};
var jsonTextToParse = '{"queryText": "' + qText + '", "lemma_forma": "' + l_f + '", "opzioni_testo": "' + optText + '", "TipoClausola": "' + claType + '", "Attiva": "' + claActive + '"';
switch (claType) {
case "Grammaticale":
var gramSelect = $("#" + claId).find(".catgram");
var contextText = $("#contextText-xX" + claIdNum).text();
claText = termText + "Categoria grammaticale: " + gramSelect[0].options[gramSelect[0].selectedIndex].text;
jsonTextToParse = jsonTextToParse + ', "' + gramSelect.attr('name') + '": "' + gramSelect[0].options[gramSelect[0].selectedIndex].value + '"';
var claSubParList = $("#" + claId).children(".dettaglifiltri").find("select, fieldset");
claSubParList.each(function() {
var claSubParType = $(this)[0].type;
if (claSubParType == "fieldset" && $(this).find(":checked").length) {
var claSubParName = $(this).find(":checked")[0].name;
if (claSubParName.startsWith(claId)) {
claSubParName = claSubParName.replace(claId, '');
}
claText = claText + "; " + $(this).find(":checked")[0].defaultValue;
jsonTextToParse = jsonTextToParse + ', "' + claSubParName + '": "' + $(this).find(":checked")[0].value + '"';
};
if (claSubParType == "select-one" && $(this)[0].selectedIndex != 0) {
claText = claText + "; " + $(this)[0].options[$(this)[0].selectedIndex].text;
jsonTextToParse = jsonTextToParse + ', "' + $(this)[0].name + '": "' + $(this)[0].options[$(this)[0].selectedIndex].value + '"';
};
});
claText = claText + '.<br>Contesto: ' + contextText;
break;
case "Sintattico":
var syntSelect = $("#" + claId).find("#synttypes");
var funcSelect = $("#" + claId).find("#syntfunc");
var contextText = $("#contextText-xX" + claIdNum).text();
claText = termText + "Tipo sintattico: " + syntSelect[0].options[syntSelect[0].selectedIndex].text + ';<br>Livello di subordinazione: ' + funcSelect[0].options[funcSelect[0].selectedIndex].text + '.<br>Contesto: ' + contextText;
jsonTextToParse = jsonTextToParse + ', "' + syntSelect.attr('name') + '": "' + syntSelect[0].options[syntSelect[0].selectedIndex].value + '", "' + funcSelect.attr('name') + '": "' + funcSelect[0].options[funcSelect[0].selectedIndex].value + '"';
break;
default:
claText = $("#" + claListItemId + " .clatext").text();
checkInsert = ' disabled';
var jsonTextToParse = '{"queryText": "", "lemma_forma": "", "opzioni_testo": "", "TipoClausola": "' + claType + '", "Attiva": "' + claActive + '"';
};
// nik controllare in quale caso si verifica "else"
if ($("#" + claListItemId)[0]) {
if (claListItemId == "li-cla" + tabsContentLenght && editCard == 9999) {
$("#" + claListItemId + " .clatext").replaceWith('<span class="small clatext">' + claText + '</span>');
} else {
$("#" + "li-cla" + editCard + " .clatext").replaceWith('<span class="small clatext">' + claText + '</span>');
var gramSelect = $("#" + claId).find(".catgram");
var contextText = $("#contextText-xX" + claIdNum).text();
if (gramSelect[0].selectedIndex > 0){
if(termText !=""){
termText += "<br>";
}
claText = termText + "Categoria grammaticale: " + gramSelect[0].options[gramSelect[0].selectedIndex].text;
}else{
claText = termText;
}
jsonTextToParse = jsonTextToParse + ', "' + gramSelect.attr('name') + '": "' + gramSelect[0].options[gramSelect[0].selectedIndex].value + '"';
var claSubParList = $("#" + claId).children(".dettaglifiltri").find("select, fieldset");
claSubParList.each(function() {
var claSubParType = $(this)[0].type;
if (claSubParType == "fieldset" && $(this).find(":checked").length) {
var claSubParName = $(this).find(":checked")[0].name;
if (claSubParName.startsWith(claId)) {
claSubParName = claSubParName.replace(claId, '');
}
claText = claText + "; " + $(this).find(":checked")[0].defaultValue;
jsonTextToParse = jsonTextToParse + ', "' + claSubParName + '": "' + $(this).find(":checked")[0].value + '"';
};
if (claSubParType == "select-one" && $(this)[0].selectedIndex != 0) {
claText = claText + "; " + $(this)[0].options[$(this)[0].selectedIndex].text;
jsonTextToParse = jsonTextToParse + ', "' + $(this)[0].name + '": "' + $(this)[0].options[$(this)[0].selectedIndex].value + '"';
};
});
var syntSelect = $("#synttypes_"+claIdNum).find(":selected").text();
var funcSelect = $("#syntfunc_"+claIdNum).find(":selected").text();
if(!syntSelect.startsWith("\n\t")){
claText = claText+"<br>Tipo sintattico: " + syntSelect;
} else {
if (!funcSelect.startsWith("Livello di subordinazione")) {
claText = claText + "<br>Qualsiasi tipo sintattico: ";
}
}
if(!funcSelect.startsWith("Livello di subordinazione")){
claText = claText+"<br>Livello di subordinazione: " + funcSelect;
}
claText = claText + '.<br>Contesto: ' + contextText;
if ($("#" + claListItemId)[0]) {
$("#" + claListItemId + " .clatext").replaceWith('<span class="small clatext">' + claText + '</span>');
} else {
addLIitem(sortableId, claIdNum, claText, checkInsert, 0);
};
@ -1354,8 +1314,8 @@ $(document).ready(function() {
};
// Rigenerazione Clausola0:
if (queryJson["Clausola0"].Attiva) {
$("#queryText").val(queryJson["Clausola0"].queryText);
$("#opzioni_testo").val(queryJson["Clausola0"].opzioni_testo);
$("#queryText_").val(queryJson["Clausola0"].queryText);
$("#opzionitesto_").val(queryJson["Clausola0"].opzioni_testo);
var qText = queryJson["Clausola0"].queryText;
if (qText !== null && qText !== '') { qText = ' "' + qText + '"'; }
setLemmaForma(qText, queryJson["Clausola0"].lemma_forma);
@ -1411,13 +1371,13 @@ $(document).ready(function() {
$("#lemma_formaINIT").val(queryJson["Clausola" + itm].lemma_forma);
$("#queryTexINIT").val(queryJson["Clausola" + itm].queryText);
$("#opzioni_testoINIT").val(queryJson["Clausola" + itm].opzioni_testo);
$("#lemma_forma" + tabID).val(queryJson["Clausola" + itm].lemma_forma);
$("#queryText" + tabID).val(queryJson["Clausola" + itm].queryText);
$("#opzioni_testo" + tabID).val(queryJson["Clausola" + itm].opzioni_testo);
$("#lemmaforma_" + tabID).val(queryJson["Clausola" + itm].lemma_forma);
$("#queryText_" + tabID).val(queryJson["Clausola" + itm].queryText);
$("#opzionitesto_" + tabID).val(queryJson["Clausola" + itm].opzioni_testo);
if (selectedValue != "all") {
$("#grammtypes" + tabID).val(selectedValue);
$("#grammtypes_" + tabID).val(selectedValue);
addCatgramSubcla("cla" + tabID, selectedValue);
var ks = Object.keys(queryJson["Clausola" + itm]);
for (var j = 6; j < ks.length - 1; j++) {
@ -1438,50 +1398,28 @@ $(document).ready(function() {
window["context" + tabID] = JSON.parse(queryJson["Clausola" + itm].contesto);
parseContext(tabID);
break;
case "Sintattico":
addSyntCla($(this)[1], active, tabID, 0);
$("#lemma_formaINIT").val(queryJson["Clausola" + itm].lemma_forma);
$("#queryTextINIT").val(queryJson["Clausola" + itm].queryText);
$("#opzioni_testoINIT").val(queryJson["Clausola" + itm].opzioni_testo);
$("#lemma_forma" + tabID).val(queryJson["Clausola" + itm].lemma_forma);
$("#queryText" + tabID).val(queryJson["Clausola" + itm].queryText);
$("#opzioni_testo" + tabID).val(queryJson["Clausola" + itm].opzioni_testo);
if (queryJson["Clausola" + itm].typeSyntax0 != ".+") {
$("#cla" + tabID + " #synttypes").val(queryJson["Clausola" + itm].typeSyntax0);
}
if (queryJson["Clausola" + itm].functionSyntax != ".+") {
$("#cla" + tabID + " #syntfunc").val(queryJson["Clausola" + itm].functionSyntax);
}
window["context" + tabID] = JSON.parse(queryJson["Clausola" + itm].contesto);
parseContext(tabID);
break;
case "Metafora":
addMetaCla($(this)[1], active, tabID, 0);
break;
default:
};
};
});
refreshClaList();
refreshClaList(tabID);
refreshSortables();
};
function resetSimpleGui() {
$('#queryText').val("");
$('#queryText_').val("");
setLemmaForma("", "forma");
$('#opzioni_testo').val("parola");
$('#opzionitesto_').val("parola");
resetContext(0);
};
function setLemmaForma(qText, newSelection) {
var newOptions = { ['La forma' + qText]: 'forma', ['Il lemma' + qText]: 'lemma', ['Il testo' + qText]: 'testo' };
$("#lemma_forma").empty();
$("#lemmaforma_").empty();
$.each(newOptions, function(key, value) {
$("#lemma_forma").append($("<option></option>").attr("value", value).text(key));
$("#lemmaforma_").append($("<option></option>").attr("value", value).text(key));
});
$("#lemma_forma").val(newSelection);
$("#lemmaforma_").val(newSelection);
};
function resetContext(claIdNum) {