ajout de la gestion des col en checkbox

This commit is contained in:
Christophe 2022-10-13 12:49:42 +02:00
parent bec9d27f7e
commit fdf26db329
3 changed files with 92 additions and 3 deletions

View file

@ -238,6 +238,8 @@ let monTableau = {
header: [], header: [],
crayons: [], crayons: [],
classes: [], classes: [],
checkbox: [],
Tcheckbox: [],
ordreCol: [], ordreCol: [],
filtreCol: [], filtreCol: [],
filtreColExist: false, filtreColExist: false,
@ -482,6 +484,12 @@ let monTableau = {
if (config.classes !== undefined) { if (config.classes !== undefined) {
this.classes = config.classes; this.classes = config.classes;
} }
if (config.checkbox !== undefined) {
this.checkbox = config.checkbox;
Object.keys(this.checkbox).forEach((head) => {
this.Tcheckbox[head] = [];
});
}
if (config.ordreCol !== undefined) { if (config.ordreCol !== undefined) {
this.ordreCol = config.ordreCol; this.ordreCol = config.ordreCol;
} }
@ -541,6 +549,12 @@ let monTableau = {
} else { } else {
this.classes = []; this.classes = [];
} }
if (config.checkbox !== undefined) {
this.checkbox = config.checkbox;
Object.keys(this.checkbox).forEach((head) => {
this.Tcheckbox[head] = [];
});
}
if (config.ordreCol !== undefined) { if (config.ordreCol !== undefined) {
this.ordreCol = config.ordreCol; this.ordreCol = config.ordreCol;
} else { } else {
@ -781,6 +795,27 @@ let monTableau = {
return 0; return 0;
} }
}, },
validerCheckboxCol(head) {
let tableau = this.tableau;
if (this.Tcheckbox[head] !== undefined && this.Tcheckbox[head].length) {
this.Tcheckbox[head] = [];
} else {
this.Tcheckbox[head] = [];
tableau.forEach((d) => {
this.Tcheckbox[head].push(d.html.id);
});
}
},
checkboxValider(head, url) {
let that = this;
$.ajax({
url: url,
data: { data: this.Tcheckbox[head] },
type: 'POST',
}).done(function () {
that.chargerJson();
});
},
}, },
template: ` template: `
<div class="gamutable"> <div class="gamutable">
@ -877,6 +912,10 @@ let monTableau = {
</tr> </tr>
<tr v-if="filtreCol.length" class="filtreColonne"> <tr v-if="filtreCol.length" class="filtreColonne">
<th v-for="(label,head,i) in header" :key="'filtreCol_'+i"> <th v-for="(label,head,i) in header" :key="'filtreCol_'+i">
<div v-if="checkbox[head] !== undefined" :id="'filtreCol_'+head" :class="classes[head]">
<input type="checkbox" @click.stop="validerCheckboxCol(head)" >
<button @click.stop="checkboxValider(head, checkbox[head])">Valider</button>
</div>
<div v-if="filtreCol.indexOf(head) !== -1" :id="'filtreCol_'+head" :class="classes[head]"> <div v-if="filtreCol.indexOf(head) !== -1" :id="'filtreCol_'+head" :class="classes[head]">
<vue-select <vue-select
v-if="filtreColType[head] === 'select'" v-if="filtreColType[head] === 'select'"
@ -922,7 +961,15 @@ let monTableau = {
</thead> </thead>
<tbody> <tbody>
<tr v-for="l in tableau" :key="l.html.id" :class="selectTr.indexOf(l.html.id) !== -1 ? 'select' : ''" > <tr v-for="l in tableau" :key="l.html.id" :class="selectTr.indexOf(l.html.id) !== -1 ? 'select' : ''" >
<td v-for="(td,name, i) in l.html" :key="'td_'+i" :class="[afficher_crayons(name,l.html.id), name, classes[name], l.classes !== undefined ? l.classes[name] : '']" v-html="td" @click="selectLigne(l.html.id,name)"> <td v-for="(td,name, i) in l.html" :key="'td_'+i" :class="[afficher_crayons(name,l.html.id), name, classes[name], l.classes !== undefined ? l.classes[name] : '']" @click="selectLigne(l.html.id,name)">
<div v-if="checkbox[name] !== undefined">
<label v-if="td.split('-')[0] === 'dataid'">
<input type='checkbox' v-model='Tcheckbox[name]' :value="td.split('-')[1]">
</label>
<div v-else v-html="td"></div>
</div>
<div v-else v-html="td"></div>
</td> </td>
</tr> </tr>
</tbody> </tbody>

File diff suppressed because one or more lines are too long

View file

@ -1,7 +1,7 @@
<paquet <paquet
prefix="gamutable" prefix="gamutable"
categorie="outil" categorie="outil"
version="3.7.2" version="3.7.3"
etat="dev" etat="dev"
compatibilite="[3.2.0-dev;4.1.*]" compatibilite="[3.2.0-dev;4.1.*]"
logo="prive/themes/spip/images/gamutable-xx.svg" logo="prive/themes/spip/images/gamutable-xx.svg"