UNPKG

fabric8-analytics-dependency-editor-jyas

Version:
90 lines 3.67 kB
import { Component, Input, Output, EventEmitter } from '@angular/core'; import * as _ from 'lodash'; import { DependencyEditorService } from '../shared/dependency-editor.service'; import { DependencySnapshot } from '../utils/dependency-snapshot'; var ListElementComponent = /** @class */ (function () { function ListElementComponent(service) { this.service = service; this.companionAdded = new EventEmitter(); this.tagAdded = new EventEmitter(); this.companionReleased = new EventEmitter(); this.companionRemoved = new EventEmitter(); this.dep = []; this.showAlternateSection = false; this.saveTagname = false; this.isOpen = false; } ListElementComponent.prototype.ngOnInit = function () { if (this.dependency && this.dependency.alternate) { this.showAlternateSection = true; } }; ListElementComponent.prototype.validateValues = function (value) { if (value < 0) { return 'NA'; } return value; }; ListElementComponent.prototype.changeTagname = function (saveTag) { this.saveTagname = !saveTag; this.dep.splice(0); this.dep.push({ name: this.dependency, type: this.saveTagname }); if (this.saveTagname === true) { this.tagAdded.emit(this.dep); this.companionAdded.emit(this.dependency); } else { this.tagAdded.emit(this.dep); this.companionReleased.emit(this.dependency); } }; ListElementComponent.prototype.addDependency = function () { var objToEmit = { depFull: this.dependency, depSnapshot: null, action: 'add' }; }; ListElementComponent.prototype.removeCompanion = function () { this.companionRemoved.emit(this.dependency); }; ListElementComponent.prototype.removeDependency = function () { this.service.removeDependency(this.dependency); }; ListElementComponent.prototype.useAlternate = function () { var alternate = this.dependency.alternate; var indexFull = _.findIndex(DependencySnapshot.DEP_FULL_ADDED, { name: alternate.name }); var indexSnapshot = _.findIndex(DependencySnapshot.DEP_SNAPSHOT_ADDED, { package: alternate.name }); DependencySnapshot.DEP_FULL_ADDED.splice(indexFull, 1, alternate.alternate); DependencySnapshot.DEP_SNAPSHOT_ADDED.splice(indexSnapshot, 1, { package: alternate.alternate.name, version: alternate.alternate.version }); this.showAlternateSection = false; }; ListElementComponent.prototype.ignoreAlternate = function () { this.showAlternateSection = false; }; ListElementComponent.decorators = [ { type: Component, args: [{ selector: 'app-list-element', styles: [require('./list-element.component.css').toString()], template: require('./list-element.component.html') },] }, ]; /** @nocollapse */ ListElementComponent.ctorParameters = function () { return [ { type: DependencyEditorService, }, ]; }; ListElementComponent.propDecorators = { 'dependency': [{ type: Input },], 'fromAddDependency': [{ type: Input },], 'companionAdded': [{ type: Output },], 'tagAdded': [{ type: Output },], 'companionReleased': [{ type: Output },], 'companionRemoved': [{ type: Output },], }; return ListElementComponent; }()); export { ListElementComponent }; //# sourceMappingURL=list-element.component.js.map