3
0

Add clearer add option to select module field configurator

This commit is contained in:
Kelani Tolulope
2023-04-17 14:09:40 +01:00
parent 4331401e44
commit fabb719163
2 changed files with 18 additions and 36 deletions

View File

@@ -42,39 +42,18 @@
</b-button>
</b-input-group-append>
</b-input-group>
<b-input-group>
<b-form-input
v-model.trim="newOption.value"
plain
size="sm"
:placeholder="$t('kind.select.optionValuePlaceholder')"
:state="newOptState"
@keypress.enter.prevent="handleAddOption"
/>
<b-form-input
v-model.trim="newOption.text"
plain
size="sm"
:placeholder="$t('kind.select.optionLabelPlaceholder')"
:state="newOptState"
@keypress.enter.prevent="handleAddOption"
/>
<b-input-group-append>
<b-button
variant="primary"
size="sm"
:disabled="newOptState === false || newEmpty"
@click.prevent="handleAddOption"
>
+ {{ $t('kind.select.optionAdd') }}
</b-button>
</b-input-group-append>
</b-input-group>
</b-form-group>
<div class="my-2">
<b-button
variant="primary px-3"
size="md"
@click.prevent="handleAddOption"
>
+ {{ $t('kind.select.optionAdd') }}
</b-button>
</div>
<b-form-group
v-if="f.isMulti"
>
@@ -162,10 +141,11 @@ export default {
methods: {
handleAddOption () {
if (this.newOption.value) {
this.f.options.options.push(this.newOption)
this.newOption = { value: undefined, text: undefined, new: true }
}
this.f.options.options.push({
value: undefined,
text: undefined,
new: true,
})
},
onUpdateIsUniqueMultiValue () {

View File

@@ -113,7 +113,9 @@ export default {
? this.value === o.value
: (this.value || []).includes(o.value)
return { ...o, disabled }
}).filter(({ value = '' }) => value)
}).filter(({ value = '', text = '' }) => {
return value !== '' || text !== ''
})
},
},