From e69a5b3d7fdedc3836c5853d1303dc44b925623e Mon Sep 17 00:00:00 2001 From: loviuz Date: Thu, 9 Mar 2023 19:40:50 +0100 Subject: [PATCH] Ottimizzazione dimensione widget --- assets/src/js/functions/hooks.js | 48 ++++++++++++----------- modules/stato_servizi/elenco-widget.php | 2 +- src/HTMLBuilder/Manager/WidgetManager.php | 14 ++----- update/2_4_42.sql | 5 ++- 4 files changed, 33 insertions(+), 36 deletions(-) diff --git a/assets/src/js/functions/hooks.js b/assets/src/js/functions/hooks.js index df3fa0902..1198c5bd5 100755 --- a/assets/src/js/functions/hooks.js +++ b/assets/src/js/functions/hooks.js @@ -56,33 +56,35 @@ function startHooks() { * @param hook */ function startHook(hook, init) { - $.ajax({ - url: globals.rootdir + "/ajax.php", - type: "get", - data: { - op: "hook-lock", - id: hook.id, - }, - success: function (data) { - var token = JSON.parse(data); + if (document.hasFocus()) { + $.ajax({ + url: globals.rootdir + "/ajax.php", + type: "get", + data: { + op: "hook-lock", + id: hook.id, + }, + success: function (data) { + var token = JSON.parse(data); - if (init) { - hookCount("#hooks-counter"); + if (init) { + hookCount("#hooks-counter"); - updateHook(hook); - } + updateHook(hook); + } - if (token) { - executeHook(hook, token); - } else { - var timeout = 10; + if (token) { + executeHook(hook, token); + } else { + var timeout = 10; - setTimeout(function () { - startHook(hook); - }, timeout * 1000); - } - }, - }); + setTimeout(function () { + startHook(hook); + }, timeout * 1000); + } + }, + }); + } } /** diff --git a/modules/stato_servizi/elenco-widget.php b/modules/stato_servizi/elenco-widget.php index 68aa7b1c3..efa1f91fa 100644 --- a/modules/stato_servizi/elenco-widget.php +++ b/modules/stato_servizi/elenco-widget.php @@ -58,7 +58,7 @@ foreach ($gruppi as $modulo => $widgets) { ' : '').' - {[ "type": "select", "name": "dimensione[]", "class": "widgets", "value": "'.$widget['class'].'", "values": "list=\"0\": \"'.tr('Da impostazioni').'\", \"3\": \"'.tr('Piccolo').'\", \"4\": \"'.tr('Medio').'\", \"6\": \"'.tr('Grande').'\", \"12\": \"'.tr('Molto grande').'\"", "extra": "data-id=\"'.$widget['id'].'\"" ]} + {[ "type": "select", "name": "dimensione[]", "class": "widgets", "value": "'.$widget['class'].'", "values": "list=\"0\": \"'.tr('Da impostazioni').'\", \"col-md-3\": \"'.tr('Piccolo').'\", \"col-md-4\": \"'.tr('Medio').'\", \"col-md-6\": \"'.tr('Grande').'\", \"col-md-12\": \"'.tr('Molto grande').'\"", "extra": "data-id=\"'.$widget['id'].'\"" ]} '.( string_starts_with($widget['location'], 'controller') ? diff --git a/src/HTMLBuilder/Manager/WidgetManager.php b/src/HTMLBuilder/Manager/WidgetManager.php index 643d3ce01..5ce60966a 100755 --- a/src/HTMLBuilder/Manager/WidgetManager.php +++ b/src/HTMLBuilder/Manager/WidgetManager.php @@ -245,25 +245,17 @@ class WidgetManager implements ManagerInterface // Generazione del codice HTML if (!empty($widgets)) { - foreach ($widgets as $widget) { - $row_max = empty($widget['class'])? setting('Numero massimo Widget per riga') : $widget['class']; - } - - $result = '
    '; // Aggiungo ad uno ad uno tutti i widget foreach ($widgets as $widget) { - if ($widgets[0]['id_module'] == $database->fetchOne('SELECT id FROM zz_modules WHERE title = "Stato dei servizi"')['id']) { + if ($widget['id_module'] == $database->fetchOne('SELECT id FROM zz_modules WHERE title = "Stato dei servizi"')['id']) { $result .= ' -
  • '; - } else if (empty($widget['class'])) { - $result .= ' -
  • '; +
  • '; } else { $result .= ' -
  • '; +
  • '; } $info = array_merge($options, [ 'id' => $widget['id'], diff --git a/update/2_4_42.sql b/update/2_4_42.sql index 13fb8260e..fb33f263a 100644 --- a/update/2_4_42.sql +++ b/update/2_4_42.sql @@ -19,4 +19,7 @@ HAVING 2=2 ORDER BY `data` DESC, - CAST(`numero_esterno` AS UNSIGNED) DESC" WHERE `name` = 'Ordini fornitore'; \ No newline at end of file + CAST(`numero_esterno` AS UNSIGNED) DESC" WHERE `name` = 'Ordini fornitore'; + +-- Correzione dimensione widget +UPDATE `zz_settings` SET `valore` = 'col-md-6', `tipo` = 'list[col-md-1,col-md-2,col-md-3,col-md-4,col-md-6]', `nome` = 'Dimensione widget predefinita' WHERE `nome` = 'Numero massimo Widget per riga'; \ No newline at end of file