add 2 options by default
This commit is contained in:
@@ -192,7 +192,7 @@
|
|||||||
v-else-if="(field.type === 'radio' || field.type === 'multiple') && field?.areas?.length > 1"
|
v-else-if="(field.type === 'radio' || field.type === 'multiple') && field?.areas?.length > 1"
|
||||||
>
|
>
|
||||||
<IconCheck
|
<IconCheck
|
||||||
v-if="field.type === 'multiple' ? field.default_value.includes(optionsUuidIndex[area.option_uuid].value) : optionsUuidIndex[area.option_uuid].value === field.default_value"
|
v-if="field.type === 'multiple' ? field.default_value.includes(buildAreaOptionValue(area)) : buildAreaOptionValue(area) === field.default_value"
|
||||||
class="aspect-square mx-auto"
|
class="aspect-square mx-auto"
|
||||||
:class="{ '!w-auto !h-full': area.w > area.h, '!w-full !h-auto': area.w <= area.h }"
|
:class="{ '!w-auto !h-full': area.w > area.h, '!w-full !h-auto': area.w <= area.h }"
|
||||||
/>
|
/>
|
||||||
@@ -596,6 +596,11 @@ export default {
|
|||||||
closeDropdown () {
|
closeDropdown () {
|
||||||
this.$el.getRootNode().activeElement.blur()
|
this.$el.getRootNode().activeElement.blur()
|
||||||
},
|
},
|
||||||
|
buildAreaOptionValue (area) {
|
||||||
|
const option = this.optionsUuidIndex[area.option_uuid]
|
||||||
|
|
||||||
|
return option.value || `${this.t('option')} ${this.field.options.indexOf(option) + 1}`
|
||||||
|
},
|
||||||
maybeToggleDefaultValue () {
|
maybeToggleDefaultValue () {
|
||||||
if (!this.editable) {
|
if (!this.editable) {
|
||||||
return
|
return
|
||||||
@@ -621,9 +626,7 @@ export default {
|
|||||||
|
|
||||||
this.save()
|
this.save()
|
||||||
} else if (this.field.type === 'radio' && this.area.option_uuid) {
|
} else if (this.field.type === 'radio' && this.area.option_uuid) {
|
||||||
const option = this.optionsUuidIndex[this.area.option_uuid]
|
const value = this.buildAreaOptionValue(this.area)
|
||||||
|
|
||||||
const value = option.value || `${this.t('option')} ${this.field.options.indexOf(option) + 1}`
|
|
||||||
|
|
||||||
this.field.default_value === value ? delete this.field.default_value : this.field.default_value = value
|
this.field.default_value === value ? delete this.field.default_value : this.field.default_value = value
|
||||||
|
|
||||||
@@ -631,9 +634,7 @@ export default {
|
|||||||
|
|
||||||
this.save()
|
this.save()
|
||||||
} else if (this.field.type === 'multiple' && this.area.option_uuid) {
|
} else if (this.field.type === 'multiple' && this.area.option_uuid) {
|
||||||
const option = this.optionsUuidIndex[this.area.option_uuid]
|
const value = this.buildAreaOptionValue(this.area)
|
||||||
|
|
||||||
const value = option.value || `${this.t('option')} ${this.field.options.indexOf(option) + 1}`
|
|
||||||
|
|
||||||
if (this.field.default_value?.includes(value)) {
|
if (this.field.default_value?.includes(value)) {
|
||||||
this.field.default_value.splice(this.field.default_value.indexOf(value), 1)
|
this.field.default_value.splice(this.field.default_value.indexOf(value), 1)
|
||||||
|
|||||||
@@ -1065,7 +1065,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (['select', 'multiple', 'radio'].includes(type)) {
|
if (['select', 'multiple', 'radio'].includes(type)) {
|
||||||
field.options = [{ value: '', uuid: v4() }]
|
field.options = [{ value: '', uuid: v4() }, { value: '', uuid: v4() }]
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === 'stamp') {
|
if (type === 'stamp') {
|
||||||
@@ -1109,7 +1109,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (['select', 'multiple', 'radio'].includes(type)) {
|
if (['select', 'multiple', 'radio'].includes(type)) {
|
||||||
field.options = [{ value: '', uuid: v4() }]
|
field.options = [{ value: '', uuid: v4() }, { value: '', uuid: v4() }]
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === 'stamp') {
|
if (type === 'stamp') {
|
||||||
@@ -1477,7 +1477,7 @@ export default {
|
|||||||
if (this.dragField?.options?.length) {
|
if (this.dragField?.options?.length) {
|
||||||
field.options = this.dragField.options.map(option => ({ value: option, uuid: v4() }))
|
field.options = this.dragField.options.map(option => ({ value: option, uuid: v4() }))
|
||||||
} else {
|
} else {
|
||||||
field.options = [{ value: '', uuid: v4() }]
|
field.options = [{ value: '', uuid: v4() }, { value: '', uuid: v4() }]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user