3
0

Fix multi value field changes not re-evaluating conditional fields

This commit is contained in:
Jože Fortun 2024-12-06 15:16:48 +01:00
parent fffbca5df4
commit a0e03e19ac
10 changed files with 38 additions and 12 deletions

View File

@ -40,7 +40,7 @@
:errors="errors" :errors="errors"
> >
<c-input-date-time <c-input-date-time
v-model="value[ctx.index]" :value="value[ctx.index]"
:no-date="field.options.onlyTime" :no-date="field.options.onlyTime"
:no-time="field.options.onlyDate" :no-time="field.options.onlyDate"
:only-future="field.options.onlyFutureValues" :only-future="field.options.onlyFutureValues"
@ -51,6 +51,7 @@
now: $t('general:label.now'), now: $t('general:label.now'),
today: $t('general:label.today'), today: $t('general:label.today'),
}" }"
@input="setMultiValue($event, ctx.index)"
/> />
</multi> </multi>

View File

@ -40,9 +40,10 @@
:errors="errors" :errors="errors"
> >
<b-form-input <b-form-input
v-model="value[ctx.index]" :value="value[ctx.index]"
type="email" type="email"
class="mr-2" class="mr-2"
@input="setMultiValue($event, ctx.index)"
/> />
</multi> </multi>

View File

@ -44,11 +44,12 @@
:append="field.options.suffix" :append="field.options.suffix"
> >
<b-form-input <b-form-input
v-model="value[ctx.index]" :value="value[ctx.index]"
autocomplete="off" autocomplete="off"
type="number" type="number"
number number
class="mr-2" class="mr-2"
@input="setMultiValue($event, ctx.index)"
/> />
</b-input-group> </b-input-group>
</multi> </multi>

View File

@ -101,7 +101,6 @@
:get-option-label="getOptionLabel" :get-option-label="getOptionLabel"
:disabled="!module" :disabled="!module"
:loading="processing" :loading="processing"
:clearable="false"
:filterable="false" :filterable="false"
:searchable="searchable" :searchable="searchable"
:selectable="isSelectable" :selectable="isSelectable"
@ -338,6 +337,8 @@ export default {
} }
} }
} }
this.$emit('change', this.value)
}, },
isSelectable ({ recordID } = {}) { isSelectable ({ recordID } = {}) {
@ -510,6 +511,8 @@ export default {
if (this.$refs.singleSelect) { if (this.$refs.singleSelect) {
this.$refs.singleSelect._data._value = undefined this.$refs.singleSelect._data._value = undefined
} }
this.$emit('change', this.value)
}, },
goToPage (next = true) { goToPage (next = true) {

View File

@ -76,12 +76,13 @@
<template #default="ctx"> <template #default="ctx">
<c-input-select <c-input-select
v-if="field.options.selectType === 'each'" v-if="field.options.selectType === 'each'"
v-model="value[ctx.index]" :value="value[ctx.index]"
:options="selectOptions" :options="selectOptions"
:reduce="o => o.value" :reduce="o => o.value"
:placeholder="$t('kind.select.placeholder')" :placeholder="$t('kind.select.placeholder')"
:selectable="isSelectable" :selectable="isSelectable"
label="text" label="text"
@input="setMultiValue($event, ctx.index)"
/> />
<span v-else>{{ findLabel(value[ctx.index]) }}</span> <span v-else>{{ findLabel(value[ctx.index]) }}</span>

View File

@ -42,20 +42,23 @@
> >
<c-rich-text-input <c-rich-text-input
v-if="field.options.useRichTextEditor" v-if="field.options.useRichTextEditor"
v-model="value[ctx.index]" :value="value[ctx.index]"
class="mr-2" class="mr-2"
@input="setMultiValue($event, ctx.index)"
/> />
<b-form-textarea <b-form-textarea
v-else-if="field.options.multiLine" v-else-if="field.options.multiLine"
v-model="value[ctx.index]" :value="value[ctx.index]"
class="mr-2" class="mr-2"
@input="setMultiValue($event, ctx.index)"
/> />
<b-form-input <b-form-input
v-else v-else
v-model="value[ctx.index]" :value="value[ctx.index]"
class="mr-2" class="mr-2"
@input="setMultiValue($event, ctx.index)"
/> />
</multi> </multi>

View File

@ -39,12 +39,13 @@
:errors="errors" :errors="errors"
> >
<b-form-input <b-form-input
v-model="value[ctx.index]" :value="value[ctx.index]"
type="url" type="url"
class="mr-2" class="mr-2"
:placeholder="$t('kind.url.example')" :placeholder="$t('kind.url.example')"
:formatter="fixUrl" :formatter="fixUrl"
lazy-formatter lazy-formatter
@input="setMultiValue($event, ctx.index)"
/> />
</multi> </multi>
<template <template

View File

@ -323,6 +323,8 @@ export default {
this.value = undefined this.value = undefined
} }
} }
this.$emit('change', this.value)
}, },
/** /**

View File

@ -145,6 +145,12 @@ export default {
getFieldCypressId (field) { getFieldCypressId (field) {
return `field-${field.toLowerCase().split(' ').join('-')}` return `field-${field.toLowerCase().split(' ').join('-')}`
}, },
setMultiValue (value, index) {
this.$set(this.value, index, value)
this.$emit('change', this.value)
},
}, },
} }
</script> </script>

View File

@ -15,7 +15,7 @@
<div <div
v-for="(v, index) of val" v-for="(v, index) of val"
:key="index" :key="index"
class="d-flex w-100 align-items-center mb-1" class="d-flex w-100 align-items-center mb-1 px-2"
> >
<font-awesome-icon <font-awesome-icon
v-b-tooltip.noninteractive.hover="{ title: $t('tooltip.dragAndDrop'), container: '#body' }" v-b-tooltip.noninteractive.hover="{ title: $t('tooltip.dragAndDrop'), container: '#body' }"
@ -47,7 +47,7 @@
variant="primary" variant="primary"
size="sm" size="sm"
:class="{ 'mt-2': val.length }" :class="{ 'mt-2': val.length }"
@click="val.push(defaultValue)" @click="addValue()"
> >
+ {{ $t('label.addValue') }} + {{ $t('label.addValue') }}
</b-button> </b-button>
@ -114,13 +114,20 @@ export default {
}, },
methods: { methods: {
addValue () {
this.val.push(this.defaultValue)
this.$emit('update:value', this.val)
},
removeValue (index) { removeValue (index) {
if (index > -1) { if (index > -1) {
this.val.splice(index, 1) this.val.splice(index, 1)
} }
this.$emit('update:value', this.val)
}, },
}, },
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>