UNPKG

fabric8-planner

Version:
169 lines 6.02 kB
import { Injectable } from '@angular/core'; import { select, Store } from '@ngrx/store'; import { map } from 'rxjs/operators'; import { switchModel } from './common.model'; import { workItemDetailSelector, WorkItemMapper } from './work-item'; var Link = /** @class */ (function () { function Link() { } return Link; }()); export { Link }; var RelationalData = /** @class */ (function () { function RelationalData() { } return RelationalData; }()); export { RelationalData }; var LinkTypeMapper = /** @class */ (function () { function LinkTypeMapper() { this.serviceToUiMapTree = [{ fromPath: ['id'], toPath: ['id'] }, { fromPath: ['attributes', 'name'], toPath: ['name'] }, { fromPath: ['attributes', 'forward_name'], toPath: ['forwardName'] }, { fromPath: ['attributes', 'reverse_name'], toPath: ['reverseName'] }, { fromPath: ['attributes', 'topology'], toPath: ['topology'] }, { fromPath: ['attributes', 'version'], toPath: ['version'] }, { fromPath: ['type'], toPath: ['type'] }, { fromPath: ['relationships', 'links', 'self'], toPath: ['selfLink'] }]; this.uiToServiceMapTree = [{ toPath: ['id'], fromPath: ['id'] }, { toPath: ['attributes', 'name'], fromPath: ['name'] }, { toPath: ['attributes', 'forward_name'], fromPath: ['forwardName'] }, { toPath: ['attributes', 'reverse_name'], fromPath: ['reverseName'] }, { toPath: ['attributes', 'topology'], fromPath: ['topology'] }, { toPath: ['attributes', 'version'], fromPath: ['version'] }, { toPath: ['type'], fromPath: ['type'] }, { toPath: ['relationships', 'links', 'self'], fromPath: ['selfLink'] }]; } LinkTypeMapper.prototype.toUIModel = function (arg) { return switchModel(arg, this.serviceToUiMapTree); }; LinkTypeMapper.prototype.toServiceModel = function (arg) { return switchModel(arg, this.uiToServiceMapTree); }; return LinkTypeMapper; }()); export { LinkTypeMapper }; var WorkItemLinkMapper = /** @class */ (function () { function WorkItemLinkMapper() { this.ltMapper = new LinkTypeMapper; this.wiMapper = new WorkItemMapper; this.serviceToUiMapTree = [{ fromPath: ['id'], toPath: ['id'] }, { fromPath: ['type'], toPath: ['type'] }, { fromPath: ['attributes', 'version'], toPath: ['version'] }, { fromPath: ['relationships', 'link_type', 'data'], toPath: ['linkType'], toFunction: this.ltMapper.toUIModel.bind(this.ltMapper) }, { fromPath: ['relationships', 'source', 'data'], toPath: ['source'], toFunction: this.wiMapper.toUIModel.bind(this.wiMapper) }, { fromPath: ['relationships', 'target', 'data'], toPath: ['target'], toFunction: this.wiMapper.toUIModel.bind(this.wiMapper) }, { toPath: ['newlyAdded'], toValue: false }]; this.uiToServiceMapTree = [{ toPath: ['id'], fromPath: ['id'] }, { toPath: ['type'], fromPath: ['type'] }, { toPath: ['attributes', 'version'], fromPath: ['version'] }, { toPath: ['relationships', 'link_type', 'data'], fromPath: ['linkType'], toFunction: this.ltMapper.toServiceModel.bind(this.ltMapper) }, { toPath: ['relationships', 'source', 'data'], fromPath: ['source'], toFunction: this.wiMapper.toServiceModel.bind(this.wiMapper) }, { toPath: ['relationships', 'target', 'data'], fromPath: ['target'], toFunction: this.wiMapper.toServiceModel.bind(this.wiMapper) }]; } WorkItemLinkMapper.prototype.toUIModel = function (arg) { return switchModel(arg, this.serviceToUiMapTree); }; WorkItemLinkMapper.prototype.toServiceModel = function (arg) { return switchModel(arg, this.uiToServiceMapTree); }; return WorkItemLinkMapper; }()); export { WorkItemLinkMapper }; var WorkItemLinkQuery = /** @class */ (function () { function WorkItemLinkQuery(store) { this.store = store; } Object.defineProperty(WorkItemLinkQuery.prototype, "getWorkItemLinks", { get: function () { return this.store.pipe(select(workItemDetailSelector), select(function (state) { return state.workItemLink; })); }, enumerable: true, configurable: true }); Object.defineProperty(WorkItemLinkQuery.prototype, "getWorkItemLinksCount", { get: function () { return this.getWorkItemLinks.pipe(map(function (links) { return Array.isArray(links) ? links.length : -1; })); }, enumerable: true, configurable: true }); WorkItemLinkQuery.decorators = [ { type: Injectable }, ]; /** @nocollapse */ WorkItemLinkQuery.ctorParameters = function () { return [ { type: Store, }, ]; }; return WorkItemLinkQuery; }()); export { WorkItemLinkQuery }; //# sourceMappingURL=link.js.map