angular2-json-schema-form
Version:
Angular 2 JSON Schema Form builder
52 lines • 3.22 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 index_1 = require("../library/utilities/index");
var SelectComponent = (function () {
function SelectComponent(jsf) {
this.jsf = jsf;
this.controlDisabled = false;
this.boundControl = false;
this.selectList = [];
}
SelectComponent.prototype.ngOnInit = function () {
this.options = this.layoutNode.options;
this.selectList = index_1.buildTitleMap(this.options.titleMap || this.options.enumNames, this.options.enum, !!this.options.required);
this.jsf.initializeControl(this);
};
SelectComponent.prototype.updateValue = function (event) {
this.jsf.updateValue(this, event.target.value);
};
return SelectComponent;
}());
__decorate([
core_1.Input(),
__metadata("design:type", Object)
], SelectComponent.prototype, "layoutNode", void 0);
__decorate([
core_1.Input(),
__metadata("design:type", Array)
], SelectComponent.prototype, "layoutIndex", void 0);
__decorate([
core_1.Input(),
__metadata("design:type", Array)
], SelectComponent.prototype, "dataIndex", void 0);
SelectComponent = __decorate([
core_1.Component({
moduleId: module.id,
selector: 'select-widget',
template: "\n <div\n [class]=\"options?.htmlClass\">\n <label *ngIf=\"options?.title\"\n [attr.for]=\"'control' + layoutNode?._id\"\n [class]=\"options?.labelHtmlClass\"\n [class.sr-only]=\"options?.notitle\"\n [innerHTML]=\"options?.title\"></label>\n <select\n [attr.aria-describedby]=\"'control' + layoutNode?._id + 'Status'\"\n [attr.readonly]=\"options?.readonly ? 'readonly' : null\"\n [attr.required]=\"options?.required\"\n [class]=\"options?.fieldHtmlClass\"\n [disabled]=\"controlDisabled\"\n [id]=\"'control' + layoutNode?._id\"\n [name]=\"controlName\"\n (input)=\"updateValue($event)\">\n <option *ngFor=\"let selectItem of selectList\"\n [value]=\"selectItem.value\"\n [selected]=\"selectItem.value === controlValue\">{{selectItem.name}}</option>\n </select>\n </div>",
}),
__metadata("design:paramtypes", [json_schema_form_service_1.JsonSchemaFormService])
], SelectComponent);
exports.SelectComponent = SelectComponent;
//# sourceMappingURL=select.component.js.map