Commit 7bcb3bf8 authored by anton's avatar anton
Browse files

Update from staging

parents 48cfc77e 2c62eb80
Pipeline #63813 passed with stage
in 4 minutes
......@@ -215,6 +215,7 @@ export default {
timeline: 'Timeline',
type: 'Type',
url: 'URL',
use_custom_date: 'Use custom date and time',
media_duration: 'Media duration',
media_title: 'Media title',
media_url: 'Media URL',
......@@ -488,8 +489,7 @@ export default {
create: {
title: 'Add Media',
caption: 'Add a new media to your timeline.',
default_selector_notice: 'Now using the video publishing date (if available), or the current date. Use the calendar to set a custom date and time for the video.',
override_selector_notice: 'You have set a custom date for the video.'
default_selector_notice: 'Now using the current date and time of submission or the original video publishing date, if available.'
},
sync: {
title: 'Sync Media',
......
......@@ -4,12 +4,9 @@
content-block(:position="'first'")
headline(:content="$t('routes.piecemaker.media.create.title')")
.q-mb-lg
q-alert(color="info" v-if="!selectorValue") {{ $t('routes.piecemaker.media.create.default_selector_notice') }}
q-alert(color="info" :actions="actions" v-else) {{ $t('routes.piecemaker.media.create.override_selector_notice') }}
content-paragraph(:position="'first'")
calendar-time-main(v-if="mayAdd", @update="onCalendarUpdate")
q-alert.q-mb-lg(color="info" v-if="!payload.customMediaDate") {{ $t('routes.piecemaker.media.create.default_selector_notice') }}
calendar-time-main(v-if="mayAdd && payload.customMediaDate", @update="onCalendarUpdate")
content-paragraph(:position="'last'")
form-main(v-if="mayAdd", v-model="payload", :schema="schema", ref="mediaForm")
......@@ -42,6 +39,17 @@
methods: {
onCalendarUpdate (val) {
this.selectorValue = val
},
async fetchMetadata () {
if (this.payload.url) {
this.metadata = await this.$store.dispatch('metadata/get', {
body: {
source: {
id: this.payload.url
}
}
})
}
}
},
data () {
......@@ -59,10 +67,16 @@
mayAdd: undefined,
// FIXME: i know this is bullshit!!! (but i hope it works for now)
apiPayload: undefined,
payload: { url: undefined, title: undefined },
payload: { url: undefined, title: undefined, customMediaDate: false },
selectorValue: undefined,
metadata: undefined,
schema: {
fields: {
customMediaDate: {
fullWidth: true,
type: 'checkbox',
label: 'labels.use_custom_date'
},
url: {
fullWidth: true,
type: 'text',
......@@ -75,22 +89,16 @@
},
submit: {
async handler () {
const metadata = await _this.$store.dispatch('metadata/get', {
body: {
source: {
id: _this.payload.url
}
}
})
await this.fetchMetadata()
let
start = _this.selectorValue,
end
if (!_this.selectorValue && metadata && metadata.publishedAt) {
start = DateTime.fromISO(metadata.publishedAt, { setZone: true }).toISO()
if ((!this.payload.customMediaDate || !_this.selectorValue) && _this.metadata && _this.metadata.publishedAt) {
start = DateTime.fromISO(_this.metadata.publishedAt, { setZone: true }).toISO()
}
else start = DateTime.local().toString()
if (metadata && metadata.duration) {
end = DateTime.fromISO(start, {setZone: true}).plus(metadata.duration * 1000).toISO()
else if (!this.payload.customMediaDate) start = DateTime.local().toString()
if (_this.metadata && _this.metadata.duration) {
end = DateTime.fromISO(start, {setZone: true}).plus(_this.metadata.duration * 1000).toISO()
}
const
target = _this.timeline.getInterval(start, end),
......@@ -108,8 +116,8 @@
target
}
const annotation = await _this.$store.dispatch('annotations/post', _this.apiPayload)
if (metadata) {
await titleHelper.create(_this.$store, annotation.id, metadata.title)
if (_this.metadata) {
await titleHelper.create(_this.$store, annotation.id, _this.metadata.title)
}
_this.$router.push({
name: 'piecemaker.media.list',
......
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