feat:
* 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:
parent
480d91695f
commit
83a33d8b2b
4 changed files with 116 additions and 137 deletions
|
@ -57,9 +57,6 @@ if (!function_exists('tsEnDate')) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function gamutable_fermer_modalbox($id_objet = 9999999999, $num = null) {
|
function gamutable_fermer_modalbox($id_objet = 9999999999, $num = null) {
|
||||||
if ($num) {
|
|
||||||
$num = "_deux";
|
|
||||||
}
|
|
||||||
$js = gamutable_generer_js($id_objet, $num);
|
$js = gamutable_generer_js($id_objet, $num);
|
||||||
$html = <<<EOJS
|
$html = <<<EOJS
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
@ -70,31 +67,18 @@ EOJS;
|
||||||
}
|
}
|
||||||
|
|
||||||
function gamutable_generer_js($id_objet, $num){
|
function gamutable_generer_js($id_objet, $num){
|
||||||
if (intval($num) === 2) {
|
if ($num === '_deux' || intval($num) === 2) {
|
||||||
$num = "_deux";
|
$num = 2;
|
||||||
} else {
|
} else {
|
||||||
$num = null;
|
$num = null;
|
||||||
}
|
}
|
||||||
$html = <<<EOJS
|
$html = <<<EOJS
|
||||||
id = "$id_objet";
|
id = "$id_objet";
|
||||||
if (id === 'maj' || !id) {
|
if (+id === 9999999999) {
|
||||||
if (typeof app !== 'undefined') {
|
id = '';
|
||||||
app.rechargerJson(id);
|
}
|
||||||
}
|
if (typeof app$num !== 'undefined') {
|
||||||
if (typeof app_deux !== 'undefined') {
|
app$num.rechargerJson(id);
|
||||||
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();
|
$.modalboxclose();
|
||||||
delete id;
|
delete id;
|
||||||
|
@ -114,31 +98,20 @@ EOJS;
|
||||||
* @return string $html
|
* @return string $html
|
||||||
*/
|
*/
|
||||||
function gamutable_recharger_tableau($id_objet = 9999999999, $num = null):string {
|
function gamutable_recharger_tableau($id_objet = 9999999999, $num = null):string {
|
||||||
if ($num) {
|
if ($num === '_deux' || intval($num) === 2) {
|
||||||
$num = "_deux";
|
$num = 2;
|
||||||
|
} else {
|
||||||
|
$num = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$html = <<<EOJS
|
$html = <<<EOJS
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
id = "$id_objet";
|
id = "$id_objet";
|
||||||
if (id === 'maj' || !id) {
|
if (+id === 9999999999) {
|
||||||
if (typeof app !== 'undefined') {
|
id = '';
|
||||||
app.rechargerJson(id);
|
}
|
||||||
}
|
if (typeof app$num !== 'undefined') {
|
||||||
if (typeof app_deux !== 'undefined') {
|
app$num.rechargerJson(id);
|
||||||
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;
|
delete id;
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -66,9 +66,9 @@ 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 app2 === "object") { app2.rechargerJson('.$id.');}if ( typeof app === "object") { app.rechargerJson('.$id.');} </script>';
|
||||||
} else {
|
} 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;
|
return $flux;
|
||||||
|
|
|
@ -1056,7 +1056,13 @@ function exporterCSV(json, delimitercsv, name) {
|
||||||
function rechargerJson(id, ajax_Crayons = true) {
|
function rechargerJson(id, ajax_Crayons = true) {
|
||||||
console.log("rechargerJson");
|
console.log("rechargerJson");
|
||||||
ajaxCrayons = ajax_Crayons;
|
ajaxCrayons = ajax_Crayons;
|
||||||
chargerJson(id);
|
console.log('rechargerJson id ', id);
|
||||||
|
|
||||||
|
if (Number.isInteger(id) && id < 0) {
|
||||||
|
delLigne(id);
|
||||||
|
} else {
|
||||||
|
chargerJson(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function delLigne(id) {
|
function delLigne(id) {
|
||||||
|
|
182
src/gamutable.js
182
src/gamutable.js
|
@ -9,38 +9,38 @@ import GamuTable from './components/gamuTable.vue';
|
||||||
import VuePapaParse from 'vue-papa-parse';
|
import VuePapaParse from 'vue-papa-parse';
|
||||||
|
|
||||||
const components = {
|
const components = {
|
||||||
GamuTable,
|
GamuTable,
|
||||||
};
|
};
|
||||||
|
|
||||||
gamutable();
|
gamutable();
|
||||||
function gamutable() {
|
function gamutable() {
|
||||||
let i = 1;
|
let i = 1;
|
||||||
for (const el of document.getElementsByClassName('vue-gamutable')) {
|
for (const el of document.getElementsByClassName('vue-gamutable')) {
|
||||||
if (i === 1) {
|
if (i === 1) {
|
||||||
window.app = createApp({
|
window.app = createApp({
|
||||||
components,
|
components,
|
||||||
mounted() {
|
mounted() {
|
||||||
app.rechargerJson = this.$refs.montableau.rechargerJson;
|
app.rechargerJson = this.$refs.montableau.rechargerJson;
|
||||||
app.delLigne = this.$refs.montableau.delLigne;
|
app.delLigne = this.$refs.montableau.delLigne;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
app.use(VuePapaParse);
|
app.use(VuePapaParse);
|
||||||
app.provide('$papa', app.config.globalProperties.$papa);
|
app.provide('$papa', app.config.globalProperties.$papa);
|
||||||
app.mount(el);
|
app.mount(el);
|
||||||
} else if (i === 2) {
|
} else if (i === 2) {
|
||||||
window.app_deux = createApp({
|
window.app2 = createApp({
|
||||||
components,
|
components,
|
||||||
mounted() {
|
mounted() {
|
||||||
app_deux.rechargerJson = this.$refs.montableau_deux.rechargerJson;
|
app2.rechargerJson = this.$refs.montableau_deux.rechargerJson;
|
||||||
app_deux.delLigne = this.$refs.montableau_deux.delLigne;
|
app2.delLigne = this.$refs.montableau_deux.delLigne;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
app_deux.use(VuePapaParse);
|
app2.use(VuePapaParse);
|
||||||
app_deux.provide('$papa', app_deux.config.globalProperties.$papa);
|
app2.provide('$papa', app2.config.globalProperties.$papa);
|
||||||
app_deux.mount(el);
|
app2.mount(el);
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// le chargement de gamutable passe dans une variable globale
|
// le chargement de gamutable passe dans une variable globale
|
||||||
// permettant de forcer son rechargement à l'ouverture du modalbox
|
// permettant de forcer son rechargement à l'ouverture du modalbox
|
||||||
|
@ -48,69 +48,69 @@ function gamutable() {
|
||||||
window.gamutable = gamutable
|
window.gamutable = gamutable
|
||||||
|
|
||||||
$('#vueGamutable').on('click', '.url_action, .url_action--ss_css', function (e) {
|
$('#vueGamutable').on('click', '.url_action, .url_action--ss_css', function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
let confirmation = $(this).data('confirm');
|
let confirmation = $(this).data('confirm');
|
||||||
if (confirmation !== undefined) {
|
if (confirmation !== undefined) {
|
||||||
if (!confirm(confirmation)) {
|
if (!confirm(confirmation)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let url = $(this).attr('href');
|
let url = $(this).attr('href');
|
||||||
let id = $(this).data('id');
|
let id = $(this).data('id');
|
||||||
|
|
||||||
// gamutable(s) à mettre à jour ? 1 | 2 | 12 (par défaut 1)
|
// gamutable(s) à mettre à jour ? 1 | 2 | 12 (par défaut 1)
|
||||||
let Treload = '1';
|
let Treload = '1';
|
||||||
if ($(this).parents('.gamutableDeux').length) {
|
if ($(this).parents('.gamutableDeux').length) {
|
||||||
Treload = '2';
|
Treload = '2';
|
||||||
}
|
}
|
||||||
if ($(this).data("treload") !== undefined) {
|
if ($(this).data("treload") !== undefined) {
|
||||||
Treload = $(this).data("treload").toString();
|
Treload = $(this).data("treload").toString();
|
||||||
}
|
}
|
||||||
let Treload1 = Treload.indexOf('1') !== -1;
|
let Treload1 = Treload.indexOf('1') !== -1;
|
||||||
let Treload2 = Treload.indexOf('2') !== -1;
|
let Treload2 = Treload.indexOf('2') !== -1;
|
||||||
|
|
||||||
// passer en refresh animé une éventuelle icone
|
// passer en refresh animé une éventuelle icone
|
||||||
if ($(this).has('i.icon, i.fa')) {
|
if ($(this).has('i.icon, i.fa')) {
|
||||||
$(this).find('i.icon, i.fa').eq(0).replaceWith('<i class="fa fa-refresh fa-spin"></i>');
|
$(this).find('i.icon, i.fa').eq(0).replaceWith('<i class="fa fa-refresh fa-spin"></i>');
|
||||||
}
|
}
|
||||||
let nomBlocAjaxReload = $(this).data('ajaxreload');
|
let nomBlocAjaxReload = $(this).data('ajaxreload');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: url,
|
url: url,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
async: true,
|
async: true,
|
||||||
}).done(function (retour) {
|
}).done(function (retour) {
|
||||||
if (!$.isEmptyObject(retour) && !$.isEmptyObject(retour.message_erreur)) {
|
if (!$.isEmptyObject(retour) && !$.isEmptyObject(retour.message_erreur)) {
|
||||||
alert(retour.message_erreur);
|
alert(retour.message_erreur);
|
||||||
} else {
|
} else {
|
||||||
if (parseInt(id) > 0) {
|
if (parseInt(id) > 0) {
|
||||||
if (Treload1) {
|
if (Treload1) {
|
||||||
app.rechargerJson(id);
|
app.rechargerJson(id);
|
||||||
}
|
}
|
||||||
if (Treload2) {
|
if (Treload2) {
|
||||||
app_deux.rechargerJson(id);
|
app2.rechargerJson(id);
|
||||||
}
|
}
|
||||||
} else if (parseInt(id) < 0) {
|
} else if (parseInt(id) < 0) {
|
||||||
if (Treload1) {
|
if (Treload1) {
|
||||||
app.delLigne(id);
|
app.delLigne(id);
|
||||||
}
|
}
|
||||||
if (Treload2) {
|
if (Treload2) {
|
||||||
app_deux.delLigne(id);
|
app2.delLigne(id);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Treload1) {
|
if (Treload1) {
|
||||||
app.rechargerJson('maj 1');
|
app.rechargerJson('maj 1');
|
||||||
}
|
}
|
||||||
if (Treload2) {
|
if (Treload2) {
|
||||||
app_deux.rechargerJson('maj 2');
|
app2.rechargerJson('maj 2');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nomBlocAjaxReload !== undefined) {
|
if (nomBlocAjaxReload !== undefined) {
|
||||||
ajaxReload(nomBlocAjaxReload, {
|
ajaxReload(nomBlocAjaxReload, {
|
||||||
args: { id },
|
args: { id },
|
||||||
callback: function () { },
|
callback: function () { },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue