UNPKG

ng2-json-editor

Version:

Angular2 component for editing large json documents

80 lines 5.33 kB
/* * This file is part of ng2-json-editor. * Copyright (C) 2016 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. */ var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); import { Component, Input, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core'; import { AbstractListFieldComponent } from '../abstract-list-field'; import { AppGlobalsService, JsonStoreService, PathUtilService, KeysStoreService, ProblemsService } from '../shared/services'; var TableListFieldComponent = (function (_super) { __extends(TableListFieldComponent, _super); function TableListFieldComponent(appGlobalsService, problemsService, jsonStoreService, pathUtilService, keysStoreService, changeDetectorRef) { var _this = _super.call(this, appGlobalsService, problemsService, jsonStoreService, pathUtilService, changeDetectorRef) || this; _this.appGlobalsService = appGlobalsService; _this.problemsService = problemsService; _this.jsonStoreService = jsonStoreService; _this.pathUtilService = pathUtilService; _this.keysStoreService = keysStoreService; _this.changeDetectorRef = changeDetectorRef; return _this; } Object.defineProperty(TableListFieldComponent.prototype, "keys$", { get: function () { return this.keysStoreService.forPath(this.pathString); }, enumerable: true, configurable: true }); return TableListFieldComponent; }(AbstractListFieldComponent)); export { TableListFieldComponent }; TableListFieldComponent.decorators = [ { type: Component, args: [{ selector: 'table-list-field', styles: ["table.editable-inner-table { border: none; } table.editable-inner-table thead > tr > th { vertical-align: middle; border: none; color: #c1c1c1; } .add-patch { margin: 8px 0px; } "], template: "<div [id]=\"pathString\" [ngClass]=\"redLeftBorderClass\"> <table class=\"table editable-inner-table\"> <thead class=\"thead-inverse\"> <tr> <th *ngFor=\"let key of keys$ | async; trackBy:trackByElement\" [style.width]=\"schema.items.properties[key].columnWidth + '%'\"> {{key | underscoreToSpace}} </th> <th class=\"button-holder\" [class.sortable]=\"schema.sortable\"> <add-field-dropdown *ngIf=\"values.size > 0\" [fields]=\"keys$ | async\" [pathString]=\"pathString\" [schema]=\"schema.items\" [isDisabled]=\"disabled\"> <i class=\"fa fa-plus\"></i> <i class=\"fa fa-caret-down\"></i> </add-field-dropdown> </th> </tr> </thead> <tr *ngFor=\"let value of values; let i = index; trackBy:trackByIndex\" table-item-field [id]=\"getPathStringForChild(i)\" [value]=\"value\" [schema]=\"schema.items\" [path]=\"getPathForChild(i)\" [keys]=\"keys$ | async\"> <td *ngIf=\"values.size > 0\" class=\"button-holder\" [class.sortable]=\"schema.sortable\"> <list-action-group (onMove)=\"moveElement(i, $event)\" (onDelete)=\"deleteElement(i, value)\" [canMove]=\"schema.sortable\" [isDisabled]=\"disabled\"></list-action-group> </td> </tr> <tr *ngIf=\"removeJsonPatch\"> <patch-actions [patch]=\"removeJsonPatch\"></patch-actions> </tr> </table> <div class=\"add-patch\" *ngFor=\"let patch of addJsonPatches\"> <add-or-replace-patch [patch]=\"patch\"></add-or-replace-patch> </div> <div *ngIf=\"replaceJsonPatches && replaceJsonPatches[0]\"> <add-or-replace-patch [patch]=\"replaceJsonPatches[0]\"></add-or-replace-patch> </div> </div> ", changeDetection: ChangeDetectionStrategy.OnPush },] }, ]; /** @nocollapse */ TableListFieldComponent.ctorParameters = function () { return [ { type: AppGlobalsService, }, { type: ProblemsService, }, { type: JsonStoreService, }, { type: PathUtilService, }, { type: KeysStoreService, }, { type: ChangeDetectorRef, }, ]; }; TableListFieldComponent.propDecorators = { 'values': [{ type: Input },], 'supportValues': [{ type: Input },], 'schema': [{ type: Input },], 'path': [{ type: Input },], }; //# sourceMappingURL=table-list-field.component.js.map