Skip to content

Commit

Permalink
fix(forms): number values in map fields (#1809)
Browse files Browse the repository at this point in the history
* fix(forms): number values in map fields

* fix(*): address feedback

* fix(*): address feedback
  • Loading branch information
Leopoldthecoder authored Nov 26, 2024
1 parent 4b12af4 commit 81f8cc6
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
v-model="value[index]"
class="form-control"
:placeholder="schema.fields && schema.fields[0].schema.placeholder"
type="text"
:type="valueInputType"
@input="updateModel(value[index], model[schema.model])"
>
<p
Expand Down Expand Up @@ -134,6 +134,9 @@ export default {
return this.model[this.schema.model]
},
valueInputType() {
return ['number', 'integer'].includes(this.schema.values?.type) ? 'number' : 'text'
},
},
mounted() {
if (!this.value) this.value = {}
Expand Down Expand Up @@ -216,9 +219,12 @@ export default {
Array.isArray(this.subSchema.fields) &&
this.subSchema.fields.length === 1 &&
this.subSchema.fields[0].type === 'array'
const type = this.subSchema ? valueIsArray ? [''] : {} : ''
const defaultValue = this.schema.values?.default ?? (this.valueInputType === 'number' ? 0 : '')
const initialValue = this.subSchema
? (valueIsArray ? [''] : {})
: defaultValue
this.value[this.newKeyName] = type
this.value[this.newKeyName] = initialValue
this.newKeyName = ''
},
Expand Down

0 comments on commit 81f8cc6

Please sign in to comment.