my-test123
Version:
A planner front-end for Fabric8.
71 lines • 3.5 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 { Actions, Effect } from '@ngrx/effects';
import { Store } from '@ngrx/store';
import { Injectable } from '@angular/core';
import * as WorkItemTypeActions from './../actions/work-item-type.actions';
import * as WIStateActoins from './../actions/work-item-state.actions';
import { Observable } from 'rxjs';
import { WorkItemService } from './../services/work-item.service';
import { WorkItemTypeMapper, WorkItemTypeResolver } from './../models/work-item-type';
import { Notifications, NotificationType } from "ngx-base";
var WorkItemTypeEffects = /** @class */ (function () {
function WorkItemTypeEffects(actions$, workItemService, store, notifications) {
var _this = this;
this.actions$ = actions$;
this.workItemService = workItemService;
this.store = store;
this.notifications = notifications;
this.getWorkItemTypes$ = this.actions$
.ofType(WorkItemTypeActions.GET)
.withLatestFrom(this.store.select('listPage').select('space'))
.switchMap(function (_a) {
var action = _a[0], space = _a[1];
return _this.workItemService.getWorkItemTypes2(space.links.self + '/workitemtypes')
.map(function (types) {
var witm = new WorkItemTypeMapper();
var wiTypes = types.map(function (t) { return witm.toUIModel(t); });
var witResolver = new WorkItemTypeResolver(wiTypes);
witResolver.resolveChildren();
_this.store.dispatch(new WIStateActoins.GetSuccess(types));
return new WorkItemTypeActions.GetSuccess(witResolver.getResolvedWorkItemTypes());
})
.catch(function (e) {
try {
_this.notifications.message({
message: "Problem in fetching workitem type.",
type: NotificationType.DANGER
});
}
catch (e) {
console.log('Problem in fetching work item type');
}
return Observable.of(new WorkItemTypeActions.GetError());
});
});
}
WorkItemTypeEffects.decorators = [
{ type: Injectable },
];
/** @nocollapse */
WorkItemTypeEffects.ctorParameters = function () { return [
{ type: Actions, },
{ type: WorkItemService, },
{ type: Store, },
{ type: Notifications, },
]; };
__decorate([
Effect(),
__metadata("design:type", Observable)
], WorkItemTypeEffects.prototype, "getWorkItemTypes$", void 0);
return WorkItemTypeEffects;
}());
export { WorkItemTypeEffects };
//# sourceMappingURL=work-item-type.effects.js.map