Make remove CLIN button work

This commit is contained in:
leigh-mil 2019-09-04 13:32:01 -04:00
parent 6f1f7f0d3d
commit 27d3f46cc9
3 changed files with 17 additions and 9 deletions

View File

@ -62,6 +62,7 @@ export default {
popValid: popValidation, popValid: popValidation,
showPopError: showPopValidation, showPopError: showPopValidation,
clinNumber: clinNumber, clinNumber: clinNumber,
showClin: true,
} }
}, },
@ -77,7 +78,7 @@ export default {
}) })
emitEvent('field-mount', this, { emitEvent('field-mount', this, {
optional: false, optional: false,
name: POP, name: POP + "-" + this.clinIndex,
valid: this.checkPopValid(), valid: this.checkPopValid(),
}) })
}, },
@ -103,7 +104,7 @@ export default {
} }
emitEvent('field-change', this, { emitEvent('field-change', this, {
name: POP, name: POP + "-" + this.clinIndex,
valid: this.checkPopValid(), valid: this.checkPopValid(),
}) })
}, },
@ -127,6 +128,13 @@ export default {
} }
} }
}, },
removeClin: function() {
this.showClin = false
emitEvent('remove-clin', this, {
clinIndex: this.clinIndex,
})
},
}, },
computed: { computed: {

View File

@ -56,6 +56,7 @@ export default {
mounted: function() { mounted: function() {
this.$root.$on('clin-change', this.calculateClinAmounts) this.$root.$on('clin-change', this.calculateClinAmounts)
this.$root.$on('remove-clin', this.handleRemoveClin)
}, },
methods: { methods: {
@ -64,10 +65,9 @@ export default {
++this.clinIndex ++this.clinIndex
}, },
removeClin: function(clinIndex) { handleRemoveClin: function(event) {
if (this.clins > 0) { --this.clinIndex
console.log('removed CLIN') console.log('removed clin')
}
}, },
calculateClinAmounts: function(event) { calculateClinAmounts: function(event) {

View File

@ -26,13 +26,13 @@
v-bind:initial-clin-type="'JEDI_CLIN_1'" v-bind:initial-clin-type="'JEDI_CLIN_1'"
{% endif %} {% endif %}
inline-template> inline-template>
<div class="clin-card"> <div class="clin-card" v-if="showClin">
<div class="card__title"> <div class="card__title">
<span class="h4" v-html='clinTitle'></span> <span class="h4" v-html='clinTitle'></span>
<button <button
v-if='$parent.clins > 0' v-if='$parent.clinIndex > 0'
class="icon-link icon-link__remove-clin" class="icon-link icon-link__remove-clin"
v-on:click="$parent.removeClin(clinIndex)" v-on:click="removeClin()"
type="button"> type="button">
{{ Icon(name='x') }} {{ Icon(name='x') }}
</button> </button>