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}"
|
||||
delimitercsv="#ENV{delimitercsv,','}"
|
||||
namecsv="#ENV{namecsv,export.csv}"
|
||||
vuebloc="#ENV{vuebloc}"
|
||||
ref="montableau"
|
||||
></mon-tableau>
|
||||
</div>
|
||||
|
|
|
@ -150,8 +150,9 @@ let monTableau = {
|
|||
namecsv: {
|
||||
type: String,
|
||||
},
|
||||
toto: {
|
||||
vuebloc: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
},
|
||||
data: function () {
|
||||
|
@ -170,19 +171,10 @@ let monTableau = {
|
|||
selectTr: [],
|
||||
champ_search: 'html',
|
||||
chargement: true,
|
||||
vuebloc: '',
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.chargerJson();
|
||||
let url = 'spip.php?page=vuebloc';
|
||||
fetch(url)
|
||||
.then((response) => response.text())
|
||||
.then((data) => {
|
||||
if (data) {
|
||||
this.vuebloc = data;
|
||||
}
|
||||
});
|
||||
},
|
||||
computed: {
|
||||
tableau: function () {
|
||||
|
|
|
@ -195,8 +195,9 @@ var monTableau = {
|
|||
namecsv: {
|
||||
type: String
|
||||
},
|
||||
toto: {
|
||||
type: String
|
||||
vuebloc: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
data: function data() {
|
||||
|
@ -214,26 +215,15 @@ var monTableau = {
|
|||
triProps: [],
|
||||
selectTr: [],
|
||||
champ_search: 'html',
|
||||
chargement: true,
|
||||
vuebloc: ''
|
||||
chargement: true
|
||||
};
|
||||
},
|
||||
mounted: function mounted() {
|
||||
var _this = this;
|
||||
|
||||
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: {
|
||||
tableau: function tableau() {
|
||||
var _this2 = this;
|
||||
var _this = this;
|
||||
|
||||
this.setPages();
|
||||
|
||||
|
@ -242,7 +232,7 @@ var monTableau = {
|
|||
}
|
||||
|
||||
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: {
|
||||
chargerJson: function chargerJson(id) {
|
||||
var _this3 = this;
|
||||
var _this2 = this;
|
||||
|
||||
var url = this.apiuri;
|
||||
|
||||
|
@ -302,32 +292,32 @@ var monTableau = {
|
|||
return response.json();
|
||||
}).then(function (data) {
|
||||
var config = data.shift();
|
||||
_this3.header = config.header;
|
||||
_this2.header = config.header;
|
||||
|
||||
if (config.crayons !== undefined) {
|
||||
_this3.crayons = config.crayons;
|
||||
_this2.crayons = config.crayons;
|
||||
}
|
||||
|
||||
if (config.classes !== undefined) {
|
||||
_this3.classes = config.classes;
|
||||
_this2.classes = config.classes;
|
||||
}
|
||||
|
||||
if (parseInt(id) > 0) {
|
||||
var i = _this3.table.findIndex(function (ligne) {
|
||||
var i = _this2.table.findIndex(function (ligne) {
|
||||
return ligne.html.id === parseInt(id);
|
||||
});
|
||||
|
||||
Vue.set(_this3.table, i, data[0]);
|
||||
Vue.set(_this2.table, i, data[0]);
|
||||
} else {
|
||||
_this3.table = data;
|
||||
_this2.table = data;
|
||||
|
||||
if (data[0] && data[0].search) {
|
||||
_this3.champ_search = 'search';
|
||||
_this2.champ_search = 'search';
|
||||
}
|
||||
}
|
||||
|
||||
Vue.nextTick(function () {
|
||||
_this3.chargement = false;
|
||||
_this2.chargement = false;
|
||||
console.timeEnd('Chargement de VueJs APRES Ajax');
|
||||
});
|
||||
}).catch(function (error) {
|
||||
|
@ -392,7 +382,7 @@ var monTableau = {
|
|||
}
|
||||
},
|
||||
exportCSV: function exportCSV() {
|
||||
var _this4 = this;
|
||||
var _this3 = this;
|
||||
|
||||
var $csv = [];
|
||||
var $header = [];
|
||||
|
@ -402,7 +392,7 @@ var monTableau = {
|
|||
});
|
||||
$tableau = this.tableau.reduce(function (acc, ligne) {
|
||||
var $uneLigne = [];
|
||||
Object.values(ligne[_this4.champcsv]).forEach(function (l) {
|
||||
Object.values(ligne[_this3.champcsv]).forEach(function (l) {
|
||||
return $uneLigne.push(l);
|
||||
});
|
||||
return [].concat(_toConsumableArray(acc), [[].concat($uneLigne)]);
|
||||
|
|
Loading…
Add table
Reference in a new issue