angular2-json-schema-form
Version:
Angular 2 JSON Schema Form builder
62 lines • 3.47 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var core_1 = require("@angular/core");
var json_schema_form_service_1 = require("../library/json-schema-form.service");
var CheckboxComponent = (function () {
function CheckboxComponent(jsf) {
this.jsf = jsf;
this.controlDisabled = false;
this.boundControl = false;
this.trueValue = true;
this.falseValue = false;
}
CheckboxComponent.prototype.ngOnInit = function () {
this.options = this.layoutNode.options;
this.jsf.initializeControl(this);
if (this.controlValue === null || this.controlValue === undefined) {
this.controlValue = this.options.title;
}
};
CheckboxComponent.prototype.updateValue = function (event) {
event.preventDefault();
this.jsf.updateValue(this, event.target.checked ? this.trueValue : this.falseValue);
};
Object.defineProperty(CheckboxComponent.prototype, "isChecked", {
get: function () {
return this.jsf.getControlValue(this);
},
enumerable: true,
configurable: true
});
return CheckboxComponent;
}());
__decorate([
core_1.Input(),
__metadata("design:type", Object)
], CheckboxComponent.prototype, "layoutNode", void 0);
__decorate([
core_1.Input(),
__metadata("design:type", Array)
], CheckboxComponent.prototype, "layoutIndex", void 0);
__decorate([
core_1.Input(),
__metadata("design:type", Array)
], CheckboxComponent.prototype, "dataIndex", void 0);
CheckboxComponent = __decorate([
core_1.Component({
moduleId: module.id,
selector: 'checkbox-widget',
template: "\n <label\n [attr.for]=\"'control' + layoutNode?._id\"\n [class]=\"options?.itemLabelHtmlClass\">\n <input\n [attr.aria-describedby]=\"'control' + layoutNode?._id + 'Status'\"\n [checked]=\"isChecked ? 'checked' : null\"\n [class]=\"options?.fieldHtmlClass + (isChecked ?\n (' ' + options?.activeClass + ' ' + options?.style?.selected) :\n (' ' + options?.style?.unselected))\"\n [disabled]=\"controlDisabled\"\n [id]=\"'control' + layoutNode?._id\"\n [name]=\"controlName\"\n [readonly]=\"options?.readonly ? 'readonly' : null\"\n [value]=\"controlValue\"\n type=\"checkbox\"\n (change)=\"updateValue($event)\">\n <span *ngIf=\"options?.title\"\n [class.sr-only]=\"options?.notitle\"\n [innerHTML]=\"options?.title\"></span>\n </label>",
}),
__metadata("design:paramtypes", [json_schema_form_service_1.JsonSchemaFormService])
], CheckboxComponent);
exports.CheckboxComponent = CheckboxComponent;
//# sourceMappingURL=checkbox.component.js.map