nested checkbox component

This commit is contained in:
dandds
2019-04-29 06:32:17 -04:00
parent b7a8cd4168
commit 47b07c2bb5
5 changed files with 41 additions and 7 deletions

View File

@@ -1,10 +1,11 @@
import { emitEvent } from '../lib/emitters'
import nestedcheckboxinput from './nested_checkbox_input'
export default {
name: 'checkboxinput',
components: {
checkboxinput: this,
nestedcheckboxinput,
},
props: {
@@ -14,7 +15,7 @@ export default {
data: function() {
return {
checked: this.initialChecked,
isChecked: this.initialChecked,
}
},

View File

@@ -0,0 +1,31 @@
import { emitEvent } from '../lib/emitters'
export default {
name: 'nestedcheckboxinput',
props: {
name: String,
isParentChecked: Boolean,
},
data: function() {
return {
isChecked: false,
}
},
updated: function() {
if (!this.isParentChecked) {
this.isChecked = false
}
},
methods: {
onInput: function(e) {
emitEvent('field-change', this, {
value: e.target.checked,
name: this.name,
})
},
},
}