my-test123
Version:
A planner front-end for Fabric8.
100 lines • 4.45 kB
JavaScript
import { Observable } from 'rxjs/Observable';
import { ActivatedRoute } from '@angular/router';
import { Component, Input } from '@angular/core';
import { AuthenticationService } from 'ngx-login-client';
import { Spaces } from 'ngx-fabric8-wit';
import { FilterService } from '../../services/filter.service';
import { GroupTypesService } from '../../services/group-types.service';
// ngrx stuff
import { Store } from '@ngrx/store';
import * as GroupTypeActions from './../../actions/group-type.actions';
var GroupTypesComponent = /** @class */ (function () {
function GroupTypesComponent(auth, filterService, groupTypesService, route, spaces, store) {
this.auth = auth;
this.filterService = filterService;
this.groupTypesService = groupTypesService;
this.route = route;
this.spaces = spaces;
this.store = store;
this.sidePanelOpen = true;
this.authUser = null;
this.eventListeners = [];
this.startedCheckingURL = false;
this.showTree = '';
}
GroupTypesComponent.prototype.ngOnInit = function () {
var _this = this;
var groupTypesData = this.store
.select('listPage')
.select('groupTypes')
.filter(function (types) { return !!types.length; });
var spaceData = this.store
.select('listPage')
.select('space')
.filter(function (space) { return space !== null; });
this.eventListeners.push(Observable.combineLatest(groupTypesData, spaceData).subscribe(function (_a) {
var types = _a[0], space = _a[1];
_this.groupTypes = types;
_this.spaceId = space.id;
if (!_this.startedCheckingURL) {
_this.checkURL();
}
}));
};
GroupTypesComponent.prototype.ngOnDestroy = function () {
this.eventListeners.forEach(function (e) { return e.unsubscribe(); });
};
GroupTypesComponent.prototype.fnBuildQueryParam = function (witGroup) {
//Query for work item type group
var type_query = this.filterService.queryBuilder('typegroup.name', this.filterService.equal_notation, witGroup.name);
//Query for space
var space_query = this.filterService.queryBuilder('space', this.filterService.equal_notation, this.spaceId);
//Join type and space query
var first_join = this.filterService.queryJoiner({}, this.filterService.and_notation, space_query);
var second_join = this.filterService.queryJoiner(first_join, this.filterService.and_notation, type_query);
//second_join gives json object
return this.filterService.jsonToQuery(second_join);
//reverse function jsonToQuery(second_join);
};
GroupTypesComponent.prototype.checkURL = function () {
var _this = this;
this.startedCheckingURL = true;
this.eventListeners.push(this.route.queryParams.subscribe(function (val) {
if (val.hasOwnProperty('q')) {
var selectedTypeGroupName_1 = _this.filterService.getConditionFromQuery(val.q, 'typegroup.name');
var selectedTypeGroup = _this.groupTypes.find(function (g) { return g.name === selectedTypeGroupName_1; });
if (!selectedTypeGroup.selected) {
_this.store.dispatch(new GroupTypeActions.SelectType(selectedTypeGroup));
}
}
if (val.hasOwnProperty('showTree')) {
_this.showTree = val.showTree;
}
else {
_this.showTree = '';
}
}));
};
GroupTypesComponent.decorators = [
{ type: Component, args: [{
selector: 'group-types',
template: require('./group-types-panel.component.html'),
styles: [require('./group-types-panel.component.css').toString()]
},] },
];
/** @nocollapse */
GroupTypesComponent.ctorParameters = function () { return [
{ type: AuthenticationService, },
{ type: FilterService, },
{ type: GroupTypesService, },
{ type: ActivatedRoute, },
{ type: Spaces, },
{ type: Store, },
]; };
GroupTypesComponent.propDecorators = {
'sidePanelOpen': [{ type: Input },],
};
return GroupTypesComponent;
}());
export { GroupTypesComponent };
//# sourceMappingURL=group-types-panel.component.js.map