UNPKG

ng2-json-editor

Version:

Angular2 component for editing large json documents

59 lines 4.48 kB
/* * This file is part of ng2-json-editor. * Copyright (C) 2017 CERN. * * ng2-json-editor is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * ng2-json-editor is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ng2-json-editor; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. * In applying this license, CERN does not * waive the privileges and immunities granted to it by virtue of its status * as an Intergovernmental Organization or submit itself to any jurisdiction. */ import { Component, Input, ChangeDetectionStrategy } from '@angular/core'; import { JsonSchemaService } from '../shared/services'; var AddOrReplacePatchComponent = (function () { function AddOrReplacePatchComponent(jsonSchemaService) { this.jsonSchemaService = jsonSchemaService; } AddOrReplacePatchComponent.prototype.ngOnChanges = function (changes) { var patchChanges = changes['patch']; if (patchChanges) { this.schema = this.jsonSchemaService.forPathString(this.patch.path); } }; Object.defineProperty(AddOrReplacePatchComponent.prototype, "leftBorderClass", { get: function () { return this.patch.op === 'add' ? 'green-left-border' : 'orange-left-border'; }, enumerable: true, configurable: true }); return AddOrReplacePatchComponent; }()); export { AddOrReplacePatchComponent }; AddOrReplacePatchComponent.decorators = [ { type: Component, args: [{ selector: 'add-or-replace-patch', styles: ["td { vertical-align: top; padding-right: 10px !important; } .align-self-end { align-self: flex-end; } .patch-container { display: flex; padding-left: 4px; } .green-left-border { border-left: 9px solid #2ecc71; } .grow { flex-grow: 1; } "], template: "<div class=\"patch-container\" [ngClass]=\"leftBorderClass\" [id]=\"patch.path\" tabindex=\"-1\"> <div class=\"grow\"> <ng-template [ngTemplateOutlet]=\"anyTypeTemplate\" [ngTemplateOutletContext]=\"{value: patch.value, schema: schema}\"></ng-template> </div> <patch-actions class=\"align-self-end\" [patch]=\"patch\"></patch-actions> </div> <ng-template #anyTypeTemplate let-value=\"value\" let-schema=\"schema\"> <ng-container [ngSwitch]=\"value | typeOf\"> <ng-container *ngSwitchCase=\"'object'\"> <ng-template [ngTemplateOutlet]=\"objectTemplate\" [ngTemplateOutletContext]=\"{object: value, schema: schema}\"></ng-template> </ng-container> <ng-container *ngSwitchCase=\"'array'\"> <ng-template [ngTemplateOutlet]=\"arrayTemplate\" [ngTemplateOutletContext]=\"{array: value, schema: schema}\"></ng-template> </ng-container> <ng-container *ngSwitchDefault> <ng-template [ngTemplateOutlet]=\"primitiveTemplate\" [ngTemplateOutletContext]=\"{primitive: value}\"></ng-template> </ng-container> </ng-container> </ng-template> <ng-template #objectTemplate let-object=\"object\" let-schema=\"schema\"> <table> <tr *ngFor=\"let key of object | keys | sortKeysBySchema:schema\"> <td> <label>{{key}}</label> </td> <td> <ng-template [ngTemplateOutlet]=\"anyTypeTemplate\" [ngTemplateOutletContext]=\"{value: object[key], schema: schema.properties[key]}\"></ng-template> </td> </tr> </table> </ng-template> <ng-template #arrayTemplate let-array=\"array\" let-schema=\"schema\"> <table> <tr *ngFor=\"let item of array\" class=\"array-item\"> <td> <ng-template [ngTemplateOutlet]=\"anyTypeTemplate\" [ngTemplateOutletContext]=\"{value: item, schema: schema.items}\"></ng-template> </td> </tr> </table> </ng-template> <ng-template #primitiveTemplate let-primitive=\"primitive\"> <span>{{primitive}}</span> </ng-template>", changeDetection: ChangeDetectionStrategy.OnPush },] }, ]; /** @nocollapse */ AddOrReplacePatchComponent.ctorParameters = function () { return [ { type: JsonSchemaService, }, ]; }; AddOrReplacePatchComponent.propDecorators = { 'patch': [{ type: Input },], }; //# sourceMappingURL=add-or-replace-patch.component.js.map