Make sure form correctly validates after CLIN is removed

This commit is contained in:
leigh-mil 2019-09-04 13:57:08 -04:00
parent 27d3f46cc9
commit f5ce35187b
2 changed files with 11 additions and 5 deletions

View File

@ -78,7 +78,7 @@ export default {
})
emitEvent('field-mount', this, {
optional: false,
name: POP + "-" + this.clinIndex,
name: 'clins-' + this.clinIndex + '-' + POP,
valid: this.checkPopValid(),
})
},
@ -104,7 +104,7 @@ export default {
}
emitEvent('field-change', this, {
name: POP + "-" + this.clinIndex,
name: 'clins-' + this.clinIndex + '-' + POP,
valid: this.checkPopValid(),
})
},

View File

@ -42,8 +42,8 @@ export default {
},
data: function() {
const clins = this.initialClinCount == 0 ? 1 : 0
const clinIndex = this.initialClinCount == 0 ? 0 : this.initialClinCount - 1
const clins = !this.initialClinCount ? 1 : 0
const clinIndex = !this.initialClinCount ? 0 : this.initialClinCount - 1
return {
clins,
@ -67,7 +67,13 @@ export default {
handleRemoveClin: function(event) {
--this.clinIndex
console.log('removed clin')
for (var field in this.fields) {
if (field.includes('-' + event.clinIndex + '-')) {
delete this.fields[field]
}
}
this.validateForm()
},
calculateClinAmounts: function(event) {