fabric8-planner
Version:
A planner front-end for Fabric8.
245 lines • 9.38 kB
JavaScript
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 __());
};
})();
import { Injectable } from '@angular/core';
import { createFeatureSelector, createSelector, select, Store } from '@ngrx/store';
import { map } from 'rxjs/operators';
import * as IterationActions from './../actions/iteration.actions';
import { IterationService as Service } from './../services/iteration.service';
import { modelService, switchModel } from './common.model';
var IterationModel = /** @class */ (function (_super) {
__extends(IterationModel, _super);
function IterationModel() {
return _super !== null && _super.apply(this, arguments) || this;
}
return IterationModel;
}(modelService));
export { IterationModel };
var IterationAttributes = /** @class */ (function () {
function IterationAttributes() {
}
return IterationAttributes;
}());
export { IterationAttributes };
var IterationLinks = /** @class */ (function () {
function IterationLinks() {
}
return IterationLinks;
}());
export { IterationLinks };
var IterationRelations = /** @class */ (function () {
function IterationRelations() {
}
return IterationRelations;
}());
export { IterationRelations };
var IterationMapper = /** @class */ (function () {
function IterationMapper() {
this.serviceToUiMapTree = [{
fromPath: ['id'],
toPath: ['id']
}, {
fromPath: ['attributes', 'name'],
toPath: ['name']
}, {
fromPath: ['attributes', 'parent_path'],
toPath: ['parentPath']
}, {
fromPath: ['attributes', 'resolved_parent_path'],
toPath: ['resolvedParentPath']
}, {
fromPath: ['attributes', 'user_active'],
toPath: ['userActive']
}, {
fromPath: ['attributes', 'active_status'],
toPath: ['isActive']
}, {
fromPath: ['attributes', 'startAt'],
toPath: ['startAt']
}, {
fromPath: ['attributes', 'endAt'],
toPath: ['endAt']
}, {
fromPath: ['attributes', 'description'],
toPath: ['description']
}, {
fromPath: ['attributes', 'state'],
toPath: ['state']
}, {
fromPath: ['links', 'self'],
toPath: ['link']
}, {
fromPath: ['relationships', 'workitems', 'meta', 'total'],
toPath: ['workItemTotalCount']
}, {
fromPath: ['relationships', 'workitems', 'meta', 'closed'],
toPath: ['workItemClosedCount']
}, {
fromPath: ['hasChildren'],
toPath: ['hasChildren']
}, {
fromPath: ['relationships', 'parent', 'data', 'id'],
toPath: ['parentId']
}, {
toPath: ['selected'],
toValue: false
}, {
toPath: ['showChildren'],
toValue: false
}
];
this.uiToServiceMapTree = [{
fromPath: ['id'],
toPath: ['id']
}, {
fromPath: ['name'],
toPath: ['attributes', 'name']
}, {
fromPath: ['parentPath'],
toPath: ['attributes', 'parent_path']
}, {
fromPath: ['resolvedParentPath'],
toPath: ['attributes', 'resolved_parent_path']
}, {
fromPath: ['userActive'],
toPath: ['attributes', 'user_active']
}, {
fromPath: ['isActive'],
toPath: ['attributes', 'active_status']
}, {
fromPath: ['startAt'],
toPath: ['attributes', 'startAt']
}, {
fromPath: ['endAt'],
toPath: ['attributes', 'endAt']
}, {
fromPath: ['description'],
toPath: ['attributes', 'description']
}, {
fromPath: ['state'],
toPath: ['attributes', 'state']
}, {
fromPath: ['link'],
toPath: ['links', 'self']
}, {
fromPath: ['workItemTotalCount'],
toPath: ['relationships', 'workitems', 'meta', 'total']
}, {
fromPath: ['workItemClosedCount'],
toPath: ['relationships', 'workitems', 'meta', 'closed']
}, {
fromPath: ['hasChildren'],
toPath: ['hasChildren']
}, {
fromPath: ['parentId'],
toPath: ['relationships', 'parent', 'data', 'id']
}, {
toPath: ['relationships', 'parent', 'data', 'type'],
toValue: 'iterations'
}, {
toPath: ['type'],
toValue: 'iterations'
}
];
}
IterationMapper.prototype.toUIModel = function (arg) {
return switchModel(arg, this.serviceToUiMapTree);
};
IterationMapper.prototype.toServiceModel = function (arg) {
return switchModel(arg, this.uiToServiceMapTree);
};
return IterationMapper;
}());
export { IterationMapper };
var IterationQuery = /** @class */ (function () {
function IterationQuery(store, iterationService) {
this.store = store;
this.iterationService = iterationService;
this.plannerSelector = createFeatureSelector('planner');
this.iterationSelector = createSelector(this.plannerSelector, function (state) { return state.iterations; });
this.iterationSource = this.store.pipe(select(this.iterationSelector));
}
IterationQuery.prototype.getIterations = function () {
return this.iterationSource.pipe(map(function (iterations) {
return Object.keys(iterations).map(function (id) { return iterations[id]; });
}));
};
IterationQuery.prototype.getIterationObservableById = function (id) {
return this.iterationSource.pipe(select(function (state) { return state[id]; }));
};
IterationQuery.prototype.getSelectedIteration = function () {
return this.getIterations()
.pipe(map(function (iterations) {
return iterations.filter(function (it) { return it.selected; });
}), map(function (iterations) {
if (iterations.length === 1) {
return iterations[0];
}
return null;
}));
};
IterationQuery.prototype.getIterationsWithChildren = function () {
var _this = this;
return this.getIterations()
.pipe(map(function (iterations) {
var _loop_1 = function (i) {
iterations[i].children = iterations.filter(function (it) { return it.parentId === iterations[i].id; });
};
for (var i = 0; i < iterations.length; i++) {
_loop_1(i);
}
var allIterations = iterations.filter(function (i) {
return !_this.iterationService.isRootIteration(i.parentPath);
});
return allIterations;
}));
};
IterationQuery.prototype.getIterationForTree = function () {
var _this = this;
return this.getIterationsWithChildren().pipe(map(function (iterations) {
return _this.iterationService.getTopLevelIterations(iterations);
}));
};
IterationQuery.prototype.getActiveIterations = function () {
return this.getIterations().pipe(map(function (iterations) {
return iterations.filter(function (iteration) { return iteration.isActive; });
}));
};
IterationQuery.prototype.deselectAllIteration = function () {
this.store.dispatch(new IterationActions.Select());
};
Object.defineProperty(IterationQuery.prototype, "getIterationIds", {
get: function () {
return this.iterationSource.pipe(map(function (iterations) {
return Object.keys(iterations);
}));
},
enumerable: true,
configurable: true
});
Object.defineProperty(IterationQuery.prototype, "getIterationNames", {
get: function () {
return this.getIterations().pipe(map(function (iterations) { return iterations.map(function (it) { return it.name; }); }));
},
enumerable: true,
configurable: true
});
IterationQuery.decorators = [
{ type: Injectable },
];
/** @nocollapse */
IterationQuery.ctorParameters = function () { return [
{ type: Store, },
{ type: Service, },
]; };
return IterationQuery;
}());
export { IterationQuery };
//# sourceMappingURL=iteration.model.js.map