Merge pull request #526 from dod-ccpo/checkbox-fixes

Checkbox fixes
This commit is contained in:
montana-mil 2019-01-09 11:22:38 -05:00 committed by GitHub
commit e83b57f8b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 46 deletions

View File

@ -1,4 +1,3 @@
import otherinput from '../components/other_input'
import optionsinput from '../components/options_input' import optionsinput from '../components/options_input'
import textinput from '../components/text_input' import textinput from '../components/text_input'
@ -6,7 +5,6 @@ export default {
name: 'multicheckboxinput', name: 'multicheckboxinput',
components: { components: {
otherinput,
optionsinput, optionsinput,
textinput, textinput,
}, },
@ -29,17 +27,11 @@ export default {
const showError = (this.initialErrors && this.initialErrors.length) || false const showError = (this.initialErrors && this.initialErrors.length) || false
return { return {
showError: showError, showError: showError,
showValid: !showError && !!this.initialValue, showValid: !showError && this.initialValue.length > 0,
validationError: this.initialErrors.join(' '), validationError: this.initialErrors.join(' '),
otherChecked: this.initialValue.includes("other") ? true : this.otherChecked, otherChecked: this.initialValue.includes("other") ? true : this.otherChecked,
otherText: this.initialOtherValue, otherText: this.initialOtherValue,
selections: [] selections: this.initialValue
}
},
mounted: function () {
for (let choice of this.initialValue) {
this.selections.push(choice)
} }
}, },
@ -55,6 +47,6 @@ export default {
otherToggle: function() { otherToggle: function() {
this.otherChecked = !this.otherChecked this.otherChecked = !this.otherChecked
this.otherText = '' this.otherText = ''
} },
} }
} }

View File

@ -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
}
}
}

View File

@ -7,7 +7,6 @@ import VTooltip from 'v-tooltip'
import optionsinput from './components/options_input' import optionsinput from './components/options_input'
import multicheckboxinput from './components/multi_checkbox_input' import multicheckboxinput from './components/multi_checkbox_input'
import otherinput from './components/other_input'
import textinput from './components/text_input' import textinput from './components/text_input'
import checkboxinput from './components/checkbox_input' import checkboxinput from './components/checkbox_input'
import DetailsOfUse from './components/forms/details_of_use' import DetailsOfUse from './components/forms/details_of_use'
@ -40,7 +39,6 @@ const app = new Vue({
toggler, toggler,
optionsinput, optionsinput,
multicheckboxinput, multicheckboxinput,
otherinput,
textinput, textinput,
checkboxinput, checkboxinput,
DetailsOfUse, DetailsOfUse,

View File

@ -32,11 +32,11 @@
{% for choice in field.choices %} {% for choice in field.choices %}
<li> <li>
{% if choice[0] != 'other' %} {% if choice[0] != 'other' %}
<input type='checkbox' name='{{ field.name }}' id='{{ field.name }}-{{ field.choices.index(choice) }}' value='{{ choice[0] }}' v-model="selections"/> <input type='checkbox' name='{{ field.name }}' id='{{ field.name }}-{{ loop.index0 }}' value='{{ choice[0] }}' v-model="selections"/>
<label for='{{ field.name }}-{{ field.choices.index(choice) }}'>{{ choice[1] }}</label> <label for='{{ field.name }}-{{ loop.index0 }}'>{{ choice[1] }}</label>
{% else %} {% else %}
<input @click="otherToggle" type='checkbox' name='{{ field.name }}' id='{{ field.name }}-{{ field.choices.index(choice) }}' value='other' v-model="selections"/> <input @click="otherToggle" type='checkbox' name='{{ field.name }}' id='{{ field.name }}-{{ loop.index0 }}' value='other' v-model="selections"/>
<label for='{{ field.name }}-{{ field.choices.index(choice) }}'>{{ choice[1] }}</label> <label for='{{ field.name }}-{{ loop.index0 }}'>{{ choice[1] }}</label>
<div v-show="otherChecked"> <div v-show="otherChecked">
<input type='text' name='{{ other_input_field.name}}' id='{{ field.name }}-other' v-bind:value="otherText" aria-expanded='false' /> <input type='text' name='{{ other_input_field.name}}' id='{{ field.name }}-other' v-bind:value="otherText" aria-expanded='false' />