editing filter modificato

This commit is contained in:
nicola 2022-06-20 18:35:38 +02:00
parent 7e6f66c72a
commit 0b318a2ca1
1 changed files with 23 additions and 31 deletions

View File

@ -448,9 +448,10 @@ $(document).ready(function() {
else
filterconditions = filterconditions + 1;
element.attr('id', 'filtro-' + filterconditions);
element.find('.delete-written-filter').attr('target', 'filtro-' + filterconditions);
element.find('.edit-written-filter').attr('target', 'filtro-' + filterconditions);
let filtroId = 'filtro-' + filterconditions;
element.attr('id', filtroId);
element.find('.delete-written-filter').attr('target', filtroId);
element.find('.edit-written-filter').attr('target', filtroId);
//trasformo il filtro espresso nella clausola in un oggetto JSON
@ -474,17 +475,13 @@ $(document).ready(function() {
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]]);
tuttiFiltri = tuttiFiltri + filtro[[keys[key]]] + ", ";
/*ddclass.append(filtro[[keys[key]]]);
dlclass.append(dtclass);
dlclass.append(ddclass);
element.find('.listacondizioni').append(dlclass);*/
}
//element.find('.listacondizioni').append(dlclass);
let virgola = tuttiFiltri.lastIndexOf(',');
tuttiFiltri = tuttiFiltri.substring(0, virgola);
let txtAreaFiltri = '<textarea readonly style="resize:none" class="bg-washed-blue bn" rows="2" cols="20" name="usrtxt" wrap="hard">' +
let txtAreaFiltri = '<textarea id = ' + 'textarea-'+filterconditions+
' readonly style="resize:none" class="bg-washed-blue bn" rows="2" cols="20" name="usrtxt" wrap="hard">' +
tuttiFiltri + "</textarea>"
ddclass.append(txtAreaFiltri);
dlclass.append(dtclass);
@ -535,10 +532,8 @@ $(document).ready(function() {
}
)
function AggiornaFiltro(filtroId) {
//e.preventDefault();
var content = jQuery('#filtro'),
size = jQuery('#filtri >div').length + 1,
element = null,
element = content.clone();
@ -550,7 +545,6 @@ $(document).ready(function() {
//trasformo il filtro espresso nella clausola in un oggetto JSON
var condizioni = $("#filterform").serialize().split('&');
//alert (condizioni)
filtro = {}
@ -564,33 +558,31 @@ $(document).ready(function() {
//mostro il filtro nella GUI
let tuttiFiltri = "";
var keys = Object.keys(filtro)//condizioniFiltro)
var keys = Object.keys(filtro);
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"/>');
tuttiFiltri = tuttiFiltri + filtro[[keys[key]]] + ", ";
}
let virgola = tuttiFiltri.lastIndexOf(',');
tuttiFiltri = tuttiFiltri.substring(0, virgola);
let txtAreaFiltri = '<textarea readonly style="resize:none" class="bg-washed-blue bn" rows="2" cols="20" name="usrtxt" wrap="hard">' +
tuttiFiltri + "</textarea>"
ddclass.append(txtAreaFiltri);
dlclass.append(dtclass);
dlclass.append(ddclass);
element.find('.listacondizioni').append(dlclass);
element.attr('style', 'display.block');
element.appendTo('#filtri');
if (size > 1) {
element.find('.andorconditions').attr('style', 'display.block');
let filterNum = filtroId.substring(7);
$('#textarea-'+ filterNum).val(tuttiFiltri);
if (filterNum != 1) {
element.find('.andorconditions').attr('style', 'display.none');
}
//$('a.remove-filter').trigger('click');
var targetDiv = jQuery(this).attr('targetfilter');
rmel = jQuery('#' + targetDiv)
rmeldetail = jQuery('#' + 'dettaglio_' + targetDiv)
// rimuovo la finestra filtro
rmel = jQuery('#' + "cg-2")
rmeldetail = jQuery('#' + 'dettaglio_' + "cg-2")
jQuery(rmel).remove();
jQuery(rmeldetail).remove();
clausolaVisibile = false;