fabric8-planner
Version:
A planner front-end for Fabric8.
55 lines • 3.14 kB
JavaScript
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 { SpaceQuery } from '../models/space';
import * as WIStateActions from './../actions/work-item-state.actions';
import * as WorkItemTypeActions from './../actions/work-item-type.actions';
import { WorkItemTypeMapper } from './../models/work-item-type';
import { WorkItemService } from './../services/work-item.service';
import { ErrorHandler, filterTypeWithSpace } from './work-item-utils';
var WorkItemTypeEffects = /** @class */ (function () {
function WorkItemTypeEffects(actions$, workItemService, spaceQuery, errHandler) {
var _this = this;
this.actions$ = actions$;
this.workItemService = workItemService;
this.spaceQuery = spaceQuery;
this.errHandler = errHandler;
this.getWorkItemTypes$ = this.actions$
.pipe(filterTypeWithSpace(WorkItemTypeActions.GET, this.spaceQuery.getCurrentSpace), switchMap(function (_a) {
var action = _a[0], space = _a[1];
return _this.workItemService.getWorkItemTypes(space.relationships.workitemtypes.links.related)
.pipe(map(function (types) { return types.filter(function (t) { return t.attributes['can-construct']; }); }), switchMap(function (types) {
var witm = new WorkItemTypeMapper();
var wiTypes = types.map(function (t) { return witm.toUIModel(t); });
return [new WorkItemTypeActions.GetSuccess(wiTypes), new WIStateActions.GetSuccess(types)];
}), catchError(function (err) { return _this.errHandler.handleError(err, "Problem in fetching workitem type.", new WorkItemTypeActions.GetError()); }));
}));
}
WorkItemTypeEffects.decorators = [
{ type: Injectable },
];
/** @nocollapse */
WorkItemTypeEffects.ctorParameters = function () { return [
{ type: Actions, },
{ type: WorkItemService, },
{ type: SpaceQuery, },
{ type: ErrorHandler, },
]; };
__decorate([
Effect(),
__metadata("design:type", Observable)
], WorkItemTypeEffects.prototype, "getWorkItemTypes$", void 0);
return WorkItemTypeEffects;
}());
export { WorkItemTypeEffects };
//# sourceMappingURL=work-item-type.effects.js.map