Commit 21a7b56e authored by Alexander Philipp Nowosad's avatar Alexander Philipp Nowosad
Browse files

Add show fulfilled factors per activity

parent 289f5600
......@@ -127,7 +127,8 @@
</button>
</div>
<div class="modal-body">
<app-method-info [developmentMethod]="modalDevelopmentMethod" [decision]="bmProcess.decisions[modalElement.id]"
<app-method-info [contextSituationalFactors]="bmProcess.situationalFactors"
[developmentMethod]="modalDevelopmentMethod" [decision]="bmProcess.decisions[modalElement.id]"
(updateDecisions)="updateDecisions($event)"></app-method-info>
</div>
</ng-template>
......
......@@ -18,6 +18,32 @@
</ul>
</td>
</tr>
<tr *ngIf="contextSituationalFactors && contextSituationalFactors.length > 0">
<th scope="row">Situational Factors</th>
<td class="show-new-lines">
<table class="table mb-0">
<tbody>
<tr>
<th scope="col">List</th>
<th scope="col">Situational Factor</th>
<th scope="col">Needed Context</th>
<th scope="col">Provided by Building Block</th>
<th scope="col" class="text-center">Fulfilled</th>
</tr>
<tr *ngFor="let factor of factors">
<td>{{factor.list}}</td>
<td>{{factor.name}}</td>
<td>{{factor.needed}}</td>
<td>{{factor.provided}}</td>
<td class="text-center">
<i *ngIf="!factor.fulfills" class="fas fa-times highlight-font-symbol-red"></i>
<i *ngIf="factor.fulfills" class="fas fa-check highlight-font-symbol-green"></i>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<th scope="row">Input Artifacts</th>
<td>
......
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
import { DevelopmentMethod } from '../../development-process-registry/development-method';
import { Decision } from '../../development-process-registry/decision';
import { SituationalFactor } from '../../development-process-registry/situational-factor';
import { SituationalFactorDefinition } from '../../development-process-registry/situational-factor-definition';
@Component({
selector: 'app-method-info',
templateUrl: './method-info.component.html',
styleUrls: ['./method-info.component.css']
})
export class MethodInfoComponent implements OnInit {
export class MethodInfoComponent implements OnInit, OnChanges {
@Input() developmentMethod: DevelopmentMethod;
@Input() decision: Decision;
@Input() contextSituationalFactors: { list: string, element: SituationalFactor }[] = [];
@Output() updateDecisions = new EventEmitter<any>();
factorsMap: { [list: string]: { [name: string]: string } };
factors: { list: string, name: string, needed: string, provided: string, fulfills: boolean }[] = [];
constructor() {
}
ngOnInit() {
}
ngOnChanges(changes: SimpleChanges) {
if (changes.developmentMethod) {
const map = {};
const factors: SituationalFactor[] = changes.developmentMethod.currentValue.situationalFactors.map((facor) => facor.element);
factors.forEach((factor) => {
if (!(factor.factor.list in map)) {
map[factor.factor.list] = {};
}
map[factor.factor.list][factor.factor.name] = factor.value;
});
this.factorsMap = map;
}
if (changes.developmentMethod || changes.contextSituationalFactors) {
this.calculateFactors();
}
}
calculateFactors() {
this.factors = this.contextSituationalFactors.map((factor) => {
const provided = this.getProvidedValue(factor.element.factor);
let fulfills: boolean;
if (provided) {
if (provided === factor.element.value) {
fulfills = true;
} else {
if (factor.element.factor.ordered) {
fulfills = factor.element.factor.values.indexOf(factor.element.value) <= factor.element.factor.values.indexOf(provided);
} else {
fulfills = false;
}
}
} else {
fulfills = false;
}
return {
list: factor.element.factor.list,
name: factor.element.factor.name,
needed: factor.element.value,
provided: provided ? provided : '-',
fulfills,
};
});
}
private getProvidedValue(factor: SituationalFactorDefinition) {
if (factor.list in this.factorsMap) {
const provided = this.factorsMap[factor.list][factor.name];
if (provided) {
return provided;
}
}
return null;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment