From 4d9d56e255c10266ab7b8ecfb8641aedc1e5fda8 Mon Sep 17 00:00:00 2001 From: tofulm Date: Tue, 26 Apr 2022 11:04:50 +0200 Subject: [PATCH] petite amelioration sur le tri --- js/gamutable.es6.js | 26 +++++++++++++++++--------- js/gamutable.js | 27 +++++++++++++++++++-------- 2 files changed, 36 insertions(+), 17 deletions(-) diff --git a/js/gamutable.es6.js b/js/gamutable.es6.js index f0c9df2..a837067 100644 --- a/js/gamutable.es6.js +++ b/js/gamutable.es6.js @@ -369,16 +369,8 @@ let monTableau = { sessionStorage.setItem('nbItems', this.parPage); }, table() { + this.saveHeader(); let $table = []; - let $header = { - header: this.header, - crayons: this.crayons, - classes: this.classes, - filtreCol: this.filtreColType, - ordreCol: this.ordreCol, - }; - localStorage.setItem('header_' + this.nameLocalStorage, JSON.stringify($header)); - $table = this.table; localforage.setItem(this.nameLocalStorage, JSON.stringify($table)); }, @@ -421,6 +413,19 @@ let monTableau = { }, }, methods: { + saveHeader() { + let $header = { + header: this.header, + crayons: this.crayons, + classes: this.classes, + filtreCol: this.filtreColType, + ordreCol: this.ordreCol, + }; + if (!localStorage.getItem('header_' + this.nameLocalStorage)) { + localStorage.setItem('headerJson_' + this.nameLocalStorage, JSON.stringify($header)); + } + localStorage.setItem('header_' + this.nameLocalStorage, JSON.stringify($header)); + }, hanldeSearchInput(event, head) { this.searchInputHead = head; this.searchInputVal = event.target.value; @@ -637,6 +642,8 @@ let monTableau = { this.triOrders.push(sens); } this.table = orderBy(this.table, this.triProps, this.triOrders, this.champ_search); + this.ordreCol[col] = sens; + this.saveHeader(); }, ordreActif(col, sens) { const i = this.triProps.indexOf(col); @@ -650,6 +657,7 @@ let monTableau = { this.table = orderBy(this.table, ['id'], '', this.champ_search); this.triOrders = []; this.triProps = []; + this.ordreCol = []; }, selectLigne(id, col) { if (col === 'id' && parseInt(id)) { diff --git a/js/gamutable.js b/js/gamutable.js index f84bab2..b90fd53 100644 --- a/js/gamutable.js +++ b/js/gamutable.js @@ -418,15 +418,8 @@ var monTableau = { sessionStorage.setItem('nbItems', this.parPage); }, table: function table() { + this.saveHeader(); var $table = []; - var $header = { - header: this.header, - crayons: this.crayons, - classes: this.classes, - filtreCol: this.filtreColType, - ordreCol: this.ordreCol - }; - localStorage.setItem('header_' + this.nameLocalStorage, JSON.stringify($header)); $table = this.table; localforage.setItem(this.nameLocalStorage, JSON.stringify($table)); }, @@ -484,6 +477,21 @@ var monTableau = { } }, methods: { + saveHeader: function saveHeader() { + var $header = { + header: this.header, + crayons: this.crayons, + classes: this.classes, + filtreCol: this.filtreColType, + ordreCol: this.ordreCol + }; + + if (!localStorage.getItem('header_' + this.nameLocalStorage)) { + localStorage.setItem('headerJson_' + this.nameLocalStorage, JSON.stringify($header)); + } + + localStorage.setItem('header_' + this.nameLocalStorage, JSON.stringify($header)); + }, hanldeSearchInput: function hanldeSearchInput(event, head) { this.searchInputHead = head; this.searchInputVal = event.target.value; @@ -740,6 +748,8 @@ var monTableau = { } this.table = orderBy(this.table, this.triProps, this.triOrders, this.champ_search); + this.ordreCol[col] = sens; + this.saveHeader(); }, ordreActif: function ordreActif(col, sens) { var i = this.triProps.indexOf(col); @@ -754,6 +764,7 @@ var monTableau = { this.table = orderBy(this.table, ['id'], '', this.champ_search); this.triOrders = []; this.triProps = []; + this.ordreCol = []; }, selectLigne: function selectLigne(id, col) { if (col === 'id' && parseInt(id)) {