diff options
author | Julius Härtl <jus@bitgrid.net> | 2019-08-29 16:50:33 +0200 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2019-09-10 09:01:23 +0200 |
commit | bd281daa47152dc09c0f6c2bbc9e5a308d1748bd (patch) | |
tree | 73227cf96161871a259688624b5d4f78637fc3d6 /apps/workflowengine/src/components/Check.vue | |
parent | aa00f401b39c2b63cba7e5e8f6cdec8528466069 (diff) | |
download | nextcloud-server-bd281daa47152dc09c0f6c2bbc9e5a308d1748bd.tar.gz nextcloud-server-bd281daa47152dc09c0f6c2bbc9e5a308d1748bd.zip |
Move to vuex store
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'apps/workflowengine/src/components/Check.vue')
-rw-r--r-- | apps/workflowengine/src/components/Check.vue | 134 |
1 files changed, 65 insertions, 69 deletions
diff --git a/apps/workflowengine/src/components/Check.vue b/apps/workflowengine/src/components/Check.vue index 86005dae268..b2e8e13c29b 100644 --- a/apps/workflowengine/src/components/Check.vue +++ b/apps/workflowengine/src/components/Check.vue @@ -1,86 +1,82 @@ <template> - <div class="check" @click="showDelete" v-click-outside="hideDelete"> - <Multiselect v-model="currentOption" :options="options" label="name" - track-by="class" :allow-empty="false" :placeholder="t('workflowengine', 'Select a filter')" - @input="updateCheck" ref="checkSelector"></Multiselect> - <Multiselect v-if="currentOption" v-model="currentOperator" @input="updateCheck" - :options="operators" label="name" track-by="operator" - :allow-empty="false" :placeholder="t('workflowengine', 'Select a comparator')"></Multiselect> - <component v-if="currentOperator && currentComponent" :is="currentOption.component()" v-model="check.value" /> - <input v-else-if="currentOperator" type="text" v-model="check.value" @input="updateCheck" /> + <div v-click-outside="hideDelete" class="check" @click="showDelete"> + <Multiselect ref="checkSelector" v-model="currentOption" :options="options" + label="name" track-by="class" :allow-empty="false" + :placeholder="t('workflowengine', 'Select a filter')" @input="updateCheck" /> + <Multiselect v-if="currentOption" v-model="currentOperator" :options="operators" + label="name" track-by="operator" :allow-empty="false" + :placeholder="t('workflowengine', 'Select a comparator')" @input="updateCheck" /> + <component :is="currentOption.component()" v-if="currentOperator && currentComponent" v-model="check.value" /> + <input v-else-if="currentOperator" v-model="check.value" type="text" + @input="updateCheck"> <Actions> - <ActionButton icon="icon-delete" v-if="deleteVisible || !currentOption" @click="$emit('remove')" /> + <ActionButton v-if="deleteVisible || !currentOption" icon="icon-delete" @click="$emit('remove')" /> </Actions> </div> </template> <script> - import { Checks } from '../services/Operation'; - import { Multiselect, Actions, ActionButton } from 'nextcloud-vue' - import ClickOutside from 'vue-click-outside'; +import { Checks } from '../services/Operation' +import { Multiselect, Actions, ActionButton } from 'nextcloud-vue' +import ClickOutside from 'vue-click-outside' - export default { - name: 'Check', - components: { - ActionButton, - Actions, - Multiselect - }, - directives: { - ClickOutside - }, - props: { - check: { - type: Object, - required: true - } - }, - data() { - return { - deleteVisible: false, - currentOption: null, - currentOperator: null, - options: [], - } +export default { + name: 'Check', + components: { + ActionButton, + Actions, + Multiselect + }, + directives: { + ClickOutside + }, + props: { + check: { + type: Object, + required: true + } + }, + data() { + return { + deleteVisible: false, + currentOption: null, + currentOperator: null, + options: [] + } + }, + computed: { + operators() { + if (!this.currentOption) { return [] } + return Checks[this.currentOption.class].operators }, - mounted() { - this.options = Object.values(Checks) - this.currentOption = Checks[this.check.class] - this.currentOperator = this.operators.find((operator) => operator.operator === this.check.operator) - this.$nextTick(() => { - //this.$refs.checkSelector.$el.focus() - }) + currentComponent() { + if (!this.currentOption) { return [] } + const currentComponent = Checks[this.currentOption.class].component + return currentComponent && currentComponent() + } + }, + mounted() { + this.options = Object.values(Checks) + this.currentOption = Checks[this.check.class] + this.currentOperator = this.operators.find((operator) => operator.operator === this.check.operator) + }, + methods: { + showDelete() { + this.deleteVisible = true }, - computed: { - operators() { - if (!this.currentOption) - return [] - return Checks[this.currentOption.class].operators - }, - currentComponent() { - if (!this.currentOption) - return [] - let currentComponent = Checks[this.currentOption.class].component - return currentComponent && currentComponent() - } + hideDelete() { + this.deleteVisible = false }, - methods: { - showDelete() { - this.deleteVisible = true - }, - hideDelete() { - this.deleteVisible = false - }, - updateCheck() { - if (this.check.class !== this.currentOption.class) { - this.currentOperator = this.operators[0] - } - this.check.class = this.currentOption.class - this.check.operator = this.currentOperator.operator - this.$emit('update', this.check) + updateCheck() { + if (this.check.class !== this.currentOption.class) { + this.currentOperator = this.operators[0] } + this.check.class = this.currentOption.class + this.check.operator = this.currentOperator.operator + this.$emit('update', this.check) } } +} </script> <style scoped lang="scss"> |