* app_deux devient app2 pour simplifier son appel. j'ai essayé de garder
  la compat, tres rarement utilisé, donc j'ai prix le risque
* refactorisation des fonctions php gamutable_fermer_modalbox => plus KISS
* ces fonctions peuvent etre appeler avec un id < 0, dans ce cas on
  supprimera la ligne dans la gamutable
This commit is contained in:
Christophe 2025-01-10 15:28:27 +01:00
parent 480d91695f
commit 83a33d8b2b
4 changed files with 116 additions and 137 deletions

View file

@ -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 = <<<EOJS
<script type="text/javascript">
@ -70,32 +67,19 @@ 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 = <<<EOJS
id = "$id_objet";
if (id === 'maj' || !id) {
if (typeof app !== 'undefined') {
app.rechargerJson(id);
if (+id === 9999999999) {
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);
}
}
}
$.modalboxclose();
delete id;
EOJS;
@ -114,32 +98,21 @@ EOJS;
* @return string $html
*/
function gamutable_recharger_tableau($id_objet = 9999999999, $num = null):string {
if ($num) {
$num = "_deux";
if ($num === '_deux' || intval($num) === 2) {
$num = 2;
} else {
$num = null;
}
$html = <<<EOJS
<script type="text/javascript">
id = "$id_objet";
if (id === 'maj' || !id) {
if (typeof app !== 'undefined') {
app.rechargerJson(id);
if (+id === 9999999999) {
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);
}
}
}
delete id;
</script>
EOJS;

View file

@ -66,9 +66,9 @@ function gamutable_crayons_vue_affichage_final($flux){
$id = intval($id)
and !in_array($objet, $GLOBALS['gamutable_rechargerJson_all'] ?? [])
) {
$flux['data'] .= ' <script type="text/javascript">if ( typeof app_deux === "object") { app_deux.rechargerJson('.$id.');}if ( typeof app === "object") { app.rechargerJson('.$id.');} </script>';
$flux['data'] .= ' <script type="text/javascript">if ( typeof app2 === "object") { app2.rechargerJson('.$id.');}if ( typeof app === "object") { app.rechargerJson('.$id.');} </script>';
} else {
$flux['data'] .= ' <script type="text/javascript">if ( typeof app_deux === "object") { app_deux.rechargerJson();}if ( typeof app === "object") { app.rechargerJson();} </script>';
$flux['data'] .= ' <script type="text/javascript">if ( typeof app2 === "object") { app2.rechargerJson();}if ( typeof app === "object") { app.rechargerJson();} </script>';
}
return $flux;

View file

@ -1056,7 +1056,13 @@ function exporterCSV(json, delimitercsv, name) {
function rechargerJson(id, ajax_Crayons = true) {
console.log("rechargerJson");
ajaxCrayons = ajax_Crayons;
console.log('rechargerJson id ', id);
if (Number.isInteger(id) && id < 0) {
delLigne(id);
} else {
chargerJson(id);
}
}
function delLigne(id) {

View file

@ -28,16 +28,16 @@ function gamutable() {
app.provide('$papa', app.config.globalProperties.$papa);
app.mount(el);
} else if (i === 2) {
window.app_deux = createApp({
window.app2 = createApp({
components,
mounted() {
app_deux.rechargerJson = this.$refs.montableau_deux.rechargerJson;
app_deux.delLigne = this.$refs.montableau_deux.delLigne;
app2.rechargerJson = this.$refs.montableau_deux.rechargerJson;
app2.delLigne = this.$refs.montableau_deux.delLigne;
},
});
app_deux.use(VuePapaParse);
app_deux.provide('$papa', app_deux.config.globalProperties.$papa);
app_deux.mount(el);
app2.use(VuePapaParse);
app2.provide('$papa', app2.config.globalProperties.$papa);
app2.mount(el);
}
i++;
}
@ -88,21 +88,21 @@ $('#vueGamutable').on('click', '.url_action, .url_action--ss_css', function (e)
app.rechargerJson(id);
}
if (Treload2) {
app_deux.rechargerJson(id);
app2.rechargerJson(id);
}
} else if (parseInt(id) < 0) {
if (Treload1) {
app.delLigne(id);
}
if (Treload2) {
app_deux.delLigne(id);
app2.delLigne(id);
}
} else {
if (Treload1) {
app.rechargerJson('maj 1');
}
if (Treload2) {
app_deux.rechargerJson('maj 2');
app2.rechargerJson('maj 2');
}
}
if (nomBlocAjaxReload !== undefined) {