fabric8-planner
Version:
A planner front-end for Fabric8.
114 lines • 4.09 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 { modelService, switchModel } from './common.model';
var AreaModel = /** @class */ (function (_super) {
__extends(AreaModel, _super);
function AreaModel() {
return _super !== null && _super.apply(this, arguments) || this;
}
return AreaModel;
}(modelService));
export { AreaModel };
var AreaAttributes = /** @class */ (function () {
function AreaAttributes() {
}
return AreaAttributes;
}());
export { AreaAttributes };
var AreaLinks = /** @class */ (function () {
function AreaLinks() {
}
return AreaLinks;
}());
export { AreaLinks };
var AreaRelations = /** @class */ (function () {
function AreaRelations() {
}
return AreaRelations;
}());
export { AreaRelations };
var AreaMapper = /** @class */ (function () {
function AreaMapper() {
this.serviceToUiMapTree = [{
fromPath: ['id'],
toPath: ['id']
}, {
fromPath: ['attributes', 'name'],
toPath: ['name']
}, {
fromPath: ['attributes', 'parent_path'],
toPath: ['parentPath']
}, {
fromPath: ['attributes', 'parent_path_resolved'],
toPath: ['parentPathResolved']
}];
this.uiToServiceMapTree = [{
toPath: ['id'],
fromPath: ['id']
}, {
toPath: ['attributes', 'name'],
fromPath: ['name']
}, {
toPath: ['attributes', 'parent_path'],
fromPath: ['parentPath']
}, {
toPath: ['attributes', 'parent_path_resolved'],
fromPath: ['parentPathResolved']
}, {
toPath: ['type'],
toValue: 'areas'
}];
}
AreaMapper.prototype.toUIModel = function (arg) {
return switchModel(arg, this.serviceToUiMapTree);
};
AreaMapper.prototype.toServiceModel = function (arg) {
return switchModel(arg, this.uiToServiceMapTree);
};
return AreaMapper;
}());
export { AreaMapper };
var AreaQuery = /** @class */ (function () {
function AreaQuery(store) {
this.store = store;
this.plannerSelector = createFeatureSelector('planner');
this.areaSelector = createSelector(this.plannerSelector, function (state) { return state.areas; });
this.areaSource = this.store.pipe(select(this.areaSelector));
}
AreaQuery.prototype.getAreas = function () {
return this.areaSource
.pipe(map(function (areas) {
return Object.keys(areas).map(function (id) { return areas[id]; });
}));
};
AreaQuery.prototype.getAreaIds = function () {
return this.areaSource.pipe(map(function (areas) { return Object.keys(areas); }));
};
AreaQuery.prototype.getAreaNames = function () {
return this.getAreas().pipe(map(function (areas) { return areas.map(function (a) { return a.name; }); }));
};
AreaQuery.prototype.getAreaObservableById = function (id) {
return this.areaSource.pipe(select(function (areas) { return areas[id]; }));
};
AreaQuery.decorators = [
{ type: Injectable },
];
/** @nocollapse */
AreaQuery.ctorParameters = function () { return [
{ type: Store, },
]; };
return AreaQuery;
}());
export { AreaQuery };
//# sourceMappingURL=area.model.js.map