diff --git a/js/components/clin_fields.js b/js/components/clin_fields.js index 56223b54..a7f646eb 100644 --- a/js/components/clin_fields.js +++ b/js/components/clin_fields.js @@ -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(), }) }, diff --git a/js/components/forms/to_form.js b/js/components/forms/to_form.js index d8d6eae7..1118f8e7 100644 --- a/js/components/forms/to_form.js +++ b/js/components/forms/to_form.js @@ -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) {