From 2d20d27d0185ad8dc9ecc6270e65237fa614f052 Mon Sep 17 00:00:00 2001 From: leigh-mil Date: Fri, 2 Aug 2019 14:54:44 -0400 Subject: [PATCH] Add POP as field on the form vue component so whether or not it is valid can be tracked to toggle the save button --- js/components/clin_fields.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/js/components/clin_fields.js b/js/components/clin_fields.js index a670bb23..b18cd3fd 100644 --- a/js/components/clin_fields.js +++ b/js/components/clin_fields.js @@ -7,6 +7,7 @@ const JEDI_CLIN_TYPE = 'jedi_clin_type' const OBLIGATED_AMOUNT = 'obligated_amount' const START_DATE = 'start_date' const END_DATE = 'end_date' +const POP = 'period_of_performance' export default { name: 'clin-fields', @@ -69,6 +70,11 @@ export default { clinType: this.clinType, amount: this.initialAmount, }) + emitEvent('field-mount', this, { + optional: false, + name: POP, + valid: this.checkPopValid(), + }) }, methods: { @@ -92,6 +98,15 @@ export default { return this.startDate < this.endDate }, + validatePop: function() { + this.popValid = this.checkPopValid() + this.showPopError = !this.popValid + emitEvent('field-change', this, { + name: POP, + valid: this.checkPopValid(), + }) + }, + handleFieldChange: function(event) { if (this._uid === event.parent_uid) { if (event.name.includes(JEDI_CLIN_TYPE)) { @@ -102,12 +117,10 @@ export default { this.clinChangeEvent() } else if (event.name.includes(START_DATE)) { this.startDate = new Date(event.value) - this.popValid = this.checkPopValid() - this.showPopError = !this.popValid + this.validatePop() } else if (event.name.includes(END_DATE)) { this.endDate = new Date(event.value) - this.popValid = this.checkPopValid() - this.showPopError = !this.popValid + this.validatePop() } } },