history is working #2203

This commit is contained in:
2023-07-14 13:14:04 +02:00
parent 0a5f1adf90
commit 6b2146ea8f
5 changed files with 148 additions and 111 deletions

View File

@@ -43,35 +43,43 @@ export default {
console.log(`terrain de vie content created, id: ${this.id}, eid: ${this.eid}, opened_concernement:`, this.opened_concernement);
// revisions
if (!this.opened_concernement.revisons) {
this.loadConcernementsRevisions(this.id).then(()=>{
console.log('Terrain de vie revisions loaded', this.opened_concernement.revisions);
if (this.opened_concernement.revisions.length > 1) {
let data=[];
this.opened_concernement.revisions.forEach(rev => {
let d = new Date(rev.changed);
data.push({
'id': rev.revision_id,
'changed': d.toLocaleDateString("fr-FR")
})
this.history_value = Math.max(this.history_value, parseInt(rev.revision_id));
});
this.history_slider_ops = {
dotSize:10,
data: data,
'data-value': 'id',
'data-label': 'changed',
adsorb: true,
'hide-label': true
}
} else {
this.history_slider_ops = null;
}
});
let data=[];
this.opened_concernement.revisions.forEach(rev => {
if (rev.entites.length > 3) {
let d = new Date(rev.changed);
data.push({
'id': rev.revision_id,
'changed': d.toLocaleDateString("fr-FR")
})
this.history_value = Math.max(this.history_value, parseInt(rev.revision_id));
}
});
if (data.length > 1) {
this.history_slider_ops = {
dotSize:10,
data: data,
'data-value': 'id',
'data-label': 'changed',
adsorb: true,
'hide-label': true
}
} else {
this.history_slider_ops = null;
}
},
watch: {
history_value: {
handler (n, o) {
console.log(`TerrainDeVie watch history_value o:${o}, n:${n}`);
this.setActiveRevision(this.opened_concernement.id, n);
},
deep: true
}
},
methods: {
...mapActions(ConcernementsStore, ['loadConcernementsRevisions'])
...mapActions(ConcernementsStore, ['setActiveRevision']) // 'loadConcernementsRevisions'
},
components: {
CartoucheLayout,