@ -19,8 +19,18 @@
: clearable = "false"
: placeholder = "t('workflowengine', 'Select a comparator')"
@ input = "updateCheck" / >
< component :is ="currentElement"
v - if = "currentElement"
ref = "checkComponent"
: disabled = "!currentOption"
: check = "check"
: model - value = "check.value"
class = "option"
@ update : model - value = "updateCheck"
@ valid = "(valid=true) && validate()"
@ invalid = "!(valid=false) && validate()" / >
< component :is ="currentOption.component"
v - if = "currentOperator && currentComponent"
v - else- if= "currentOperator && currentComponent"
v - model = "check.value"
: disabled = "!currentOption"
: check = "check"
@ -52,7 +62,6 @@ import NcActionButton from '@nextcloud/vue/components/NcActionButton'
import NcSelect from '@nextcloud/vue/components/NcSelect'
import CloseIcon from 'vue-material-design-icons/Close.vue'
import ClickOutside from 'vue-click-outside'
export default {
@ -99,6 +108,12 @@ export default {
}
return operators
} ,
currentElement ( ) {
if ( ! this . check . class ) {
return false
}
return this . checks [ this . check . class ] . element
} ,
currentComponent ( ) {
if ( ! this . currentOption ) { return [ ] }
return this . checks [ this . currentOption . class ] . component
@ -120,6 +135,15 @@ export default {
this . currentOption = this . checks [ this . check . class ]
this . currentOperator = this . operators . find ( ( operator ) => operator . operator === this . check . operator )
if ( this . currentElement ) {
console . error ( this . $refs )
this . $refs . checkComponent . value = this . currentOption
} else if ( this . currentOption ? . component ) {
/ / k e e p i n g t h i s i n a n e l s e f o r a p p s t h a t t r y t o b e b a c k w a r d s c o m p a t i b l e a n d m a y s h i p b o t h
/ / t o b e r e m o v e d i n 0 3 / 2 0 2 8
console . warn ( 'Developer warning: `CheckPlugin.options` is deprecated. Use `CheckPlugin.element` instead.' )
}
if ( this . check . class === null ) {
this . $nextTick ( ( ) => this . $refs . checkSelector . $el . focus ( ) )
}
@ -141,11 +165,14 @@ export default {
this . check . invalid = ! this . valid
this . $emit ( 'validate' , this . valid )
} ,
updateCheck ( ) {
updateCheck ( event ) {
const matchingOperator = this . operators . findIndex ( ( operator ) => this . check . operator === operator . operator )
if ( this . check . class !== this . currentOption . class || matchingOperator === - 1 ) {
this . currentOperator = this . operators [ 0 ]
}
if ( event ? . detail ) {
this . check . value = event . detail [ 0 ]
}
/ / e s l i n t - d i s a b l e - n e x t - l i n e v u e / n o - m u t a t i n g - p r o p s
this . check . class = this . currentOption . class
/ / e s l i n t - d i s a b l e - n e x t - l i n e v u e / n o - m u t a t i n g - p r o p s