my-test123
Version:
A planner front-end for Fabric8.
97 lines • 4.24 kB
JavaScript
import { trimEnd } from 'lodash';
import { Component, Input, ViewChild } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { Broadcaster } from 'ngx-base';
import { AuthenticationService } from 'ngx-login-client';
import { Spaces } from 'ngx-fabric8-wit';
import { WorkItemService } from '../../services/work-item.service';
var WorkItemDetailAddTypeSelectorComponent = /** @class */ (function () {
function WorkItemDetailAddTypeSelectorComponent(router, route, broadcaster, workItemService, auth, spaces) {
this.router = router;
this.route = route;
this.broadcaster = broadcaster;
this.workItemService = workItemService;
this.auth = auth;
this.spaces = spaces;
this.wiTypes = [];
this.takeFromInput = false;
this.loggedIn = false;
this.workItemTypes = [];
this.spaceSubscription = null;
}
WorkItemDetailAddTypeSelectorComponent.prototype.ngOnInit = function () {
var _this = this;
this.loggedIn = this.auth.isLoggedIn();
this.spaceSubscription = this.spaces.current.subscribe(function (space) {
if (space) {
console.log('[WorkItemDetailAddTypeSelectorComponent] New Space selected: ' + space.attributes.name);
_this.getWorkItemTypes();
}
else {
console.log('[WorkItemDetailAddTypeSelectorComponent] Space deselected.');
_this.workItemTypes = [];
}
});
};
WorkItemDetailAddTypeSelectorComponent.prototype.ngOnChanges = function () {
if (this.takeFromInput) {
this.workItemTypes = this.wiTypes;
}
};
//Detailed add functions
WorkItemDetailAddTypeSelectorComponent.prototype.getWorkItemTypes = function () {
var _this = this;
if (this.takeFromInput) {
this.workItemTypes = this.wiTypes;
}
else {
this.workItemService.getWorkItemTypes()
.subscribe(function (types) {
_this.workItemTypes = types;
});
}
};
WorkItemDetailAddTypeSelectorComponent.prototype.closePanel = function () {
this.workItemDetailAddTypeSelectorWidget.close();
};
// optional, we can supply context area and iteration that is
// appended to the next url to be consumed by the create dialog
// for pre-selecting values.
WorkItemDetailAddTypeSelectorComponent.prototype.openPanel = function (iterationId, areaId) {
this.selectedIterationId = iterationId;
this.selectedAreaId = areaId;
this.workItemDetailAddTypeSelectorWidget.open();
};
WorkItemDetailAddTypeSelectorComponent.prototype.onChangeType = function (type) {
this.workItemDetailAddTypeSelectorWidget.close();
this.router.navigateByUrl(trimEnd(this.router.url.split('plan')[0], '/')
+ '/plan/detail/new?type='
+ type.id
+ (this.selectedIterationId ? '&iteration=' + this.selectedIterationId : '')
+ (this.selectedAreaId ? '&area=' + this.selectedAreaId : ''));
};
WorkItemDetailAddTypeSelectorComponent.decorators = [
{ type: Component, args: [{
selector: 'detail-add-type-selector',
template: require('./work-item-create.component.html'),
styles: [require('./work-item-create.component.css').toString()]
},] },
];
/** @nocollapse */
WorkItemDetailAddTypeSelectorComponent.ctorParameters = function () { return [
{ type: Router, },
{ type: ActivatedRoute, },
{ type: Broadcaster, },
{ type: WorkItemService, },
{ type: AuthenticationService, },
{ type: Spaces, },
]; };
WorkItemDetailAddTypeSelectorComponent.propDecorators = {
'wiTypes': [{ type: Input },],
'takeFromInput': [{ type: Input },],
'workItemDetailAddTypeSelectorWidget': [{ type: ViewChild, args: ['detailAddTypeSelector',] },],
};
return WorkItemDetailAddTypeSelectorComponent;
}());
export { WorkItemDetailAddTypeSelectorComponent };
//# sourceMappingURL=work-item-create.component.js.map