Commit cdd78a5e authored by Anton's avatar Anton

Fix active annotation

parent 22c5a98b
......@@ -7,12 +7,12 @@
//q-list-header
q-item {{videoMeta.title}}
template(v-if="cell.displayType === 'tabss'")
template(v-if="cell.displayType === 'tabs'")
.annotation-tabs-container.column
.annotation-tab(
v-for="(annotation, index) in annotations",
@click="event => {handleTabClick(event, annotation, index)}", :key="`tab-${index}`",
:class="{'active': isAnnotationActive(annotation, index)}")
:class="{'active': index === currentIndex}")
div {{index + 1}}
.annotation-content-container
q-item.annotation(v-for="(annotation, index) in annotations", v-show="index === activeTabIdx", :key="`annotation-${index}`")
......@@ -37,7 +37,7 @@
q-item-separator
q-item.annotation
a(:class="{'active': isAnnotationActive(annotation, index)}",
a(:class="{'active': index === currentIndex}",
@click.prevent="event => {handleAnnotationClick(event, annotation, index)}")
.row.no-wrap
.date {{formatSelectorForList(annotation)}}
......@@ -83,17 +83,18 @@ export default {
inputIndex: 0,
newAnnotationText: '',
staging: process.env.IS_STAGING,
activeTabIdx: 0
activeTabIdx: 0,
playerTime: 0.0
}
},
async mounted () {
this.videoUuid = this.cell.sourceUuid
const videoAnnotation = await this.$store.dispatch(
'annotations/get',
this.cell.sourceUuid
)
this.videoTime = DateTime.fromISO(videoAnnotation.target.selector.value, { setZone: true })
try {
const videoAnnotation = await this.$store.dispatch(
'annotations/get',
this.cell.sourceUuid
)
this.videoTime = DateTime.fromISO(videoAnnotation.target.selector.value, { setZone: true })
const meta = await this.$store.dispatch('metadata/get', videoAnnotation)
if (meta && meta.title) this.videoMeta = meta
}
......@@ -105,10 +106,28 @@ export default {
this.$root.$on('video-time-changed', this.onVideoTimeChanged)
this.$root.$on('grid-datetime', this.onGridDateTime)
},
computed: {
currentIndex () {
if (!this.annotations || !this.annotations.length) return
let idx = -1, annotation = this.annotations[0]
while (annotation && idx < this.annotations.length &&
this.baseSelector >= DateTime.fromISO(annotation.target.selector.value, { setZone: true })) {
idx++
annotation = this.annotations[idx + 1]
}
return idx
},
baseSelector () {
if (!this.videoTime) return DateTime.local().toISO()
return this.videoTime.plus(this.playerTime * 1000)
}
},
methods: {
onVideoTimeChanged (time, globalTime, origin = undefined) {
if (!origin || (origin.type === 'Video' && this.video.target.id === origin.origin.target.id)) {
// console.debug('CellAnnotationList: received video-time-changed event', time, globalTime, origin)
this.playerTime = time
this.gridTime = globalTime
this.contextTime = globalTime
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment