2019-02-17 06:32:35 +00:00
|
|
|
<template lang='pug'>
|
2019-08-10 16:18:14 +00:00
|
|
|
v-toolbar.radius-7(flat, :color='$vuetify.theme.dark ? "grey darken-4-l3" : "grey lighten-3"')
|
2019-06-15 21:05:56 +00:00
|
|
|
.body-2.mr-3 {{$t('common:duration.every')}}
|
2019-02-17 06:32:35 +00:00
|
|
|
v-text-field(
|
|
|
|
solo
|
|
|
|
hide-details
|
|
|
|
flat
|
|
|
|
reverse
|
|
|
|
v-model='minutes'
|
2019-08-25 18:23:56 +00:00
|
|
|
style='flex: 1 1 70px;'
|
2019-02-17 06:32:35 +00:00
|
|
|
)
|
2019-06-15 21:05:56 +00:00
|
|
|
.body-2.mx-3 {{$t('common:duration.minutes')}}
|
2019-08-25 18:23:56 +00:00
|
|
|
v-divider.mr-3
|
2019-02-17 06:32:35 +00:00
|
|
|
v-text-field(
|
|
|
|
solo
|
|
|
|
hide-details
|
|
|
|
flat
|
|
|
|
reverse
|
|
|
|
v-model='hours'
|
2019-08-25 18:23:56 +00:00
|
|
|
style='flex: 1 1 70px;'
|
2019-02-17 06:32:35 +00:00
|
|
|
)
|
2019-06-15 21:05:56 +00:00
|
|
|
.body-2.mx-3 {{$t('common:duration.hours')}}
|
2019-08-25 18:23:56 +00:00
|
|
|
v-divider.mr-3
|
2019-02-17 06:32:35 +00:00
|
|
|
v-text-field(
|
|
|
|
solo
|
|
|
|
hide-details
|
|
|
|
flat
|
|
|
|
reverse
|
|
|
|
v-model='days'
|
2019-08-25 18:23:56 +00:00
|
|
|
style='flex: 1 1 70px;'
|
2019-02-17 06:32:35 +00:00
|
|
|
)
|
2019-06-15 21:05:56 +00:00
|
|
|
.body-2.mx-3 {{$t('common:duration.days')}}
|
2019-08-25 18:23:56 +00:00
|
|
|
v-divider.mr-3
|
2019-02-17 06:32:35 +00:00
|
|
|
v-text-field(
|
|
|
|
solo
|
|
|
|
hide-details
|
|
|
|
flat
|
|
|
|
reverse
|
|
|
|
v-model='months'
|
2019-08-25 18:23:56 +00:00
|
|
|
style='flex: 1 1 70px;'
|
2019-02-17 06:32:35 +00:00
|
|
|
)
|
2019-06-15 21:05:56 +00:00
|
|
|
.body-2.mx-3 {{$t('common:duration.months')}}
|
2019-08-25 18:23:56 +00:00
|
|
|
v-divider.mr-3
|
2019-02-17 06:32:35 +00:00
|
|
|
v-text-field(
|
|
|
|
solo
|
|
|
|
hide-details
|
|
|
|
flat
|
|
|
|
reverse
|
|
|
|
v-model='years'
|
2019-08-25 18:23:56 +00:00
|
|
|
style='flex: 1 1 70px;'
|
2019-02-17 06:32:35 +00:00
|
|
|
)
|
2019-06-15 21:05:56 +00:00
|
|
|
.body-2.mx-3 {{$t('common:duration.years')}}
|
2019-02-17 06:32:35 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import _ from 'lodash'
|
|
|
|
import moment from 'moment'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
value: {
|
|
|
|
type: String,
|
|
|
|
default: 'PT5M'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
duration: moment.duration(0)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
years: {
|
|
|
|
get() { return this.duration.years() || 0 },
|
|
|
|
set(val) { this.rebuild(_.toNumber(val), 'years') }
|
|
|
|
},
|
|
|
|
months: {
|
|
|
|
get() { return this.duration.months() || 0 },
|
|
|
|
set(val) { this.rebuild(_.toNumber(val), 'months') }
|
|
|
|
},
|
|
|
|
days: {
|
|
|
|
get() { return this.duration.days() || 0 },
|
|
|
|
set(val) { this.rebuild(_.toNumber(val), 'days') }
|
|
|
|
},
|
|
|
|
hours: {
|
|
|
|
get() { return this.duration.hours() || 0 },
|
|
|
|
set(val) { this.rebuild(_.toNumber(val), 'hours') }
|
|
|
|
},
|
|
|
|
minutes: {
|
|
|
|
get() { return this.duration.minutes() || 0 },
|
|
|
|
set(val) { this.rebuild(_.toNumber(val), 'minutes') }
|
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
value(newValue, oldValue) {
|
|
|
|
this.duration = moment.duration(newValue)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
rebuild(val, unit) {
|
|
|
|
if (!_.isFinite(val) || val < 0) {
|
|
|
|
val = 0
|
|
|
|
}
|
|
|
|
const newDuration = {
|
|
|
|
minutes: this.duration.minutes(),
|
|
|
|
hours: this.duration.hours(),
|
|
|
|
days: this.duration.days(),
|
|
|
|
months: this.duration.months(),
|
|
|
|
years: this.duration.years()
|
|
|
|
}
|
|
|
|
_.set(newDuration, unit, val)
|
|
|
|
this.duration = moment.duration(newDuration)
|
|
|
|
this.$emit('input', this.duration.toISOString())
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.duration = moment.duration(this.value)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|