quand on ajout dans l'url &_id=45, maintenant gamutable affiche la bonne page de l'element 45

This commit is contained in:
Christophe 2022-03-24 07:22:28 +01:00
parent 1c3a41a2a8
commit 1fa801ce92
3 changed files with 49 additions and 9 deletions

View file

@ -23,6 +23,7 @@
includespip="#ENV{includespip}" includespip="#ENV{includespip}"
ref="montableau" ref="montableau"
filtrer="#ENV{filtrer}" filtrer="#ENV{filtrer}"
_id="#ENV{_id}"
></mon-tableau> ></mon-tableau>
</div> </div>
</div> </div>
@ -46,6 +47,8 @@
includespip="#ENV{includespip}" includespip="#ENV{includespip}"
ref="montableau" ref="montableau"
filtrer="#ENV{filtrer}" filtrer="#ENV{filtrer}"
affichage_id="#ENV{_id}"
_id="#ENV{_id}"
></mon-tableau> ></mon-tableau>
</div> </div>
</div> </div>
@ -57,9 +60,7 @@
ajout de la classe: select sur le tr ajout de la classe: select sur le tr
] ]
<script type="text/javascript"> <script type="text/javascript">
var $_id = #ENV{_id,0}; let nomBlocAjaxReload = '';
$_id = parseInt($_id);
var nomBlocAjaxReload = '';
</script> </script>
[(#CONFIG{gamutable/version_js}|=={dev}|?{ [(#CONFIG{gamutable/version_js}|=={dev}|?{

View file

@ -201,6 +201,9 @@ let monTableau = {
filtrer: { filtrer: {
type: String, type: String,
}, },
_id: {
type: String,
},
}, },
data: function () { data: function () {
return { return {
@ -485,12 +488,27 @@ let monTableau = {
Vue.nextTick(() => { Vue.nextTick(() => {
this.chargement = false; this.chargement = false;
if ($_id > 0) { if (parseInt(this._id) > 0) {
this.selectLigne($_id, 'id'); 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); let url = new URL(window.location);
url = url.href.replace('&_id=' + $_id, ''); url = url.href.replace('&_id=' + _id, '');
history.pushState({}, null, url); history.pushState({}, null, url);
} }
if (this.nomblocajaxreload) { if (this.nomblocajaxreload) {
ajaxReload(this.nomblocajaxreload); ajaxReload(this.nomblocajaxreload);
} }

View file

@ -251,6 +251,9 @@ var monTableau = {
}, },
filtrer: { filtrer: {
type: String type: String
},
_id: {
type: String
} }
}, },
data: function data() { data: function data() {
@ -562,12 +565,30 @@ var monTableau = {
Vue.nextTick(function () { Vue.nextTick(function () {
_this4.chargement = false; _this4.chargement = false;
if ($_id > 0) { if (parseInt(_this4._id) > 0) {
_this4.selectLigne($_id, 'id'); 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); var _url = new URL(window.location);
_url = _url.href.replace('&_id=' + $_id, ''); _url = _url.href.replace('&_id=' + _id, '');
history.pushState({}, null, _url); history.pushState({}, null, _url);
} }