From 606b8aabeab7eab59e92b6dc4afa248bde751927 Mon Sep 17 00:00:00 2001 From: Luca Trupiano Date: Mon, 9 Jan 2023 16:58:22 +0100 Subject: [PATCH] mostra condizione di default AND solo quando necessario --- index_3.2.html | 13 ++++++------- js/script_3.2.js | 13 ++++++++++++- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/index_3.2.html b/index_3.2.html index be4df2e..6d9c4b0 100644 --- a/index_3.2.html +++ b/index_3.2.html @@ -1073,14 +1073,13 @@
-
-
AND
+
-
    -
  • Nessuna - clausola aggiunta.
  • -
+
    +
  • Nessuna + clausola aggiunta.
  • +
diff --git a/js/script_3.2.js b/js/script_3.2.js index cfb6ad6..1e3393c 100644 --- a/js/script_3.2.js +++ b/js/script_3.2.js @@ -85,6 +85,7 @@ $(document).ready(function() { }; }) + // Evento: click sulsullo switch di ricerca avanzata $('#searchToggle').on('change', function() { if ($(this).prop('checked')) { queryJson.QueryAvanzata = "1"; @@ -150,6 +151,7 @@ $(document).ready(function() { $('#sortable0').on('click', '.removeCond', function() { $(this).closest('ul').parent().remove(); condListLen--; + refreshClaList(); refreshSortables(); refreshConnectWith(); if (claListLen == 0 && condListLen == 0) { @@ -190,6 +192,7 @@ $(document).ready(function() { opacity: 0.6, cursor: 'move', update: function() { + refreshClaList(); refreshSortables(); } }); @@ -494,7 +497,8 @@ $(document).ready(function() { // Variabili testuali per compattezza var iconReset = '
'; var iconCloseCond = '
'; - var emptyClaList = '
  • Nessuna clausola aggiunta.
  • '; + var emptyClaList = '
  • Nessuna clausola aggiunta.
  • '; + var defaultCond = '
    AND
    '; var condLIplaceholderText1 = 'Trascina qui almeno 1 clausola o condizione'; var condLIplaceholderText2 = 'Trascina qui almeno 2 clausole o condizioni'; @@ -815,6 +819,13 @@ $(document).ready(function() { }; queryJson.Clausola0 = JSON.parse('{"queryText": "' + qText + '", "lemma_forma": "' + l_f + '", "opzioni_testo": "' + optText + '", "TipoClausola": "0", "Attiva": "' + claActive + '"}'); var tabsContent = $("#sortable0").find(".claLI"); + if ($('#sortable0').children("li").length <= 1) { + $("#cla-defaultCond").remove(); + } else { + if ($('#cla-defaultCond').length == 0) { + $("#cla-list-row").prepend($(defaultCond)); + } + }; if ($(tabsContent).length) { if ($("#li-cla0")[0]) { $("#li-cla0")[0].remove();