Pour charger le modele html du bloc, on ne passe plus par l'AJAX mais on
via une prop
This commit is contained in:
parent
3dc60ef3c7
commit
f6179c2fa1
3 changed files with 20 additions and 37 deletions
|
@ -8,6 +8,7 @@
|
||||||
champcsv="#ENV{champcsv,html}"
|
champcsv="#ENV{champcsv,html}"
|
||||||
delimitercsv="#ENV{delimitercsv,','}"
|
delimitercsv="#ENV{delimitercsv,','}"
|
||||||
namecsv="#ENV{namecsv,export.csv}"
|
namecsv="#ENV{namecsv,export.csv}"
|
||||||
|
vuebloc="#ENV{vuebloc}"
|
||||||
ref="montableau"
|
ref="montableau"
|
||||||
></mon-tableau>
|
></mon-tableau>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -150,8 +150,9 @@ let monTableau = {
|
||||||
namecsv: {
|
namecsv: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
toto: {
|
vuebloc: {
|
||||||
type: String,
|
type: String,
|
||||||
|
default: '',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data: function () {
|
data: function () {
|
||||||
|
@ -170,19 +171,10 @@ let monTableau = {
|
||||||
selectTr: [],
|
selectTr: [],
|
||||||
champ_search: 'html',
|
champ_search: 'html',
|
||||||
chargement: true,
|
chargement: true,
|
||||||
vuebloc: '',
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.chargerJson();
|
this.chargerJson();
|
||||||
let url = 'spip.php?page=vuebloc';
|
|
||||||
fetch(url)
|
|
||||||
.then((response) => response.text())
|
|
||||||
.then((data) => {
|
|
||||||
if (data) {
|
|
||||||
this.vuebloc = data;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
tableau: function () {
|
tableau: function () {
|
||||||
|
|
|
@ -195,8 +195,9 @@ var monTableau = {
|
||||||
namecsv: {
|
namecsv: {
|
||||||
type: String
|
type: String
|
||||||
},
|
},
|
||||||
toto: {
|
vuebloc: {
|
||||||
type: String
|
type: String,
|
||||||
|
default: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data: function data() {
|
data: function data() {
|
||||||
|
@ -214,26 +215,15 @@ var monTableau = {
|
||||||
triProps: [],
|
triProps: [],
|
||||||
selectTr: [],
|
selectTr: [],
|
||||||
champ_search: 'html',
|
champ_search: 'html',
|
||||||
chargement: true,
|
chargement: true
|
||||||
vuebloc: ''
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted: function mounted() {
|
mounted: function mounted() {
|
||||||
var _this = this;
|
|
||||||
|
|
||||||
this.chargerJson();
|
this.chargerJson();
|
||||||
var url = 'spip.php?page=vuebloc';
|
|
||||||
fetch(url).then(function (response) {
|
|
||||||
return response.text();
|
|
||||||
}).then(function (data) {
|
|
||||||
if (data) {
|
|
||||||
_this.vuebloc = data;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
tableau: function tableau() {
|
tableau: function tableau() {
|
||||||
var _this2 = this;
|
var _this = this;
|
||||||
|
|
||||||
this.setPages();
|
this.setPages();
|
||||||
|
|
||||||
|
@ -242,7 +232,7 @@ var monTableau = {
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.pagination(this.table.filter(function (ligne) {
|
return this.pagination(this.table.filter(function (ligne) {
|
||||||
return Object.values(ligne[_this2.champ_search]).toString().toLowerCase().indexOf(_this2.search.toLowerCase()) < 0 ? false : true;
|
return Object.values(ligne[_this.champ_search]).toString().toLowerCase().indexOf(_this.search.toLowerCase()) < 0 ? false : true;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -266,7 +256,7 @@ var monTableau = {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
chargerJson: function chargerJson(id) {
|
chargerJson: function chargerJson(id) {
|
||||||
var _this3 = this;
|
var _this2 = this;
|
||||||
|
|
||||||
var url = this.apiuri;
|
var url = this.apiuri;
|
||||||
|
|
||||||
|
@ -302,32 +292,32 @@ var monTableau = {
|
||||||
return response.json();
|
return response.json();
|
||||||
}).then(function (data) {
|
}).then(function (data) {
|
||||||
var config = data.shift();
|
var config = data.shift();
|
||||||
_this3.header = config.header;
|
_this2.header = config.header;
|
||||||
|
|
||||||
if (config.crayons !== undefined) {
|
if (config.crayons !== undefined) {
|
||||||
_this3.crayons = config.crayons;
|
_this2.crayons = config.crayons;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.classes !== undefined) {
|
if (config.classes !== undefined) {
|
||||||
_this3.classes = config.classes;
|
_this2.classes = config.classes;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parseInt(id) > 0) {
|
if (parseInt(id) > 0) {
|
||||||
var i = _this3.table.findIndex(function (ligne) {
|
var i = _this2.table.findIndex(function (ligne) {
|
||||||
return ligne.html.id === parseInt(id);
|
return ligne.html.id === parseInt(id);
|
||||||
});
|
});
|
||||||
|
|
||||||
Vue.set(_this3.table, i, data[0]);
|
Vue.set(_this2.table, i, data[0]);
|
||||||
} else {
|
} else {
|
||||||
_this3.table = data;
|
_this2.table = data;
|
||||||
|
|
||||||
if (data[0] && data[0].search) {
|
if (data[0] && data[0].search) {
|
||||||
_this3.champ_search = 'search';
|
_this2.champ_search = 'search';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Vue.nextTick(function () {
|
Vue.nextTick(function () {
|
||||||
_this3.chargement = false;
|
_this2.chargement = false;
|
||||||
console.timeEnd('Chargement de VueJs APRES Ajax');
|
console.timeEnd('Chargement de VueJs APRES Ajax');
|
||||||
});
|
});
|
||||||
}).catch(function (error) {
|
}).catch(function (error) {
|
||||||
|
@ -392,7 +382,7 @@ var monTableau = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
exportCSV: function exportCSV() {
|
exportCSV: function exportCSV() {
|
||||||
var _this4 = this;
|
var _this3 = this;
|
||||||
|
|
||||||
var $csv = [];
|
var $csv = [];
|
||||||
var $header = [];
|
var $header = [];
|
||||||
|
@ -402,7 +392,7 @@ var monTableau = {
|
||||||
});
|
});
|
||||||
$tableau = this.tableau.reduce(function (acc, ligne) {
|
$tableau = this.tableau.reduce(function (acc, ligne) {
|
||||||
var $uneLigne = [];
|
var $uneLigne = [];
|
||||||
Object.values(ligne[_this4.champcsv]).forEach(function (l) {
|
Object.values(ligne[_this3.champcsv]).forEach(function (l) {
|
||||||
return $uneLigne.push(l);
|
return $uneLigne.push(l);
|
||||||
});
|
});
|
||||||
return [].concat(_toConsumableArray(acc), [[].concat($uneLigne)]);
|
return [].concat(_toConsumableArray(acc), [[].concat($uneLigne)]);
|
||||||
|
|
Loading…
Add table
Reference in a new issue