UNPKG

fabric8-planner

Version:
61 lines 2.5 kB
import { Component, EventEmitter, Input, Output } from '@angular/core'; import { Store } from '@ngrx/store'; import { first } from 'rxjs/operators'; import { Delete } from '../../actions/work-item.actions'; import { PermissionQuery } from '../../models/permission.model'; import { ModalService } from '../../services/modal.service'; var DeleteWorkItemComponent = /** @class */ (function () { function DeleteWorkItemComponent(modalService, store, permissionQuery) { this.modalService = modalService; this.store = store; this.permissionQuery = permissionQuery; this.detailContext = ''; this.onDelete = new EventEmitter; } Object.defineProperty(DeleteWorkItemComponent.prototype, "workItemInput", { set: function (val) { if (val) { this.workItem = val; this.allowDelete = this.permissionQuery.isAllowedToDelete(val); } }, enumerable: true, configurable: true }); DeleteWorkItemComponent.prototype.deleteWorkItem = function (event) { var _this = this; var note = 'Are you sure you want to delete this work item?'; if (this.workItem.hasChildren) { note = 'This work item has children. ' + note; } this.modalService.openModal('Delete Work Item', note, 'Delete', 'deleteWorkItem') .pipe(first()).subscribe(function (actionKey) { if (actionKey === 'deleteWorkItem') { _this.onDelete.emit(); _this.store.dispatch(new Delete(_this.workItem)); } }); }; DeleteWorkItemComponent.decorators = [ { type: Component, args: [{ selector: 'f8-delete-workitem', template: require('./delete-work-item.component.html'), styles: [require('./delete-work-item.component.css').toString()] },] }, ]; /** @nocollapse */ DeleteWorkItemComponent.ctorParameters = function () { return [ { type: ModalService, }, { type: Store, }, { type: PermissionQuery, }, ]; }; DeleteWorkItemComponent.propDecorators = { 'workItemInput': [{ type: Input, args: ['workItem',] },], 'detailContext': [{ type: Input },], 'onDelete': [{ type: Output },], }; return DeleteWorkItemComponent; }()); export { DeleteWorkItemComponent }; //# sourceMappingURL=delete-work-item.component.js.map