UNPKG

fabric8-planner

Version:
78 lines 3.7 kB
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); }; import { Injectable } from '@angular/core'; import { Actions, Effect } from '@ngrx/effects'; import * as LinkTypeActions from './../actions/link-type.actions'; import { Observable } from 'rxjs'; import { map, switchMap } from 'rxjs/operators'; import { SpaceQuery } from './../models/space'; import { WorkItemService } from './../services/work-item.service'; import { filterTypeWithSpace } from './work-item-utils'; var LinkTypeEffects = /** @class */ (function () { function LinkTypeEffects(actions$, workItemService, spaceQuery) { var _this = this; this.actions$ = actions$; this.workItemService = workItemService; this.spaceQuery = spaceQuery; this.getLinkTypes$ = this.actions$ .pipe(filterTypeWithSpace(LinkTypeActions.GET, this.spaceQuery.getCurrentSpace), map(function (_a) { var action = _a[0], space = _a[1]; return { payload: action, space: space }; }), switchMap(function (lt) { return _this.workItemService.getAllLinkTypes(lt.space.links.workitemlinktypes) .pipe(map(function (data) { var lts = {}; var linkTypes = []; lts['forwardLinks'] = data; lts['backwardLinks'] = data; lts.forwardLinks.forEach(function (linkType) { linkTypes.push({ name: linkType.attributes['forward_name'], id: linkType.id, linkType: 'forward', description: linkType.attributes['forward_description'] ? linkType.attributes['forward_description'] : linkType.attributes['description'] }); }); lts.backwardLinks.forEach(function (linkType) { linkTypes.push({ name: linkType.attributes['reverse_name'], id: linkType.id, linkType: 'reverse', description: linkType.attributes['reverse_description'] ? linkType.attributes['reverse_description'] : linkType.attributes['description'] }); }); return new LinkTypeActions.GetSuccess(linkTypes); })); })); } LinkTypeEffects.decorators = [ { type: Injectable }, ]; /** @nocollapse */ LinkTypeEffects.ctorParameters = function () { return [ { type: Actions, }, { type: WorkItemService, }, { type: SpaceQuery, }, ]; }; __decorate([ Effect(), __metadata("design:type", Observable) ], LinkTypeEffects.prototype, "getLinkTypes$", void 0); return LinkTypeEffects; }()); export { LinkTypeEffects }; //# sourceMappingURL=link-type.effects.js.map