aggiungi/rimuovi clausole

This commit is contained in:
cesare 2022-02-07 16:50:59 +01:00
parent 786de6a1bb
commit 5bc69839c0
2 changed files with 140 additions and 61 deletions

View File

@ -40,7 +40,7 @@
<div class="mw9 center ph3-ns">
<div class="cf ph2-ns">
<div class="fl w-100 w-20-ns pa4">
Filtri
Clausole
<div class=" bg-washed-blue pv2">
<!--
@ -193,7 +193,10 @@
<!-- CATEGORIA GRAMMATICALE -->
<div style="display: none;" id='categoriagrammaticale'>
<div class="outline w-25 pv4 ph1">
<div class="outline w-25">
<div class="flex flex-column">
<div class="outline w-100 pa4 mr2">
<select id="types"
class="w-100 db h2 f6 bg-near-white ba b--sliver gray catgram"
name="categoria" onchange="" title="Macro categoria">
@ -217,15 +220,29 @@
<option value="aggettivo_latino_a">Aggettivo latino</option>
<option value="pronome_latino_p">Pronome latino</option>
<option value="avverbio_latino_r">Avverbio latino</option>
<option value="preposizione_latino_e">Preposizione latino</option>
<option value="congiunzione_latino_c">Congiunzione latino</option>
<option value="interiezione_latino_i">Interiezione latino</option>
<option value="preposizione_latino_e">Preposizione
latino</option>
<option value="congiunzione_latino_c">Congiunzione
latino</option>
<option value="interiezione_latino_i">Interiezione
latino</option>
<option value="enclitica_latino_9">Enclitica latino</option>
<option value="citazione_latino_zi">Citazione latino</option>
<option value="simbolo_latino_yy">Simbolo latino</option>
</optgroup>
</select>
</div>
<div class="outline w-100 pa1 mr2">
<a class="f6 link dim br1 ba ph1 mb2 dib dark-green w-40 remove-filter"
href="#0" value="rimuovi" data-added="0">Rimuovi</a>
<a class="f6 link dim br1 ba ph1 mb2 dib dark-green w-40 add-details"
href="#0" value="dettagli" data-added="0" style="display:none" >Filtri categoria</a>
</div>
</div>
</div>
@ -799,6 +816,7 @@
<div style="display: none;" id='categoriasostantivo'>
<div class=" w-15 pa1 mr2">
<fieldset id="numero" class="bn">

View File

