mirror of
https://github.com/nextcloud/server.git
synced 2026-02-20 00:12:30 -05:00
fix(workflowengine): adapt check operator RequestTime to use web component
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
parent
c24ead810d
commit
f88ea21ddc
2 changed files with 20 additions and 13 deletions
|
|
@ -27,7 +27,6 @@
|
|||
<script>
|
||||
import NcSelect from '@nextcloud/vue/components/NcSelect'
|
||||
import moment from 'moment-timezone'
|
||||
import valueMixin from '../../mixins/valueMixin.js'
|
||||
|
||||
const zones = moment.tz.names()
|
||||
export default {
|
||||
|
|
@ -35,13 +34,16 @@ export default {
|
|||
components: {
|
||||
NcSelect,
|
||||
},
|
||||
mixins: [
|
||||
valueMixin,
|
||||
],
|
||||
emits: ['update:model-value'],
|
||||
props: {
|
||||
value: {
|
||||
modelValue: {
|
||||
type: String,
|
||||
default: '',
|
||||
default: '[]',
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
modelValue() {
|
||||
this.updateInternalValue()
|
||||
},
|
||||
},
|
||||
data() {
|
||||
|
|
@ -53,21 +55,26 @@ export default {
|
|||
endTime: null,
|
||||
timezone: moment.tz.guess(),
|
||||
},
|
||||
stringifiedValue : '[]'
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.validate()
|
||||
beforeMount() {
|
||||
// this is necessary to keep so the value is re-applied when a different
|
||||
// check is being removed.
|
||||
this.updateInternalValue()
|
||||
},
|
||||
methods: {
|
||||
updateInternalValue(value) {
|
||||
updateInternalValue() {
|
||||
try {
|
||||
const data = JSON.parse(value)
|
||||
const data = JSON.parse(this.modelValue)
|
||||
if (data.length === 2) {
|
||||
this.newValue = {
|
||||
startTime: data[0].split(' ', 2)[0],
|
||||
endTime: data[1].split(' ', 2)[0],
|
||||
timezone: data[0].split(' ', 2)[1],
|
||||
}
|
||||
this.stringifiedValue = `["${this.newValue.startTime} ${this.newValue.timezone}","${this.newValue.endTime} ${this.newValue.timezone}"]`
|
||||
this.validate()
|
||||
}
|
||||
} catch (e) {
|
||||
// ignore invalid values
|
||||
|
|
@ -89,8 +96,8 @@ export default {
|
|||
this.newValue.timezone = moment.tz.guess()
|
||||
}
|
||||
if (this.validate()) {
|
||||
const output = `["${this.newValue.startTime} ${this.newValue.timezone}","${this.newValue.endTime} ${this.newValue.timezone}"]`
|
||||
this.$emit('input', output)
|
||||
this.stringifiedValue = `["${this.newValue.startTime} ${this.newValue.timezone}","${this.newValue.endTime} ${this.newValue.timezone}"]`
|
||||
this.$emit('update:model-value', this.stringifiedValue)
|
||||
}
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ const RequestChecks = [
|
|||
{ operator: 'in', name: t('workflowengine', 'between') },
|
||||
{ operator: '!in', name: t('workflowengine', 'not between') },
|
||||
],
|
||||
component: RequestTime,
|
||||
element: registerCustomElement(RequestTime, 'oca-workflowengine-checks-request_time'),
|
||||
},
|
||||
{
|
||||
class: 'OCA\\WorkflowEngine\\Check\\RequestUserAgent',
|
||||
|
|
|
|||
Loading…
Reference in a new issue