diff --git a/js/components/multi_checkbox_input.js b/js/components/multi_checkbox_input.js index 7c0b822c..49fa1f07 100644 --- a/js/components/multi_checkbox_input.js +++ b/js/components/multi_checkbox_input.js @@ -1,4 +1,3 @@ -import otherinput from '../components/other_input' import optionsinput from '../components/options_input' import textinput from '../components/text_input' @@ -26,20 +25,14 @@ export default { data: function () { - const showError = (this.initialErrors && this.initialErrors.length) || false + const showError = (this.initialErrors && this.initialValue.length > 0) || false return { showError: showError, showValid: !showError && !!this.initialValue, validationError: this.initialErrors.join(' '), otherChecked: this.initialValue.includes("other") ? true : this.otherChecked, otherText: this.initialOtherValue, - selections: [] - } - }, - - mounted: function () { - for (let choice of this.initialValue) { - this.selections.push(choice) + selections: this.setSelection() } }, @@ -55,6 +48,11 @@ export default { otherToggle: function() { this.otherChecked = !this.otherChecked this.otherText = '' + }, + setSelection: function () { + for (let choice of this.initialValue) { + this.selections.push(choice) + } } } } diff --git a/js/components/other_input.js b/js/components/other_input.js deleted file mode 100644 index c2431b85..00000000 --- a/js/components/other_input.js +++ /dev/null @@ -1,29 +0,0 @@ -import FormMixin from '../mixins/form' -import textinput from '../components/text_input' - -export default { - name: 'otherinput', - - mixins: [FormMixin], - - components: { - textinput, - }, - - props: { - initialData: { - type: Array, - default: () => ({}) - } - }, - - data: function () { - const { - other = true - } = this.initialData - - return { - other - } - } -} diff --git a/templates/components/multi_checkbox_input.html b/templates/components/multi_checkbox_input.html index 3bd294c5..9a9543df 100644 --- a/templates/components/multi_checkbox_input.html +++ b/templates/components/multi_checkbox_input.html @@ -33,7 +33,7 @@
  • {% if choice[0] != 'other' %} - + {% else %}