Site > Versions > Active latest and keep active

This commit is contained in:
brunosimon
2017-08-29 19:48:52 +01:00
parent 2530f6ba5a
commit f2ca2ac277
7 changed files with 51 additions and 13 deletions
+43 -1
View File
@@ -11,13 +11,15 @@ export default
props:
{
content: { type: Array }
content: { type: Array },
file: { type: Object }
},
computed:
{
versions()
{
// console.log('uh')
const versions = this.content.sort((versionA, versionB) =>
{
const dateA = new Date(versionA.date)
@@ -28,5 +30,45 @@ export default
return versions
}
},
watch:
{
versions: 'onVersionsUpdate',
file: 'onFileUpdate'
},
created()
{
this.keepLatest = false
},
mounted()
{
this.$store.commit('setVersion', this.versions[0])
},
methods:
{
onVersionsUpdate()
{
if(this.keepLatest)
{
this.$store.commit('setVersion', this.versions[0])
}
},
onFileUpdate()
{
this.keepLatest = true
this.$store.commit('setVersion', this.versions[0])
},
onVersionClick(version, index)
{
this.keepLatest = index === 0
this.$store.commit('setVersion', version)
}
}
}