2
0
mirror of https://github.com/frappe/books.git synced 2024-11-14 09:24:04 +00:00
books/client/view/controls/check.js
2018-03-05 22:15:21 +05:30

38 lines
798 B
JavaScript

const BaseControl = require('./base');
class CheckControl extends BaseControl {
make() {
if (!this.onlyInput) {
this.makeInputContainer();
}
this.makeInput();
if (!this.onlyInput) {
this.makeLabel();
}
this.addChangeHandler();
}
makeInputContainer() {
super.makeInputContainer('form-check');
}
makeLabel() {
super.makeLabel('form-check-label');
}
makeInput() {
super.makeInput('form-check-input');
this.input.type = 'checkbox';
}
setInputValue(value) {
if (value === '0') value = 0;
this.input.checked = value ? true : false;
}
getInputValue() {
return this.input.checked ? 1 : 0
}
};
module.exports = CheckControl;