UNPKG

angular2-json-schema-form

Version:
59 lines 2.92 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 AddReferenceComponent = (function () { function AddReferenceComponent(jsf) { this.jsf = jsf; this.showAddButton = true; } AddReferenceComponent.prototype.ngOnInit = function () { this.options = this.layoutNode.options; this.itemCount = this.layoutIndex[this.layoutIndex.length - 1]; this.updateControl(); }; AddReferenceComponent.prototype.ngOnChanges = function () { this.updateControl(); }; AddReferenceComponent.prototype.addItem = function (event) { event.preventDefault(); this.itemCount = this.layoutIndex[this.layoutIndex.length - 1] + 1; this.jsf.addItem(this); this.updateControl(); }; AddReferenceComponent.prototype.updateControl = function () { this.showAddButton = this.layoutNode.arrayItem && this.itemCount <= (this.options.maxItems || 1000000); }; return AddReferenceComponent; }()); __decorate([ core_1.Input(), __metadata("design:type", Object) ], AddReferenceComponent.prototype, "layoutNode", void 0); __decorate([ core_1.Input(), __metadata("design:type", Array) ], AddReferenceComponent.prototype, "layoutIndex", void 0); __decorate([ core_1.Input(), __metadata("design:type", Array) ], AddReferenceComponent.prototype, "dataIndex", void 0); AddReferenceComponent = __decorate([ core_1.Component({ moduleId: module.id, selector: 'add-reference-widget', template: "\n <button *ngIf=\"showAddButton\"\n [class]=\"options?.fieldHtmlClass\"\n [disabled]=\"options?.readonly\"\n (click)=\"addItem($event)\">\n <span *ngIf=\"options?.icon\" [class]=\"options?.icon\"></span>\n <span *ngIf=\"options?.title\" [innerHTML]=\"options?.title\"></span>\n </button>", }), __metadata("design:paramtypes", [json_schema_form_service_1.JsonSchemaFormService]) ], AddReferenceComponent); exports.AddReferenceComponent = AddReferenceComponent; //# sourceMappingURL=add-reference.component.js.map