Skip to content

Commit c24ead8

Browse files
committed
fix(workflowengine): adapt check operator RequestURL to use web component
Signed-off-by: Arthur Schiwon <[email protected]>
1 parent 5fbe008 commit c24ead8

3 files changed

Lines changed: 22 additions & 6 deletions

File tree

apps/workflowengine/src/components/Check.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
v-if="currentElement"
2424
ref="checkComponent"
2525
:disabled="!currentOption"
26-
:check="check"
26+
:operator="check.operator"
2727
:model-value="check.value"
2828
class="option"
2929
@update:model-value="updateCheck"
@@ -166,7 +166,8 @@ export default {
166166
this.$emit('validate', this.valid)
167167
},
168168
updateCheck(event) {
169-
const matchingOperator = this.operators.findIndex((operator) => this.check.operator === operator.operator)
169+
const selectedOperator = event?.operator || this.currentOperator?.operator || this.check.operator
170+
const matchingOperator = this.operators.findIndex((operator) => selectedOperator === operator.operator)
170171
if (this.check.class !== this.currentOption.class || matchingOperator === -1) {
171172
this.currentOperator = this.operators[0]
172173
}

apps/workflowengine/src/components/Checks/RequestURL.vue

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<template>
66
<div>
77
<NcSelect :value="currentValue"
8+
v-model="newValue"
89
:placeholder="t('workflowengine', 'Select a request URL')"
910
label="label"
1011
:clearable="false"
@@ -45,6 +46,9 @@ export default {
4546
mixins: [
4647
valueMixin,
4748
],
49+
50+
emits: ['update:model-value'],
51+
4852
data() {
4953
return {
5054
newValue: '',
@@ -57,12 +61,22 @@ export default {
5761
],
5862
}
5963
},
64+
props: {
65+
modelValue: {
66+
type: String,
67+
default: '',
68+
},
69+
operator: {
70+
type: String,
71+
default: '',
72+
},
73+
},
6074
computed: {
6175
options() {
6276
return [...this.predefinedTypes, this.customValue]
6377
},
6478
placeholder() {
65-
if (this.check.operator === 'matches' || this.check.operator === '!matches') {
79+
if (this.operator === 'matches' || this.operator === '!matches') {
6680
return '/^https\\:\\/\\/localhost\\/index\\.php$/i'
6781
}
6882
return 'https://localhost/index.php'
@@ -102,12 +116,12 @@ export default {
102116
// TODO: check if value requires a regex and set the check operator according to that
103117
if (value !== null) {
104118
this.newValue = value.id
105-
this.$emit('input', this.newValue)
119+
this.$emit('update:model-value', this.newValue)
106120
}
107121
},
108122
updateCustom(event) {
109123
this.newValue = event.target.value
110-
this.$emit('input', this.newValue)
124+
this.$emit('update:model-value', this.newValue)
111125
},
112126
},
113127
}

apps/workflowengine/src/components/Checks/request.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

6+
import { registerCustomElement } from '../../helpers/window.js'
67
import RequestUserAgent from './RequestUserAgent.vue'
78
import RequestTime from './RequestTime.vue'
89
import RequestURL from './RequestURL.vue'
@@ -18,7 +19,7 @@ const RequestChecks = [
1819
{ operator: 'matches', name: t('workflowengine', 'matches') },
1920
{ operator: '!matches', name: t('workflowengine', 'does not match') },
2021
],
21-
component: RequestURL,
22+
element: registerCustomElement(RequestURL, 'oca-workflowengine-checks-request_url'),
2223
},
2324
{
2425
class: 'OCA\\WorkflowEngine\\Check\\RequestTime',

0 commit comments

Comments
 (0)