feat : suite refactoring
This commit is contained in:
parent
910cf503d8
commit
778f9a2c44
3 changed files with 297 additions and 339 deletions
File diff suppressed because it is too large
Load diff
|
@ -45,7 +45,7 @@
|
|||
includespip="#ENV{includespip}"
|
||||
ref="montableau"
|
||||
filtrer="#ENV{filtrer}"
|
||||
_id="#ENV{_id}"
|
||||
:_id="[(#ENV{_id}|intval)]"
|
||||
filtreselect="[(#ENV{filtrerselect})]"
|
||||
></gamu-table>
|
||||
</div>
|
||||
|
@ -76,7 +76,7 @@
|
|||
includespip="#ENV{includespip}"
|
||||
ref="montableau_deux"
|
||||
filtrer="#ENV{filtrer}"
|
||||
_id="#ENV{_id}"
|
||||
:_id="[(#ENV{_id}|intval)]"
|
||||
filtreselect="[(#ENV{filtrerselect_deux})]"
|
||||
></gamu-table>
|
||||
</div>
|
||||
|
|
|
@ -653,6 +653,45 @@ function gererConfig(config) {
|
|||
}
|
||||
return filtreCol;
|
||||
}
|
||||
|
||||
function gererData(filtreColRecup, data, id = null) {
|
||||
if (parseInt(id) > 0) {
|
||||
if (data.length > 0) {
|
||||
let i = trouver_index(table.value, id);
|
||||
table.value[i] = data[0];
|
||||
} else {
|
||||
let i = trouver_index(table.value, id);
|
||||
table.value.splice(i, 1);
|
||||
}
|
||||
localforage.setItem(
|
||||
nameLocalStorage.value,
|
||||
JSON.stringify(table.value)
|
||||
);
|
||||
} else {
|
||||
table.value = data;
|
||||
if (data[0] && data[0].search) {
|
||||
champ_search.value = "search";
|
||||
}
|
||||
}
|
||||
if (filtreColRecup !== undefined) {
|
||||
filtreColType.value = filtreColRecup;
|
||||
filtreCol.value = [];
|
||||
Object.keys(filtreColType.value).forEach((col) => {
|
||||
let Tval = [];
|
||||
table.value.forEach((t) => {
|
||||
let valCol = t[champ_search.value][col];
|
||||
if (valCol) {
|
||||
if (Tval.indexOf(valCol) === -1) {
|
||||
Tval.push(valCol);
|
||||
}
|
||||
}
|
||||
});
|
||||
filtreCol.value.push(col);
|
||||
filtreColVal.value[col] = Tval.sort();
|
||||
filtreColSelected.value[col] = [];
|
||||
});
|
||||
}
|
||||
}
|
||||
function chargerJson(id) {
|
||||
console.log("chargerJson pour ", id);
|
||||
chargement.value = true;
|
||||
|
@ -670,28 +709,7 @@ function chargerJson(id) {
|
|||
.getItem(nameLocalStorage.value)
|
||||
.then(function (data) {
|
||||
data = recupJson(data);
|
||||
if (data && data.length) {
|
||||
table.value = data;
|
||||
if (data[0].search) {
|
||||
champ_search.value = "search";
|
||||
}
|
||||
if (filtreColRecup !== undefined) {
|
||||
filtreColType.value = filtreColRecup;
|
||||
Object.keys(filtreColType.value).forEach((col) => {
|
||||
let Tval = [];
|
||||
// let Tval = [''];
|
||||
table.value.forEach((t) => {
|
||||
let valCol = t[champ_search.value][col];
|
||||
if (Tval.indexOf(valCol) === -1) {
|
||||
Tval.push(valCol);
|
||||
}
|
||||
});
|
||||
// filtreCol.value.push(col);
|
||||
filtreColVal.value[col] = Tval.sort();
|
||||
filtreColSelected.value[col] = [];
|
||||
});
|
||||
}
|
||||
}
|
||||
gererData(filtreColRecup, data, id);
|
||||
if (props.nomblocajaxreload) {
|
||||
ajaxReload(props.nomblocajaxreload);
|
||||
}
|
||||
|
@ -706,67 +724,7 @@ function chargerJson(id) {
|
|||
.then((data) => {
|
||||
let config = data.shift();
|
||||
let filtreColRecup = gererConfig(config);
|
||||
// header.value = config.header;
|
||||
// if (config.maj !== undefined) {
|
||||
// maj.value = config.maj?.lastMAJ;
|
||||
// }
|
||||
// if (config.crayons !== undefined) {
|
||||
// crayons.value = config.crayons;
|
||||
// } else {
|
||||
// crayons.value = [];
|
||||
// }
|
||||
// if (config.classes !== undefined) {
|
||||
// classes.value = config.classes;
|
||||
// } else {
|
||||
// classes.value = [];
|
||||
// }
|
||||
// if (config.checkbox !== undefined) {
|
||||
// checkbox.value = config.checkbox;
|
||||
// Object.keys(checkbox.value).forEach((head) => {
|
||||
// Tcheckbox.value[head] = [];
|
||||
// });
|
||||
// }
|
||||
// if (config.ordreCol !== undefined) {
|
||||
// ordreCol.value = config.ordreCol;
|
||||
// } else {
|
||||
// ordreCol.value = [];
|
||||
// }
|
||||
if (parseInt(id) > 0) {
|
||||
if (data.length > 0) {
|
||||
let i = trouver_index(table.value, id);
|
||||
table.value[i] = data[0];
|
||||
} else {
|
||||
let i = trouver_index(table.value, id);
|
||||
table.value.splice(i, 1);
|
||||
}
|
||||
localforage.setItem(
|
||||
nameLocalStorage.value,
|
||||
JSON.stringify(table.value)
|
||||
);
|
||||
} else {
|
||||
table.value = data;
|
||||
if (data[0] && data[0].search) {
|
||||
champ_search.value = "search";
|
||||
}
|
||||
}
|
||||
if (filtreColRecup !== undefined) {
|
||||
filtreColType.value = filtreColRecup;
|
||||
filtreCol.value = [];
|
||||
Object.keys(filtreColType.value).forEach((col) => {
|
||||
let Tval = [];
|
||||
table.value.forEach((t) => {
|
||||
let valCol = t[champ_search.value][col];
|
||||
if (valCol) {
|
||||
if (Tval.indexOf(valCol) === -1) {
|
||||
Tval.push(valCol);
|
||||
}
|
||||
}
|
||||
});
|
||||
filtreCol.value.push(col);
|
||||
filtreColVal.value[col] = Tval.sort();
|
||||
filtreColSelected.value[col] = [];
|
||||
});
|
||||
}
|
||||
gererData(filtreColRecup, data, id);
|
||||
|
||||
nextTick(() => {
|
||||
chargement.value = false;
|
||||
|
|
Loading…
Add table
Reference in a new issue