angular2-json-schema-form
Version:
Angular 2 JSON Schema Form builder
74 lines • 3.83 kB
JavaScript
"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 MaterialAddReferenceComponent = (function () {
function MaterialAddReferenceComponent(jsf) {
this.jsf = jsf;
this.showAddButton = true;
}
MaterialAddReferenceComponent.prototype.ngOnInit = function () {
this.options = this.layoutNode.options;
this.updateControl();
};
MaterialAddReferenceComponent.prototype.ngDoCheck = function () {
if (this.previousLayoutIndex !== this.layoutIndex ||
this.previousDataIndex !== this.dataIndex) {
this.updateControl();
}
};
MaterialAddReferenceComponent.prototype.addItem = function (event) {
event.preventDefault();
this.itemCount = this.layoutIndex[this.layoutIndex.length - 1] + 1;
this.jsf.addItem(this);
this.updateControl();
};
MaterialAddReferenceComponent.prototype.updateControl = function () {
this.itemCount = this.layoutIndex[this.layoutIndex.length - 1];
this.previousLayoutIndex = this.layoutIndex;
this.previousDataIndex = this.dataIndex;
this.showAddButton = this.layoutNode.arrayItem &&
this.itemCount < (this.options.maxItems || 1000000);
};
MaterialAddReferenceComponent.prototype.setTitle = function () {
var parent = {
dataIndex: this.dataIndex.slice(0, -1),
layoutNode: this.jsf.getParentNode(this)
};
return this.jsf.setTitle(parent, this.layoutNode, this.itemCount);
};
return MaterialAddReferenceComponent;
}());
__decorate([
core_1.Input(),
__metadata("design:type", Number)
], MaterialAddReferenceComponent.prototype, "formID", void 0);
__decorate([
core_1.Input(),
__metadata("design:type", Object)
], MaterialAddReferenceComponent.prototype, "layoutNode", void 0);
__decorate([
core_1.Input(),
__metadata("design:type", Array)
], MaterialAddReferenceComponent.prototype, "layoutIndex", void 0);
__decorate([
core_1.Input(),
__metadata("design:type", Array)
], MaterialAddReferenceComponent.prototype, "dataIndex", void 0);
MaterialAddReferenceComponent = __decorate([
core_1.Component({
selector: 'material-add-reference-widget',
template: "\n <section [class]=\"options?.htmlClass\" align=\"end\">\n <button *ngIf=\"showAddButton\" md-raised-button\n [class]=\"options?.fieldHtmlClass\"\n [color]=\"options?.color || 'accent'\"\n [disabled]=\"options?.readonly\"\n (click)=\"addItem($event)\">\n <span *ngIf=\"options?.icon\" [class]=\"options?.icon\"></span>\n <span *ngIf=\"options?.title\" [innerHTML]=\"setTitle()\"></span>\n </button>\n </section>",
}),
__metadata("design:paramtypes", [json_schema_form_service_1.JsonSchemaFormService])
], MaterialAddReferenceComponent);
exports.MaterialAddReferenceComponent = MaterialAddReferenceComponent;
//# sourceMappingURL=material-add-reference.component.js.map