Commit cb972c40 authored by Richard Blechinger's avatar Richard Blechinger
Browse files

Show projected duration when adding new timeslot

parent c2ef9afc
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
variant="warning" variant="warning"
:show="pastEventWarning" :show="pastEventWarning"
> >
<span v-html="$t('scheduleEditor.pastEventWarning')" /> <span v-html="$t('scheduleEditor.pastEventWarning')"/>
</b-alert> </b-alert>
<div v-if="loaded.modal && !submitting"> <div v-if="loaded.modal && !submitting">
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
</b-col> </b-col>
<b-col cols="3" v-if="valuePick.rrule != 1"> <b-col cols="3" v-if="valuePick.rrule != 1">
<label class="tw-w-full tw-font-bold"> <label class="tw-w-full tw-font-bold">
<span class="tw-inline-block tw-pb-2" v-html="$t('scheduleEditor.toDate')" /> <span class="tw-inline-block tw-pb-2" v-html="$t('scheduleEditor.toDate')"/>
<b-form-input <b-form-input
v-model="valuePick.until" v-model="valuePick.until"
type="date" type="date"
...@@ -76,6 +76,18 @@ ...@@ -76,6 +76,18 @@
</b-col> </b-col>
</b-row> </b-row>
</div> </div>
<template v-slot:modal-footer="{ ok, cancel }">
<div class="tw-flex tw-justify-between tw-items-center tw-w-full">
<span v-html="$t('scheduleEditor.projectedDuration', { duration: projectedTimeslotDuration })"/>
<div class="tw-space-x-2">
<b-button @click="cancel()">{{ $t('cancel') }}</b-button>
<b-button variant='primary' @click="ok()">OK</b-button>
</div>
</div>
</template>
</b-modal> </b-modal>
</div> </div>
</template> </template>
...@@ -97,6 +109,7 @@ ...@@ -97,6 +109,7 @@
valuePick: { valuePick: {
dstart: null, dstart: null,
tstart: null, tstart: null,
dend: null,
tend: null, tend: null,
until: null, until: null,
rrule: 1 rrule: 1
...@@ -112,6 +125,18 @@ ...@@ -112,6 +125,18 @@
} }
}, },
projectedTimeslotDuration() {
const {dstart, tstart, dend, tend} = this.valuePick;
const d1 = new Date(`${dstart} ${tstart}`);
const d2 = new Date(`${dend} ${tend}`);
const diffInNs = (d2 - d1) * 1000 * 1000;
const diffInMinutes = this.nanosecondsToMinutes(diffInNs);
return this.minutesToHm(diffInMinutes);
},
...mapGetters({ ...mapGetters({
selectedShow: 'shows/selectedShow', selectedShow: 'shows/selectedShow',
}) })
...@@ -201,6 +226,7 @@ ...@@ -201,6 +226,7 @@
open(start, end) { open(start, end) {
let dstart = start.format('YYYY-MM-DD') let dstart = start.format('YYYY-MM-DD')
let tstart = start.format('HH:mm') let tstart = start.format('HH:mm')
let dend = end.format('YYYY-MM-DD')
let tend = end.format('HH:mm') let tend = end.format('HH:mm')
let until = end.format('YYYY-MM-DD') let until = end.format('YYYY-MM-DD')
let now = this.apiDate(new Date()) let now = this.apiDate(new Date())
...@@ -212,6 +238,7 @@ ...@@ -212,6 +238,7 @@
} }
this.valuePick.dstart = dstart this.valuePick.dstart = dstart
this.valuePick.tstart = tstart this.valuePick.tstart = tstart
this.valuePick.dend = dend
this.valuePick.tend = tend this.valuePick.tend = tend
this.valuePick.until = until this.valuePick.until = until
this.newSchedule = { this.newSchedule = {
......
...@@ -369,6 +369,7 @@ export default { ...@@ -369,6 +369,7 @@ export default {
'start': 'Start', 'start': 'Start',
'end': 'Ende', 'end': 'Ende',
'projectedDuration': '<b>Geplante Dauer: </b> %{duration}',
'pastEventWarning': 'Vergangene Daten werden ignoriert. Startdatum wurde auf heute gesetzt!<br>Versuch es noch einmal oder setze ein Startdatum in die Zukunft.', 'pastEventWarning': 'Vergangene Daten werden ignoriert. Startdatum wurde auf heute gesetzt!<br>Versuch es noch einmal oder setze ein Startdatum in die Zukunft.',
'from': 'Von', 'from': 'Von',
......
...@@ -369,6 +369,7 @@ export default { ...@@ -369,6 +369,7 @@ export default {
'start': 'Start', 'start': 'Start',
'end': 'End', 'end': 'End',
'projectedDuration': '<b>Projected duration: </b> %{duration}',
'pastEventWarning': 'Past events will be ignored. Start date was set to today!<br>Try again or change the start date to something in the future.', 'pastEventWarning': 'Past events will be ignored. Start date was set to today!<br>Try again or change the start date to something in the future.',
'from': 'From', 'from': 'From',
......
...@@ -110,6 +110,12 @@ export default { ...@@ -110,6 +110,12 @@ export default {
return seconds * 1000 * 1000 * 1000; return seconds * 1000 * 1000 * 1000;
}, },
minutesToHm: function(minutes) {
var m = minutes % 60;
var h = (minutes-m)/60;
return `${this.leadingZero(h)}:${this.leadingZero(m)}`;
},
prettyWeekday: function (weekday) { prettyWeekday: function (weekday) {
let w; let w;
......
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