UNPKG

angular2-json-schema-form

Version:
86 lines 5.26 kB
"use strict"; 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 MaterialCheckboxesComponent = (function () { function MaterialCheckboxesComponent(jsf) { this.jsf = jsf; this.boundControl = false; this.horizontalList = false; this.checkboxList = []; } MaterialCheckboxesComponent.prototype.ngOnInit = function () { this.options = this.layoutNode.options; this.horizontalList = this.layoutNode.type === 'checkboxes-inline' || this.layoutNode.type === 'checkboxbuttons'; this.jsf.initializeControl(this); this.checkboxList = index_1.buildTitleMap(this.options.titleMap || this.options.enumNames, this.options.enum, true); if (this.boundControl) { var formArray = this.jsf.getControl(this); for (var _i = 0, _a = this.checkboxList; _i < _a.length; _i++) { var checkboxItem = _a[_i]; checkboxItem.checked = formArray.value.indexOf(checkboxItem.value) !== -1; } } }; Object.defineProperty(MaterialCheckboxesComponent.prototype, "allChecked", { get: function () { return this.checkboxList.filter(function (t) { return t.checked; }).length === this.checkboxList.length; }, enumerable: true, configurable: true }); Object.defineProperty(MaterialCheckboxesComponent.prototype, "someChecked", { get: function () { var checkedItems = this.checkboxList.filter(function (t) { return t.checked; }).length; return checkedItems > 0 && checkedItems < this.checkboxList.length; }, enumerable: true, configurable: true }); MaterialCheckboxesComponent.prototype.updateValue = function (event, checkAll) { if (checkAll === void 0) { checkAll = false; } if (checkAll) { this.checkboxList.forEach(function (t) { return t.checked = event.checked; }); } if (this.boundControl) { this.jsf.updateArrayCheckboxList(this, this.checkboxList); } }; return MaterialCheckboxesComponent; }()); __decorate([ core_1.Input(), __metadata("design:type", Number) ], MaterialCheckboxesComponent.prototype, "formID", void 0); __decorate([ core_1.Input(), __metadata("design:type", Object) ], MaterialCheckboxesComponent.prototype, "layoutNode", void 0); __decorate([ core_1.Input(), __metadata("design:type", Array) ], MaterialCheckboxesComponent.prototype, "layoutIndex", void 0); __decorate([ core_1.Input(), __metadata("design:type", Array) ], MaterialCheckboxesComponent.prototype, "dataIndex", void 0); MaterialCheckboxesComponent = __decorate([ core_1.Component({ selector: 'material-checkboxes-widget', template: "\n <md-checkbox type=\"checkbox\"\n [color]=\"options?.color || 'accent'\"\n [disabled]=\"controlDisabled || options?.readonly\"\n [name]=\"options?.name\"\n [checked]=\"allChecked\"\n [indeterminate]=\"someChecked\"\n (change)=\"updateValue($event, true)\">\n <span [innerHTML]=\"checkboxItem?.name\"></span>\n </md-checkbox>\n <label *ngIf=\"options?.title\"\n [class]=\"options?.labelHtmlClass\"\n [class.sr-only]=\"options?.notitle\"\n [innerHTML]=\"options?.title\"></label>\n <ul class=\"checkbox-list\" [class.horizontal-list]=\"horizontalList\">\n <li *ngFor=\"let checkboxItem of checkboxList\"\n [class]=\"options?.htmlClass\">\n <md-checkbox type=\"checkbox\"\n [(ngModel)]=\"checkboxItem.checked\"\n [color]=\"options?.color || 'accent'\"\n [disabled]=\"controlDisabled || options?.readonly\"\n [name]=\"checkboxItem?.name\"\n (change)=\"updateValue($event)\">\n <span [innerHTML]=\"checkboxItem?.name\"></span>\n </md-checkbox>\n </li>\n </ul>", styles: ["\n .checkbox-list {\n list-style-type: none;\n }\n .horizontal-list > li {\n display: inline-block;\n margin-right: 10px;\n zoom: 1;\n *display: inline;\n }\n "] }), __metadata("design:paramtypes", [json_schema_form_service_1.JsonSchemaFormService]) ], MaterialCheckboxesComponent); exports.MaterialCheckboxesComponent = MaterialCheckboxesComponent; //# sourceMappingURL=material-checkboxes.component.js.map