From 1fa801ce92c595da7e2134dec3ea128c5b19a717 Mon Sep 17 00:00:00 2001 From: tofulm Date: Thu, 24 Mar 2022 07:22:28 +0100 Subject: [PATCH] quand on ajout dans l'url &_id=45, maintenant gamutable affiche la bonne page de l'element 45 --- inclure/gamutable.html | 7 ++++--- js/gamutable.es6.js | 24 +++++++++++++++++++++--- js/gamutable.js | 27 ++++++++++++++++++++++++--- 3 files changed, 49 insertions(+), 9 deletions(-) diff --git a/inclure/gamutable.html b/inclure/gamutable.html index a808610..b6f5150 100644 --- a/inclure/gamutable.html +++ b/inclure/gamutable.html @@ -23,6 +23,7 @@ includespip="#ENV{includespip}" ref="montableau" filtrer="#ENV{filtrer}" + _id="#ENV{_id}" > @@ -46,6 +47,8 @@ includespip="#ENV{includespip}" ref="montableau" filtrer="#ENV{filtrer}" + affichage_id="#ENV{_id}" + _id="#ENV{_id}" > @@ -57,9 +60,7 @@ ajout de la classe: select sur le tr ] [(#CONFIG{gamutable/version_js}|=={dev}|?{ diff --git a/js/gamutable.es6.js b/js/gamutable.es6.js index 68c5776..b4bf5b1 100644 --- a/js/gamutable.es6.js +++ b/js/gamutable.es6.js @@ -201,6 +201,9 @@ let monTableau = { filtrer: { type: String, }, + _id: { + type: String, + }, }, data: function () { return { @@ -485,12 +488,27 @@ let monTableau = { Vue.nextTick(() => { this.chargement = false; - if ($_id > 0) { - this.selectLigne($_id, 'id'); + if (parseInt(this._id) > 0) { + let _id = parseInt(this._id); + let parPage = parseInt(this.tparpage[0]); + if (parseInt(parPage)) { + let ordre = 0; + Object.values(this.table).forEach((d, i) => { + if (_id === d.html.id) { + ordre = i + 1; + } + }); + if (ordre > parPage) { + let numPage = parseInt(ordre / parPage) + 1; + this.page = numPage; + } + } + this.selectLigne(_id, 'id'); let url = new URL(window.location); - url = url.href.replace('&_id=' + $_id, ''); + url = url.href.replace('&_id=' + _id, ''); history.pushState({}, null, url); } + if (this.nomblocajaxreload) { ajaxReload(this.nomblocajaxreload); } diff --git a/js/gamutable.js b/js/gamutable.js index be5e71f..d8c2de7 100644 --- a/js/gamutable.js +++ b/js/gamutable.js @@ -251,6 +251,9 @@ var monTableau = { }, filtrer: { type: String + }, + _id: { + type: String } }, data: function data() { @@ -562,12 +565,30 @@ var monTableau = { Vue.nextTick(function () { _this4.chargement = false; - if ($_id > 0) { - _this4.selectLigne($_id, 'id'); + if (parseInt(_this4._id) > 0) { + var _id = parseInt(_this4._id); + + var parPage = parseInt(_this4.tparpage[0]); + + if (parseInt(parPage)) { + var ordre = 0; + Object.values(_this4.table).forEach(function (d, i) { + if (_id === d.html.id) { + ordre = i + 1; + } + }); + + if (ordre > parPage) { + var numPage = parseInt(ordre / parPage) + 1; + _this4.page = numPage; + } + } + + _this4.selectLigne(_id, 'id'); var _url = new URL(window.location); - _url = _url.href.replace('&_id=' + $_id, ''); + _url = _url.href.replace('&_id=' + _id, ''); history.pushState({}, null, _url); }