Use widgets to get checkboxes and add some vue
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import FormMixin from '../../mixins/form'
|
||||
import optionsinput from '../options_input'
|
||||
import textinput from '../text_input'
|
||||
import checkboxinput from '../checkbox_input'
|
||||
|
||||
@@ -9,7 +8,6 @@ export default {
|
||||
mixins: [FormMixin],
|
||||
|
||||
components: {
|
||||
optionsinput,
|
||||
textinput,
|
||||
checkboxinput,
|
||||
},
|
||||
|
44
js/components/multi_checkbox_input.js
Normal file
44
js/components/multi_checkbox_input.js
Normal file
@@ -0,0 +1,44 @@
|
||||
import otherinput from '../components/other_input'
|
||||
import optionsinput from '../components/options_input'
|
||||
import textinput from '../components/text_input'
|
||||
|
||||
export default {
|
||||
name: 'multicheckboxinput',
|
||||
|
||||
components: {
|
||||
otherinput,
|
||||
optionsinput,
|
||||
textinput,
|
||||
},
|
||||
|
||||
props: {
|
||||
name: String,
|
||||
initialErrors: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
initialValue: Array,
|
||||
},
|
||||
|
||||
|
||||
data: function () {
|
||||
const showError = (this.initialErrors && this.initialErrors.length) || false
|
||||
return {
|
||||
showError: showError,
|
||||
showValid: !showError && !!this.initialValue,
|
||||
validationError: this.initialErrors.join(' ')
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
methods: {
|
||||
onInput: function (e) {
|
||||
this.$root.$emit('field-change', {
|
||||
value: e.target.value,
|
||||
name: this.name
|
||||
})
|
||||
this.showError = false
|
||||
this.showValid = true
|
||||
}
|
||||
}
|
||||
}
|
29
js/components/other_input.js
Normal file
29
js/components/other_input.js
Normal file
@@ -0,0 +1,29 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user