UNPKG

fabric8-planner

Version:
212 lines 9.51 kB
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 __()); }; })(); var __assign = (this && this.__assign) || Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; import { Injectable } from '@angular/core'; import { select, Store } from '@ngrx/store'; import { map } from 'rxjs/operators'; import { AreaQuery } from './area.model'; import { modelService, switchModel } from './common.model'; import { IterationQuery } from './iteration.model'; import { LabelQuery } from './label.model'; import { UserQuery } from './user'; import { WorkItemTypeQuery } from './work-item-type'; var Event = /** @class */ (function (_super) { __extends(Event, _super); function Event() { return _super !== null && _super.apply(this, arguments) || this; } return Event; }(modelService)); export { Event }; var EventAttributes = /** @class */ (function () { function EventAttributes() { } return EventAttributes; }()); export { EventAttributes }; var EventRelationships = /** @class */ (function () { function EventRelationships() { } return EventRelationships; }()); export { EventRelationships }; var EventMapper = /** @class */ (function () { function EventMapper() { this.serviceToUiMapTree = [{ fromPath: ['attributes', 'name'], toPath: ['name'] }, { fromPath: ['attributes', 'newValue'], toPath: ['newValue'], toFunction: function (newValue) { if (newValue !== null) { if (Array.isArray(newValue)) { return newValue.join(', '); } else { return newValue; } } else { return newValue; } } }, { fromPath: ['attributes', 'oldValue'], toPath: ['oldValue'], toFunction: function (oldValue) { if (oldValue !== null) { if (Array.isArray(oldValue)) { return oldValue.join(', '); } else { return oldValue; } } else { return oldValue; } } }, { fromPath: ['attributes', 'timestamp'], toPath: ['timestamp'] }, { fromPath: ['relationships', 'modifier', 'data', 'id'], toPath: ['modifierId'] }, { fromPath: ['relationships', 'newValue'], toPath: ['newValueRelationships'], toFunction: function (newValue) { if (newValue !== null) { if (newValue.hasOwnProperty('data')) { return newValue['data'].map(function (item) { return { id: item.id, type: item.type }; }); } else { return []; } } else { return []; } } }, { fromPath: ['relationships', 'oldValue'], toPath: ['oldValueRelationships'], toFunction: function (oldValue) { if (oldValue !== null) { if (oldValue.hasOwnProperty('data')) { return oldValue['data'].map(function (item) { return { id: item.id, type: item.type }; }); } else { return []; } } else { return []; } } }, { toPath: ['type'], toValue: null }]; } EventMapper.prototype.toUIModel = function (arg) { return switchModel(arg, this.serviceToUiMapTree); }; EventMapper.prototype.toServiceModel = function (arg) { return switchModel(arg, this.uiToServiceMapTree); }; return EventMapper; }()); export { EventMapper }; var EventQuery = /** @class */ (function () { function EventQuery(store, userQuery, iterationQuery, areaQuery, labelQuery, workitemTypeQuery) { this.store = store; this.userQuery = userQuery; this.iterationQuery = iterationQuery; this.areaQuery = areaQuery; this.labelQuery = labelQuery; this.workitemTypeQuery = workitemTypeQuery; this.eventSource = this.store .pipe(select(function (state) { return state.detailPage; }), select(function (state) { return state.events; })); } EventQuery.prototype.getEventsWithModifier = function () { var _this = this; return this.eventSource .pipe(map(function (events) { return events.map(function (event) { switch (event.type) { case 'iterations': return __assign({}, event, { modifier: _this.userQuery.getUserObservableById(event.modifierId), newValueRelationshipsObs: event.newValueRelationships.map(function (item) { return _this.iterationQuery.getIterationObservableById(item.id); }), oldValueRelationshipsObs: event.oldValueRelationships.map(function (item) { return _this.iterationQuery.getIterationObservableById(item.id); }) }); case 'areas': return __assign({}, event, { modifier: _this.userQuery.getUserObservableById(event.modifierId), newValueRelationshipsObs: event.newValueRelationships.map(function (item) { return _this.areaQuery.getAreaObservableById(item.id); }), oldValueRelationshipsObs: event.oldValueRelationships.map(function (item) { return _this.areaQuery.getAreaObservableById(item.id); }) }); case 'users': return __assign({}, event, { modifier: _this.userQuery.getUserObservableById(event.modifierId), newValueRelationshipsObs: event.newValueRelationships.map(function (item) { return _this.userQuery.getUserObservableById(item.id); }), oldValueRelationshipsObs: event.oldValueRelationships.map(function (item) { return _this.userQuery.getUserObservableById(item.id); }) }); case 'labels': return __assign({}, event, { modifier: _this.userQuery.getUserObservableById(event.modifierId), newValueRelationshipsObs: _this.labelQuery.getLabelObservablesByIds(event.newValueRelationships.map(function (i) { return i.id; })), oldValueRelationshipsObs: _this.labelQuery.getLabelObservablesByIds(event.oldValueRelationships.map(function (i) { return i.id; })) }); case 'workitemtypes': return __assign({}, event, { modifier: _this.userQuery.getUserObservableById(event.modifierId), newValueRelationshipsObs: event.newValueRelationships.map(function (item) { return _this.workitemTypeQuery.getWorkItemTypeById(item.id); }), oldValueRelationshipsObs: event.oldValueRelationships.map(function (item) { return _this.workitemTypeQuery.getWorkItemTypeById(item.id); }) }); default: console.log('Unknown event: ', event); return __assign({}, event, { modifier: _this.userQuery.getUserObservableById(event.modifierId) }); } }); })); }; EventQuery.decorators = [ { type: Injectable }, ]; /** @nocollapse */ EventQuery.ctorParameters = function () { return [ { type: Store, }, { type: UserQuery, }, { type: IterationQuery, }, { type: AreaQuery, }, { type: LabelQuery, }, { type: WorkItemTypeQuery, }, ]; }; return EventQuery; }()); export { EventQuery }; //# sourceMappingURL=event.model.js.map