Fix logic for multi select (#6)

* Fix logic for multi select

* test case for multi select logic
This commit is contained in:
Chirag
2022-10-03 00:10:10 +05:30
committed by GitHub
parent ef70be9d14
commit 610c71cb69
6 changed files with 124 additions and 28 deletions

View File

@@ -58,7 +58,7 @@ export default {
}
if (['select', 'multi_select'].includes(this.property.type)) {
componentData.multiple = (this.property.type == 'multi_select')
componentData.multiple = false;
componentData.options = this.property[this.property.type].options.map(option => {
return {
name: option.name,

View File

@@ -1,16 +1,16 @@
<template>
<div class="flex px-4 py-1">
<select-input ref="ruleSelect" v-model="selectedRule" class="flex-grow mr-1"
<div class="flex flex-wrap px-4 py-1 -ml-1 -mt-1">
<select-input ref="ruleSelect" v-model="selectedRule" class="flex-grow ml-1 mr-1 mt-1"
wrapper-class="relative" placeholder="Add condition on input field"
:options="groupCtrl.rules" margin-bottom=""
emit-key="identifier"
option-key="identifier"
name="group-control-slot-rule"
/>
<v-button class="ml-1" color="blue" size="small" :disabled="selectedRule === ''" @click="addRule">
<v-button class="ml-1 mt-1" color="blue" size="small" :disabled="selectedRule === ''" @click="addRule">
Add Condition
</v-button>
<v-button class="ml-1" color="green" size="small" @click="groupCtrl.newGroup">
<v-button class="ml-1 mt-1" color="green" size="small" @click="groupCtrl.newGroup">
Add Group
</v-button>
</div>

View File

@@ -64,7 +64,13 @@ function checkContains (condition, fieldValue) {
}
function checkListContains (condition, fieldValue) {
return (fieldValue && fieldValue.length > 0) ? condition.value.every(r => fieldValue.includes(r)) : false
if (!fieldValue) return false
if (Array.isArray(condition.value)) {
return condition.value.every(r => fieldValue.includes(r))
} else {
return fieldValue.includes(condition.value)
}
}
function checkStartsWith (condition, fieldValue) {