From 83a33d8b2b01c7a114f64a422460b6b4954738cb Mon Sep 17 00:00:00 2001 From: tofulm Date: Fri, 10 Jan 2025 15:28:27 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20*=20app=5Fdeux=20devient=20app2=20pour?= =?UTF-8?q?=20simplifier=20son=20appel.=20j'ai=20essay=C3=A9=20de=20garder?= =?UTF-8?q?=20=20=20la=20compat,=20tres=20rarement=20utilis=C3=A9,=20donc?= =?UTF-8?q?=20j'ai=20prix=20le=20risque=20*=20refactorisation=20des=20fonc?= =?UTF-8?q?tions=20php=20gamutable=5Ffermer=5Fmodalbox=20=3D>=20plus=20KIS?= =?UTF-8?q?S=20*=20ces=20fonctions=20peuvent=20etre=20appeler=20avec=20un?= =?UTF-8?q?=20id=20<=200,=20dans=20ce=20cas=20on=20=20=20supprimera=20la?= =?UTF-8?q?=20ligne=20dans=20la=20gamutable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gamutable_fonctions.php | 59 +++--------- gamutable_pipelines.php | 4 +- src/components/gamuTable.vue | 8 +- src/gamutable.js | 182 +++++++++++++++++------------------ 4 files changed, 116 insertions(+), 137 deletions(-) diff --git a/gamutable_fonctions.php b/gamutable_fonctions.php index caa162b..bb86894 100644 --- a/gamutable_fonctions.php +++ b/gamutable_fonctions.php @@ -57,9 +57,6 @@ if (!function_exists('tsEnDate')) { } function gamutable_fermer_modalbox($id_objet = 9999999999, $num = null) { - if ($num) { - $num = "_deux"; - } $js = gamutable_generer_js($id_objet, $num); $html = << @@ -70,31 +67,18 @@ EOJS; } function gamutable_generer_js($id_objet, $num){ - if (intval($num) === 2) { - $num = "_deux"; + if ($num === '_deux' || intval($num) === 2) { + $num = 2; } else { $num = null; } $html = << id = "$id_objet"; - if (id === 'maj' || !id) { - if (typeof app !== 'undefined') { - app.rechargerJson(id); - } - if (typeof app_deux !== 'undefined') { - app_deux.rechargerJson(id); - } - } else { - id = parseInt(id); - if (id === 9999999999) { - if (typeof app$num !== 'undefined') { - app$num.rechargerJson(); - } - } else { - if (typeof app$num !== 'undefined') { - app$num.rechargerJson(id); - } - } + if (+id === 9999999999) { + id = ''; + } + if (typeof app$num !== 'undefined') { + app$num.rechargerJson(id); } delete id; diff --git a/gamutable_pipelines.php b/gamutable_pipelines.php index ecb9090..9f478e4 100644 --- a/gamutable_pipelines.php +++ b/gamutable_pipelines.php @@ -66,9 +66,9 @@ function gamutable_crayons_vue_affichage_final($flux){ $id = intval($id) and !in_array($objet, $GLOBALS['gamutable_rechargerJson_all'] ?? []) ) { - $flux['data'] .= ' '; + $flux['data'] .= ' '; } else { - $flux['data'] .= ' '; + $flux['data'] .= ' '; } return $flux; diff --git a/src/components/gamuTable.vue b/src/components/gamuTable.vue index bf57daf..6bd14b7 100644 --- a/src/components/gamuTable.vue +++ b/src/components/gamuTable.vue @@ -1056,7 +1056,13 @@ function exporterCSV(json, delimitercsv, name) { function rechargerJson(id, ajax_Crayons = true) { console.log("rechargerJson"); ajaxCrayons = ajax_Crayons; - chargerJson(id); + console.log('rechargerJson id ', id); + + if (Number.isInteger(id) && id < 0) { + delLigne(id); + } else { + chargerJson(id); + } } function delLigne(id) { diff --git a/src/gamutable.js b/src/gamutable.js index 90e22c7..3f9f5cd 100644 --- a/src/gamutable.js +++ b/src/gamutable.js @@ -9,38 +9,38 @@ import GamuTable from './components/gamuTable.vue'; import VuePapaParse from 'vue-papa-parse'; const components = { - GamuTable, + GamuTable, }; gamutable(); function gamutable() { - let i = 1; - for (const el of document.getElementsByClassName('vue-gamutable')) { - if (i === 1) { - window.app = createApp({ - components, - mounted() { - app.rechargerJson = this.$refs.montableau.rechargerJson; - app.delLigne = this.$refs.montableau.delLigne; - }, - }); - app.use(VuePapaParse); - app.provide('$papa', app.config.globalProperties.$papa); - app.mount(el); - } else if (i === 2) { - window.app_deux = createApp({ - components, - mounted() { - app_deux.rechargerJson = this.$refs.montableau_deux.rechargerJson; - app_deux.delLigne = this.$refs.montableau_deux.delLigne; - }, - }); - app_deux.use(VuePapaParse); - app_deux.provide('$papa', app_deux.config.globalProperties.$papa); - app_deux.mount(el); - } - i++; - } + let i = 1; + for (const el of document.getElementsByClassName('vue-gamutable')) { + if (i === 1) { + window.app = createApp({ + components, + mounted() { + app.rechargerJson = this.$refs.montableau.rechargerJson; + app.delLigne = this.$refs.montableau.delLigne; + }, + }); + app.use(VuePapaParse); + app.provide('$papa', app.config.globalProperties.$papa); + app.mount(el); + } else if (i === 2) { + window.app2 = createApp({ + components, + mounted() { + app2.rechargerJson = this.$refs.montableau_deux.rechargerJson; + app2.delLigne = this.$refs.montableau_deux.delLigne; + }, + }); + app2.use(VuePapaParse); + app2.provide('$papa', app2.config.globalProperties.$papa); + app2.mount(el); + } + i++; + } } // le chargement de gamutable passe dans une variable globale // permettant de forcer son rechargement à l'ouverture du modalbox @@ -48,69 +48,69 @@ function gamutable() { window.gamutable = gamutable $('#vueGamutable').on('click', '.url_action, .url_action--ss_css', function (e) { - e.preventDefault(); - e.stopPropagation(); - let confirmation = $(this).data('confirm'); - if (confirmation !== undefined) { - if (!confirm(confirmation)) { - return; - } - } - let url = $(this).attr('href'); - let id = $(this).data('id'); + e.preventDefault(); + e.stopPropagation(); + let confirmation = $(this).data('confirm'); + if (confirmation !== undefined) { + if (!confirm(confirmation)) { + return; + } + } + let url = $(this).attr('href'); + let id = $(this).data('id'); - // gamutable(s) à mettre à jour ? 1 | 2 | 12 (par défaut 1) - let Treload = '1'; - if ($(this).parents('.gamutableDeux').length) { - Treload = '2'; - } - if ($(this).data("treload") !== undefined) { - Treload = $(this).data("treload").toString(); - } - let Treload1 = Treload.indexOf('1') !== -1; - let Treload2 = Treload.indexOf('2') !== -1; + // gamutable(s) à mettre à jour ? 1 | 2 | 12 (par défaut 1) + let Treload = '1'; + if ($(this).parents('.gamutableDeux').length) { + Treload = '2'; + } + if ($(this).data("treload") !== undefined) { + Treload = $(this).data("treload").toString(); + } + let Treload1 = Treload.indexOf('1') !== -1; + let Treload2 = Treload.indexOf('2') !== -1; - // passer en refresh animé une éventuelle icone - if ($(this).has('i.icon, i.fa')) { - $(this).find('i.icon, i.fa').eq(0).replaceWith(''); - } - let nomBlocAjaxReload = $(this).data('ajaxreload'); - $.ajax({ - url: url, - dataType: 'json', - async: true, - }).done(function (retour) { - if (!$.isEmptyObject(retour) && !$.isEmptyObject(retour.message_erreur)) { - alert(retour.message_erreur); - } else { - if (parseInt(id) > 0) { - if (Treload1) { - app.rechargerJson(id); - } - if (Treload2) { - app_deux.rechargerJson(id); - } - } else if (parseInt(id) < 0) { - if (Treload1) { - app.delLigne(id); - } - if (Treload2) { - app_deux.delLigne(id); - } - } else { - if (Treload1) { - app.rechargerJson('maj 1'); - } - if (Treload2) { - app_deux.rechargerJson('maj 2'); - } - } - if (nomBlocAjaxReload !== undefined) { - ajaxReload(nomBlocAjaxReload, { - args: { id }, - callback: function () { }, - }); - } - } - }); + // passer en refresh animé une éventuelle icone + if ($(this).has('i.icon, i.fa')) { + $(this).find('i.icon, i.fa').eq(0).replaceWith(''); + } + let nomBlocAjaxReload = $(this).data('ajaxreload'); + $.ajax({ + url: url, + dataType: 'json', + async: true, + }).done(function (retour) { + if (!$.isEmptyObject(retour) && !$.isEmptyObject(retour.message_erreur)) { + alert(retour.message_erreur); + } else { + if (parseInt(id) > 0) { + if (Treload1) { + app.rechargerJson(id); + } + if (Treload2) { + app2.rechargerJson(id); + } + } else if (parseInt(id) < 0) { + if (Treload1) { + app.delLigne(id); + } + if (Treload2) { + app2.delLigne(id); + } + } else { + if (Treload1) { + app.rechargerJson('maj 1'); + } + if (Treload2) { + app2.rechargerJson('maj 2'); + } + } + if (nomBlocAjaxReload !== undefined) { + ajaxReload(nomBlocAjaxReload, { + args: { id }, + callback: function () { }, + }); + } + } + }); });