UNPKG

fabric8-planner

Version:
55 lines 2.92 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 { Observable } from 'rxjs'; import { catchError, map, switchMap } from 'rxjs/operators'; import { normalizeArray } from '../models/common.model'; import { SpaceQuery } from '../models/space'; import * as AreaActions from './../actions/area.actions'; import { AreaMapper } from './../models/area.model'; import { AreaService as AService } from './../services/area.service'; import { ErrorHandler, filterTypeWithSpace } from './work-item-utils'; var AreaEffects = /** @class */ (function () { function AreaEffects(actions$, areaService, errHandler, spaceQuery) { var _this = this; this.actions$ = actions$; this.areaService = areaService; this.errHandler = errHandler; this.spaceQuery = spaceQuery; this.getAreas$ = this.actions$ .pipe(filterTypeWithSpace(AreaActions.GET, this.spaceQuery.getCurrentSpace), switchMap(function (_a) { var action = _a[0], space = _a[1]; return _this.areaService.getAreas2(space.relationships.areas.links.related) .pipe(map(function (areas) { var aMapper = new AreaMapper(); return areas.map(function (a) { return aMapper.toUIModel(a); }). sort(function (a1, a2) { return (a1.name.toLowerCase() > a2.name.toLowerCase() ? 1 : 0); }); }), map(function (areas) { return new AreaActions.GetSuccess(normalizeArray(areas)); }), catchError(function (err) { return _this.errHandler.handleError(err, 'Problem in fetching Areas.', new AreaActions.GetError()); })); })); } AreaEffects.decorators = [ { type: Injectable }, ]; /** @nocollapse */ AreaEffects.ctorParameters = function () { return [ { type: Actions, }, { type: AService, }, { type: ErrorHandler, }, { type: SpaceQuery, }, ]; }; __decorate([ Effect(), __metadata("design:type", Observable) ], AreaEffects.prototype, "getAreas$", void 0); return AreaEffects; }()); export { AreaEffects }; //# sourceMappingURL=area.effects.js.map