nested checkbox component
This commit is contained in:
@@ -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,
|
||||
}
|
||||
},
|
||||
|
||||
|
31
js/components/nested_checkbox_input.js
Normal file
31
js/components/nested_checkbox_input.js
Normal 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,
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
Reference in New Issue
Block a user