diff options
author | Julius Härtl <jus@bitgrid.net> | 2019-09-06 16:23:45 +0200 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2019-09-10 09:01:25 +0200 |
commit | 98666a9f4d79a1d2bb8e9be318946e99bdcaa8b8 (patch) | |
tree | 5bf63d1d2b4e7544c47c52c0c38ab384e43d3fa9 /apps/workflowengine/src/components/Checks/RequestTime.vue | |
parent | d6b3af9d776c224015f9e9d8a4d858acae6f8560 (diff) | |
download | nextcloud-server-98666a9f4d79a1d2bb8e9be318946e99bdcaa8b8.tar.gz nextcloud-server-98666a9f4d79a1d2bb8e9be318946e99bdcaa8b8.zip |
Move over checker plugins
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'apps/workflowengine/src/components/Checks/RequestTime.vue')
-rw-r--r-- | apps/workflowengine/src/components/Checks/RequestTime.vue | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/apps/workflowengine/src/components/Checks/RequestTime.vue b/apps/workflowengine/src/components/Checks/RequestTime.vue new file mode 100644 index 00000000000..2f09693232a --- /dev/null +++ b/apps/workflowengine/src/components/Checks/RequestTime.vue @@ -0,0 +1,94 @@ +<template> + <div class="timeslot"> + <multiselect v-model="newValue.timezone" :options="timezones"></multiselect> + <input type="text" class="timeslot--start" v-model="newValue.startTime" placeholder="08:00" @input="update"/> + <input type="text" v-model="newValue.endTime" placeholder="18:00" @input="update"/> + </div> +</template> + +<script> +import { Multiselect } from 'nextcloud-vue/dist/Components/Multiselect' +import moment from 'moment-timezone' + +const zones = moment.tz.names() +export default { + name: 'RequestTime', + components: { + Multiselect + }, + props: { + value: { + type: String, + default: '1 MB' + } + }, + data() { + return { + valid: false, + newValue: { + startTime: null, + endTime: null, + timezone: moment.tz.guess() + }, + } + }, + computed: { + timezones() { + return zones + } + }, + watch: { + 'value': function(value) { + var data = JSON.parse(value) + var startTime = data[0].split(' ', 2)[0] + var endTime = data[1].split(' ', 2)[0] + var timezone = data[0].split(' ', 2)[1] + this.newValue = { + startTime: startTime, + endTime: endTime, + timezone: timezone + } + } + }, + methods: { + validate() { + return this.newValue.startTime && this.newValue.startTime.match(/^(0[0-9]|1[0-9]|2[0-3]|[0-9]):[0-5][0-9]$/i) !== null && + this.newValue.endTime && this.newValue.endTime.match(/^(0[0-9]|1[0-9]|2[0-3]|[0-9]):[0-5][0-9]$/i) !== null && + moment.tz.zone(this.newValue.timezone) !== null + }, + update() { + if (this.validate()) { + const output = `["${this.newValue.startTime} ${this.newValue.timezone}","${this.newValue.endTime} ${this.newValue.timezone}"]` + this.$emit('input', output) + this.valid = true + } else { + this.valid = false + } + } + } +} +</script> + +<style scoped lang="scss"> + .timeslot { + display: flex; + flex-grow: 1; + flex-wrap: wrap; + max-width: 200px; + + .multiselect { + width: 100%; + margin-bottom: 5px; + } + + input[type=text] { + width: 50%; + margin: 0; + margin-bottom: 5px; + &.timeslot--start { + margin-right: 5px; + width: calc(50% - 5px); + } + } + } +</style> |