From 80f028540cf47d87d72a82335ed3adefdcdf09b1 Mon Sep 17 00:00:00 2001 From: graham-dds Date: Wed, 11 Dec 2019 15:51:55 -0500 Subject: [PATCH] Refactor multi_checkbox_input This component was made when having an "other" value as a check option also meant typing in a custom value into an input field. Since this is no longer needed, we were able to remove the markup / vue code for that feature. --- js/components/multi_checkbox_input.js | 22 +++++-------------- .../components/multi_checkbox_input.html | 11 ---------- 2 files changed, 6 insertions(+), 27 deletions(-) diff --git a/js/components/multi_checkbox_input.js b/js/components/multi_checkbox_input.js index fdba839f..f2d878da 100644 --- a/js/components/multi_checkbox_input.js +++ b/js/components/multi_checkbox_input.js @@ -13,22 +13,14 @@ export default { type: Array, default: () => [], }, - initialOtherValue: String, optional: Boolean, }, data: function() { - const showError = (this.initialErrors && this.initialErrors.length) || false return { - showError: showError, - showValid: !showError && this.initialValue.length > 0, + showError: this.initialErrors.length > 0, + showValid: false, validationError: this.initialErrors.join(' '), - otherChecked: this.initialValue.includes('other') - ? true - : this.otherChecked, - otherText: this.initialValue.includes('other') - ? this.initialOtherValue - : '', selections: this.initialValue, } }, @@ -36,17 +28,15 @@ export default { methods: { onInput: function(e) { emitFieldChange(this) - this.showError = false - this.showValid = true - }, - otherToggle: function() { - this.otherChecked = !this.otherChecked + this.showError = !this.valid + this.showValid = !this.showError + this.validationError = 'This field is required.' }, }, computed: { valid: function() { - return this.optional || this.showValid + return this.optional || this.selections.length > 0 }, }, } diff --git a/templates/components/multi_checkbox_input.html b/templates/components/multi_checkbox_input.html index 2f2c65ec..6de6331b 100644 --- a/templates/components/multi_checkbox_input.html +++ b/templates/components/multi_checkbox_input.html @@ -45,19 +45,8 @@