2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 15:50:56 +00:00
books/client/view/controls/check.js

38 lines
798 B
JavaScript
Raw Normal View History

2018-03-05 16:45:21 +00:00
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;