fabric8-planner
Version:
A planner front-end for Fabric8.
93 lines • 3.33 kB
JavaScript
import { Injectable } from '@angular/core';
import { ofType } from '@ngrx/effects';
import { Notifications, NotificationType } from 'ngx-base';
import { of as ObservableOf, pipe } from 'rxjs';
import { map } from 'rxjs/operators';
import { withLatestFrom } from 'rxjs/operators';
import { AND, EQUAL } from '../services/query-keys';
export var filterTypeWithSpace = function (x, y) { return pipe(ofType(x), withLatestFrom(y)); };
var ErrorHandler = /** @class */ (function () {
function ErrorHandler(notifications) {
this.notifications = notifications;
}
ErrorHandler.prototype.handleError = function (error, msg, nextActions) {
this.notifyError(msg);
console.log('#################', error);
return Array.isArray(nextActions) ? nextActions : [nextActions];
};
ErrorHandler.prototype.notifyError = function (msg) {
try {
this.notifications.message({
message: msg,
type: NotificationType.DANGER
});
}
catch (e) {
console.log('Problem in fetching Areas.');
}
};
ErrorHandler.decorators = [
{ type: Injectable },
];
/** @nocollapse */
ErrorHandler.ctorParameters = function () { return [
{ type: Notifications, },
]; };
return ErrorHandler;
}());
export { ErrorHandler };
export function workitemMatchesFilter(route, filterService, workItemService, workitem, spaceId) {
var currentRoute = route.queryParams;
if ((currentRoute['q']
&& currentRoute.hasOwnProperty('q')
&& currentRoute['q'].includes('boardContextId')) ||
(document.location.pathname.indexOf('/query') > -1)) {
return ObservableOf(workitem);
}
if (Object.keys(currentRoute).length === 0 && currentRoute.constructor === Object) {
return ObservableOf(workitem);
}
else {
var wiQuery = filterService.queryBuilder('number', EQUAL, workitem.number.toString());
var exp = filterService.queryJoiner(filterService.queryToJson(currentRoute['q']), AND, wiQuery);
var spaceQuery = filterService.queryBuilder('space', EQUAL, spaceId);
var finalQuery = filterService.queryJoiner(exp, AND, spaceQuery);
var searchPayload = {
expression: finalQuery
};
return workItemService.getWorkItems(1, searchPayload)
.pipe(map(function (data) { return data.totalCount; }), map(function (count) {
workitem.bold = count > 0;
return workitem;
}));
}
}
export function createLinkObject(parentWorkItemId, childWorkItemId, linkId) {
return {
'type': 'workitemlinks',
'attributes': {
'version': 0
},
'relationships': {
'link_type': {
'data': {
'id': linkId,
'type': 'workitemlinktypes'
}
},
'source': {
'data': {
'id': parentWorkItemId,
'type': 'workitems'
}
},
'target': {
'data': {
'id': childWorkItemId,
'type': 'workitems'
}
}
}
};
}
//# sourceMappingURL=work-item-utils.js.map