managing filter, in progress

This commit is contained in:
cesare 2022-04-26 12:36:37 +02:00
parent 28e6086d9e
commit 1ba6ed56de
2 changed files with 50 additions and 23 deletions

View File

@ -219,7 +219,7 @@
<!-- TEMPLATE FILTRO --> <!-- TEMPLATE FILTRO -->
<div class="flex items-center justify-center pa1 bg-lightest-blue navy" <div class="flex items-center justify-center pa1 bg-lightest-blue navy"
style="display: none;" id="filtrogrammaticale"> style="display: none;" id="filtro">
<div class="flex flex-column"> <div class="flex flex-column">
<nav class="pa1 pa1-ns"> <nav class="pa1 pa1-ns">
@ -234,19 +234,7 @@
</select> </select>
</nav> </nav>
<div class="pa1 pa1-ns listacondizioni"> <div class="pa1 pa1-ns listacondizioni">
<h4 class="f6 fw6">Clausola grammaticale</h4> <!--<h4 class="f6 fw6">Clausola</h4> -->
<dl class="f6 lh-title mv2">
<dt class="dib b">categoria:</dt>
<dd class="dib ml0 gray">cat</dd>
</dl>
<dl class="f6 lh-title mv2">
<dt class="dib b">filtro1:</dt>
<dd class="dib ml0 gray">val1</dd>
</dl>
<dl class="f6 lh-title mv2">
<dt class="dib b">filtro2:</dt>
<dd class="dib ml0 gray">val2</dd>
</dl>
</div> </div>
</div> </div>

View File

@ -137,7 +137,8 @@ $(document).ready(function() {
var categorieJson = $.extend({}, pronomeJson, aggettivoJson, articoloJson, avverbioJson, preposizioneJson, congiunzioneJson, onomasticacitazioneJson); var categorieJson = $.extend({}, pronomeJson, aggettivoJson, articoloJson, avverbioJson, preposizioneJson, congiunzioneJson, onomasticacitazioneJson);
var categoriaGrammaticaleFiltro='none'
var condizioniFiltro={}
$('.tabs__menu-item').on('click', function() { $('.tabs__menu-item').on('click', function() {
$(this).addClass('bg-white').addClass('red'); $(this).addClass('bg-white').addClass('red');
@ -188,8 +189,26 @@ $(document).ready(function() {
e.preventDefault(); e.preventDefault();
//alert(($(this).closest('div')).closest('div').attr('id')) //alert(($(this).closest('div')).closest('div').attr('id'))
var pare=$(this).parents()[2]; //var pare=$(this).parents()[2];
var sbs=($(this).closest('div')).siblings() var sbs=($(this).closest('div')).siblings()
condizioniFiltro["Tipo Sintattico"]=$(this).val();
sbs.find(".set-filter").attr('style', 'display.block')
})
/** SCELTA FUNZIONE SINTATTICA
*/
jQuery(document).delegate('select.syntfun', 'change', function(e) {
e.preventDefault();
//alert(($(this).closest('div')).closest('div').attr('id'))
//var pare=$(this).parents()[2];
var sbs=($(this).closest('div')).siblings()
condizioniFiltro["Funzione Sintattica"]=$(this).val();
sbs.find(".set-filter").attr('style', 'display.block') sbs.find(".set-filter").attr('style', 'display.block')
}) })
@ -216,7 +235,8 @@ $(document).ready(function() {
sbs.find(".add-details").attr('target', containerid) sbs.find(".add-details").attr('target', containerid)
sbs.find(".set-filter").attr('target', containerid) sbs.find(".set-filter").attr('target', containerid)
//if ($('#types').find(":selected").val()=='verbovolgare'){ //if ($('#types').find(":selected").val()=='verbovolgare'){
categoriaGrammaticaleFiltro=$(this).val();
condizioniFiltro["Categoria Grammaticale"]=$(this).val();
if ($(this).val() == 'verbovolgare') { if ($(this).val() == 'verbovolgare') {
var content = jQuery('#categoriaverbo >div'), var content = jQuery('#categoriaverbo >div'),
@ -427,8 +447,11 @@ $(document).ready(function() {
return false; return false;
} }
}); });
/** /**
Il Filtro viene trascritto
Il Filtro viene scritto
*/ */
@ -436,15 +459,29 @@ $(document).ready(function() {
jQuery(document).delegate('a.set-filter', 'click', function(e) { jQuery(document).delegate('a.set-filter', 'click', function(e) {
e.preventDefault(); e.preventDefault();
var didConfirm = confirm("Sei sicuro di voler definire il filtro '"+categoriaGrammaticaleFiltro+"'?"); var didConfirm = confirm("Sei sicuro di voler definire il filtro?");
if (didConfirm == true) { if (didConfirm == true) {
var content = jQuery('#filtrogrammaticale'), var content = jQuery('#filtro'),
size = jQuery('#filtri >div').length + 1, size = jQuery('#filtri >div').length + 1,
element = null, element = null,
element = content.clone(); element = content.clone();
element.attr('id', 'filtro-' + size); element.attr('id', 'filtro-' + size);
element.find('.delete-written-filter').attr('target','filtro-'+size); element.find('.delete-written-filter').attr('target','filtro-'+size);
var keys = Object.keys(condizioniFiltro)
for (key in keys) {
var dlclass = $('<dl class="f6 lh-title mv2" />'),
dtclass = $('<dt class="dib b mainflabel" />'),
ddclass = $('<dd class="dib ml0 gray mainfvalue"/>');
dtclass.append([keys[key]]);
ddclass.append(condizioniFiltro[[keys[key]]]);
dlclass.append(dtclass);
dlclass.append(ddclass);
element.find('.listacondizioni').append(dlclass);
}
//element.find('.listacondizioni').append(dlclass);
element.attr('style','display.block'); element.attr('style','display.block');
element.appendTo('#filtri'); element.appendTo('#filtri');
if (size>1){ if (size>1){
@ -459,6 +496,8 @@ $(document).ready(function() {
jQuery(rmel).remove(); jQuery(rmel).remove();
jQuery(rmeldetail).remove(); jQuery(rmeldetail).remove();
condizioniFiltro={}
return true; return true;
} else { } else {
return false; return false;