diff --git a/app/javascript/template_builder/area.vue b/app/javascript/template_builder/area.vue index 8d003e95..889a597d 100644 --- a/app/javascript/template_builder/area.vue +++ b/app/javascript/template_builder/area.vue @@ -192,7 +192,7 @@ v-else-if="(field.type === 'radio' || field.type === 'multiple') && field?.areas?.length > 1" > @@ -596,6 +596,11 @@ export default { closeDropdown () { 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 () { if (!this.editable) { return @@ -621,9 +626,7 @@ export default { this.save() } else if (this.field.type === 'radio' && this.area.option_uuid) { - const option = this.optionsUuidIndex[this.area.option_uuid] - - const value = option.value || `${this.t('option')} ${this.field.options.indexOf(option) + 1}` + const value = this.buildAreaOptionValue(this.area) this.field.default_value === value ? delete this.field.default_value : this.field.default_value = value @@ -631,9 +634,7 @@ export default { this.save() } else if (this.field.type === 'multiple' && this.area.option_uuid) { - const option = this.optionsUuidIndex[this.area.option_uuid] - - const value = option.value || `${this.t('option')} ${this.field.options.indexOf(option) + 1}` + const value = this.buildAreaOptionValue(this.area) if (this.field.default_value?.includes(value)) { this.field.default_value.splice(this.field.default_value.indexOf(value), 1) diff --git a/app/javascript/template_builder/builder.vue b/app/javascript/template_builder/builder.vue index ad295068..bf01ca31 100644 --- a/app/javascript/template_builder/builder.vue +++ b/app/javascript/template_builder/builder.vue @@ -1065,7 +1065,7 @@ export default { } if (['select', 'multiple', 'radio'].includes(type)) { - field.options = [{ value: '', uuid: v4() }] + field.options = [{ value: '', uuid: v4() }, { value: '', uuid: v4() }] } if (type === 'stamp') { @@ -1109,7 +1109,7 @@ export default { } if (['select', 'multiple', 'radio'].includes(type)) { - field.options = [{ value: '', uuid: v4() }] + field.options = [{ value: '', uuid: v4() }, { value: '', uuid: v4() }] } if (type === 'stamp') { @@ -1477,7 +1477,7 @@ export default { if (this.dragField?.options?.length) { field.options = this.dragField.options.map(option => ({ value: option, uuid: v4() })) } else { - field.options = [{ value: '', uuid: v4() }] + field.options = [{ value: '', uuid: v4() }, { value: '', uuid: v4() }] } }