From 8974f899f08a2805bf6244d8b512b97a5bc8868b Mon Sep 17 00:00:00 2001 From: tofulm Date: Thu, 12 Mar 2020 23:05:47 +0100 Subject: [PATCH] si on clique sur un id de la col id, on selectionne / deselectionne la ligne --- css/gamutable.css | 7 +++++++ js/gamutable.es6.js | 24 +++++++++++++++--------- js/gamutable.js | 23 +++++++++++++++-------- 3 files changed, 37 insertions(+), 17 deletions(-) diff --git a/css/gamutable.css b/css/gamutable.css index aafc9c5..afe6576 100644 --- a/css/gamutable.css +++ b/css/gamutable.css @@ -22,3 +22,10 @@ .iconeTri .active { color: #000; } +#app .active { + background-color: rgba(179, 209, 67, 0.47); +} + +td.id { + cursor: pointer; +} diff --git a/js/gamutable.es6.js b/js/gamutable.es6.js index dcbcf97..e2d06ac 100644 --- a/js/gamutable.es6.js +++ b/js/gamutable.es6.js @@ -2,9 +2,6 @@ jQuery(function() { $('#app').on('click', '.url_action', function(e) { e.preventDefault(); e.stopPropagation(); - $('html').css('cursor', 'wait'); - $('td').css('cursor', 'wait'); - $('a').css('cursor', 'wait'); let url = $(this).attr('href'); let id = $(this).data('id'); console.time('Chargement de VueJs APRES Ajax'); @@ -103,7 +100,8 @@ let monTableau = { parPageSelect: this.tparpage[0], pages: [], triOrders: [], - triProps: [] + triProps: [], + selectTr: [275] }; }, mounted() { @@ -156,9 +154,6 @@ let monTableau = { this.table = data; } Vue.nextTick(function() { - $('html').css('cursor', 'auto'); - $('td').css('cursor', 'auto'); - $('a').css('cursor', 'pointer'); console.timeEnd('Chargement de VueJs APRES Ajax'); }); }) @@ -205,6 +200,17 @@ let monTableau = { this.table = orderBy(this.table, ['id']); this.triOrders = []; this.triProps = []; + }, + selectLigne(id, col) { + if (col === 'id' && parseInt(id)) { + let i = this.selectTr.indexOf(id); + console.log(i); + if (i !== -1) { + this.selectTr.splice(i, 1); + } else { + this.selectTr.push(id); + } + } } }, template: ` @@ -229,8 +235,8 @@ let monTableau = { - - + + diff --git a/js/gamutable.js b/js/gamutable.js index bde4557..ef97063 100644 --- a/js/gamutable.js +++ b/js/gamutable.js @@ -12,9 +12,6 @@ jQuery(function () { $('#app').on('click', '.url_action', function (e) { e.preventDefault(); e.stopPropagation(); - $('html').css('cursor', 'wait'); - $('td').css('cursor', 'wait'); - $('a').css('cursor', 'wait'); var url = $(this).attr('href'); var id = $(this).data('id'); console.time('Chargement de VueJs APRES Ajax'); @@ -122,7 +119,8 @@ var monTableau = { parPageSelect: this.tparpage[0], pages: [], triOrders: [], - triProps: [] + triProps: [], + selectTr: [275] }; }, mounted: function mounted() { @@ -186,9 +184,6 @@ var monTableau = { } Vue.nextTick(function () { - $('html').css('cursor', 'auto'); - $('td').css('cursor', 'auto'); - $('a').css('cursor', 'pointer'); console.timeEnd('Chargement de VueJs APRES Ajax'); }); }).catch(function (error) { @@ -240,9 +235,21 @@ var monTableau = { this.table = orderBy(this.table, ['id']); this.triOrders = []; this.triProps = []; + }, + selectLigne: function selectLigne(id, col) { + if (col === 'id' && parseInt(id)) { + var i = this.selectTr.indexOf(id); + console.log(i); + + if (i !== -1) { + this.selectTr.splice(i, 1); + } else { + this.selectTr.push(id); + } + } } }, - template: "\n\t
\n\t\t
\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t
\n\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t
\n\t\t\t
{{table.length}} \xE9l\xE9ments
\n\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t
\n\t\t
\n\t
" + template: "\n\t
\n\t\t
\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t
\n\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t
\n\t\t\t
{{table.length}} \xE9l\xE9ments
\n\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t
\n\t\t
\n\t
" }; var app = new Vue({ el: '#app',