@ -119,13 +119,7 @@ $(document).ready(function() {
"citazionevolgare": "filtricitazione"
}
/*$.getJSON("aggettivo.json", function(aggettivo){
//var keys = Object.values(aggettivo.filtri["Con oggetto indiretto"]);
//alert(keys);
aggettivoJson=aggettivo
}).fail(function(){
console.log("An error has occurred.");
});*/
var catGrammsenzaspec=['all', 'interiezionevolgare']
var categorieJson = $.extend({}, pronomeJson, aggettivoJson, articoloJson, avverbioJson, preposizioneJson, congiunzioneJson, onomasticacitazioneJson);
@ -136,14 +130,13 @@ $(document).ready(function() {
jQuery(document).delegate('a.add-record', 'click', function(e) {
e.preventDefault();
var content = jQuery('#categoriagrammaticale div'),
var content = jQuery('#categoriagrammaticale >div'),
size = jQuery('#condizioni >div').length + 1,
element = null,
element = content.clone();
//alert(size);
element.attr('id', 'cg-' + size);
//element.attr('class', "stripe-dark")
//element.find('.delete-record').attr('data-id', size);
element.find('.remove-filter').attr('target','cg-'+size);
element.appendTo('#condizioni');
element.find('.sn').html(size);
grammarconditions = grammarconditions + 1
@ -159,8 +152,8 @@ $(document).ready(function() {
element = null,
element = content.clone();
element.attr('id', 'ts-' + size);
//element.attr('class', "stripe-dark")
//element.find('.delete-record').attr('data-id', size);
element.find('.remove-filter').attr('target','ts-'+size);
element.appendTo('#condizioni');
element.find('.sn').html(size);
if (size == 1)
@ -170,13 +163,21 @@ $(document).ready(function() {
jQuery(document).delegate('select.catgram', 'change', function(e) {
e.preventDefault();
//alert ($('#types').find(":selected").val())
alert($(this).closest('div').attr('id'))
containerid = 'dettaglio_' + $(this).closest('div').attr('id')
//alert(($(this).closest('div')).closest('div').attr('id'))
var pare=$(this).parents()[2];
var sbs=($(this).closest('div')).siblings()
sbs.find(".add-details").attr('style', 'display:block')
alert(pare.id)
containerid = 'dettaglio_' + pare.id;//$(this).closest('div').attr('id')
sbs.find(".add-details").attr('target', containerid)
//if ($('#types').find(":selected").val()=='verbovolgare'){
if ($(this).val() == 'verbovolgare') {
//alert($('#types').find(":selected").val());
var content = jQuery('#categoriaverbo >div'),
size = jQuery('#dettaglifiltri').length + 1,
element = null,
@ -191,10 +192,10 @@ $(document).ready(function() {
element = content.clone();
}
//alert($(this).val())
if (Object.keys(categorie).includes($(this).val())) {
//alert(categorie[$(this).val()])
var filtro = categorie[$(this).val()]
//var keys = Object.keys(aggettivoJson.filtri);
var keys = Object.keys(categorieJson[filtro])
@ -240,7 +241,7 @@ $(document).ready(function() {
flexdiv1.appendTo(rbfieldset);
flexdiv2.appendTo(rbfieldset);
rbfieldset.appendTo(element);
element.attr('style', 'display:block')
element.attr('style', 'display:none')
element.appendTo('#dettaglifiltri');
}
}
@ -269,7 +270,7 @@ $(document).ready(function() {
label1.appendTo(flexdiv1);
flexdiv1.appendTo(rbfieldset);
rbfieldset.appendTo(element);
element.attr('style', 'display:block')
element.attr('style', 'display:none')
element.appendTo('#dettaglifiltri');
}
}
@ -290,9 +291,11 @@ $(document).ready(function() {
seloption.appendTo(select)
}
select.appendTo(element)
element.attr('style', 'display:block')
element.attr('style', 'display:none')
element.appendTo('#dettaglifiltri');
}
}
@ -300,18 +303,34 @@ $(document).ready(function() {
if (element === undefined) {
var test = jQuery('#' + containerid)
sbs.find(".add-details").attr('style', 'display:none')
test.remove()
}
else
{
element.attr('style', "display: block;")
element.attr('style', "display: none;")
//element.appendTo('#dettaglifiltri');
var test = jQuery('#' + containerid)
/*if (test.val() !== undefined){
//alert (test)
var flexdivreplace = $('<div />');
flexdivreplace.attr('class', 'flex flex-wrap')
flexdivreplace.attr('id', containerid)
element.appendTo(flexdivreplace)
test.replaceWith(flexdivreplace)
}
else{*/
test.remove()
//<legend class="pa0 f5 f4-ns mb3 black-80">Sostantivo</legend>
//var legend=$('<legend class="pa0 f5 f4-ns mb3 black-80">'+$(this).val()+'</legend>');
//var fset=$('<fieldset class="cf bn ma0 pa0">')
element.appendTo('#dettaglifiltri');
var container = jQuery('#dettaglifiltri');
container.attr('id', containerid);
var divdf = jQuery('#divdettaglifiltri >div'),
@ -319,6 +338,8 @@ $(document).ready(function() {
detelement = divdf.clone();
detelement.attr('id', 'dettaglifiltri')
detelement.appendTo("#query")
//}
element.find('.sn').html(size);
}
@ -328,7 +349,7 @@ $(document).ready(function() {
jQuery(document).delegate('input.delete-record', 'click', function(e) {
e.preventDefault();
var didConfirm = confirm("Sei sicuro di voler eliminare la condizione?");
var didConfirm = confirm("Sei sicuro di voler eliminare la clausola?");
if (didConfirm == true) {
var id = jQuery(this).attr('data-id');
var targetDiv = jQuery(this).attr('targetDiv');
@ -346,4 +367,44 @@ $(document).ready(function() {
return false;
}
});
jQuery(document).delegate('a.remove-filter', 'click', function(e) {
e.preventDefault();
var didConfirm = confirm("Sei sicuro di voler eliminare la clausola?");
if (didConfirm == true) {
var targetDiv = jQuery(this).attr('target');
rmel=jQuery('#'+targetDiv)
rmeldetail=jQuery('#'+'dettaglio_' + targetDiv)
jQuery(rmel).remove();
jQuery(rmeldetail).remove();
return true;
} else {
return false;
}
});
jQuery(document).delegate('a.add-details', 'click', function(e) {
e.preventDefault();
var targetDiv = jQuery(this).attr('target');
rmel=jQuery('#'+targetDiv)
var curstyle=rmel.attr('view')
if(curstyle!==undefined && curstyle==='y'){
rmel.children().attr('style','display:none');
rmel.attr('view','n')
}
else{
rmel.attr('view','y')
rmel.children().attr('style','display:block');
}
return true;
});
});