Feat: on recharge en prenant en compte le timestamp

TODO : la suppression
This commit is contained in:
Christophe 2023-01-12 14:36:08 +01:00
parent 778f9a2c44
commit 1ac31ccb9d
3 changed files with 37 additions and 15 deletions

View file

@ -15,8 +15,8 @@ if (!defined("_ECRIRE_INC_VERSION")) {
include_spip("inc/vite"); include_spip("inc/vite");
function gamutable_fermer_modalbox($id_objet = 9999999999, $num = null) { function gamutable_fermer_modalbox($id_objet = 9999999999, $num = null) {
if ($num) { if ($id_objet === 'maj') {
$num = '_deux'; $id_objet = 1;
} }
$html = <<<EOJS $html = <<<EOJS
<script type="text/javascript"> <script type="text/javascript">
@ -24,13 +24,19 @@ function gamutable_fermer_modalbox($id_objet = 9999999999, $num = null) {
id = parseInt(id); id = parseInt(id);
if (id > 0 && id < 9999999999) { if (id > 0 && id < 9999999999) {
if (typeof app !== 'undefined') { if (typeof app !== 'undefined') {
app$num.rechargerJson(id); app.rechargerJson('maj');
}
if (typeof app_deux !== 'undefined') {
app_deux.rechargerJson('maj');
} }
$.modalboxclose(); $.modalboxclose();
} }
if (id === 9999999999) { if (id === 9999999999) {
if (typeof app !== 'undefined') { if (typeof app !== 'undefined') {
app$num.rechargerJson(); app.rechargerJson();
}
if (typeof app_deux !== 'undefined') {
app_deux.rechargerJson();
} }
$.modalboxclose(); $.modalboxclose();
} }
@ -41,8 +47,8 @@ EOJS;
} }
function gamutable_recharger_tableau($id_objet = 9999999999, $num = null) { function gamutable_recharger_tableau($id_objet = 9999999999, $num = null) {
if ($num) { if ($id_objet === 'maj') {
$num = '_deux'; $id_objet = 1;
} }
$html = <<<EOJS $html = <<<EOJS
<script type="text/javascript"> <script type="text/javascript">
@ -50,12 +56,18 @@ function gamutable_recharger_tableau($id_objet = 9999999999, $num = null) {
id = parseInt(id); id = parseInt(id);
if (id > 0 && id < 9999999999) { if (id > 0 && id < 9999999999) {
if (typeof app !== 'undefined') { if (typeof app !== 'undefined') {
app$num.rechargerJson(id); app.rechargerJson('maj');
}
if (typeof app_deux !== 'undefined') {
app_deux.rechargerJson('maj');
} }
} }
if (id === 9999999999) { if (id === 9999999999) {
if (typeof app !== 'undefined') { if (typeof app !== 'undefined') {
app$num.rechargerJson(); app.rechargerJson();
}
if (typeof app_deux !== 'undefined') {
app_deux.rechargerJson();
} }
} }
delete id; delete id;

View file

@ -54,7 +54,7 @@ function gamutable_crayons_vue_affichage_final($flux){
$id = intval($id) $id = intval($id)
and !in_array($objet, $GLOBALS['gamutable_rechargerJson_all'] ?? []) 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 app_deux === "object") { app_deux.rechargerJson("maj");}if ( typeof app === "object") { app.rechargerJson("maj");} </script>';
} else { } else {
$flux['data'] .= $objet . ' <script type="text/javascript">if ( typeof app_deux === "object") { app_deux.rechargerJson();}if ( typeof app === "object") { app.rechargerJson();} </script>'; $flux['data'] .= $objet . ' <script type="text/javascript">if ( typeof app_deux === "object") { app_deux.rechargerJson();}if ( typeof app === "object") { app.rechargerJson();} </script>';
} }

View file

@ -667,6 +667,21 @@ function gererData(filtreColRecup, data, id = null) {
nameLocalStorage.value, nameLocalStorage.value,
JSON.stringify(table.value) JSON.stringify(table.value)
); );
} else if (id === "maj") {
console.log("table.value = ", table.value);
if (data[0] && data[0].search) {
champ_search.value = "search";
}
if (data.length > 0) {
data.forEach((ligne, index) => {
let i = trouver_index(table.value, ligne.html.id);
table.value[i] = data[index];
});
}
localforage.setItem(
nameLocalStorage.value,
JSON.stringify(table.value)
);
} else { } else {
table.value = data; table.value = data;
if (data[0] && data[0].search) { if (data[0] && data[0].search) {
@ -791,6 +806,7 @@ function saveHeader() {
classes: classes.value, classes: classes.value,
filtreCol: filtreColType.value, filtreCol: filtreColType.value,
ordreCol: ordreCol.value, ordreCol: ordreCol.value,
maj: maj.value,
}; };
localStorage.setItem( localStorage.setItem(
"header_" + nameLocalStorage.value, "header_" + nameLocalStorage.value,
@ -801,14 +817,8 @@ function deleteInputSearch(head) {
loadingVueSelect.value = false; loadingVueSelect.value = false;
filtreColSelected.value[head] = []; filtreColSelected.value[head] = [];
} }
function hanldeSearchInput(event, head) {
searchInputHead.value = head;
searchInputVal.value = event.target.value;
}
function selectValCol() { function selectValCol() {
filtreColModif.value++; filtreColModif.value++;
searchInputVal.value = "";
searchInputHead.value = "";
} }
function endLoadingVueSelect() { function endLoadingVueSelect() {
loadingVueSelect.value = false; loadingVueSelect.value = false;