-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add modal to add performance metrics that have been deleted or untrac…
…ked in the kpi management page
- Loading branch information
Showing
7 changed files
with
209 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...-wizard/pre-visit/company-kpi-details/kpm-database-modal/kpm-database-modal.component.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.popup-header{ | ||
font-weight: normal; | ||
} |
45 changes: 45 additions & 0 deletions
45
...wizard/pre-visit/company-kpi-details/kpm-database-modal/kpm-database-modal.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<div [ngClass]="{'window-overlay': displayModal}"></div> | ||
<div class="popup" [ngClass]="{'open': displayModal }"> | ||
<div class="popup-header">KPMs Typically Associated With | ||
<span class="bold" [innerHTML]="keyPerformanceIndicator.htmlLabel"></span> | ||
<button type="button" class="btn-close float-end" aria-label="Close" (click)="closeModal()"></button> | ||
</div> | ||
<div class="popup-body"> | ||
<ng-template [ngIf]="keyPerformanceMetricOptions.length > 0" [ngIfElse]="noOptionsBlock"> | ||
<table class="table table-bordered table-hover table-sm"> | ||
<tbody> | ||
<tr class="clickable" (click)="toggleMetric(performanceMetric)" | ||
*ngFor="let performanceMetric of keyPerformanceMetricOptions"> | ||
<td class="add-td text-center"> | ||
<a class="click-link"> | ||
<ng-template [ngIf]="addMetricValues.includes(performanceMetric.value)" | ||
[ngIfElse]="addMetricBlock"> | ||
<fa-icon [icon]="faCheck"></fa-icon> | ||
</ng-template> | ||
<ng-template #addMetricBlock> | ||
<fa-icon [icon]="faPlus"></fa-icon> | ||
</ng-template> | ||
</a> | ||
</td> | ||
<td> | ||
<span [innerHTML]="performanceMetric.htmlLabel"></span> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</ng-template> | ||
<ng-template #noOptionsBlock> | ||
<div class="alert alert-info"> | ||
All metrics in our system that are associated with <span class="bold" | ||
[innerHTML]="keyPerformanceIndicator.htmlLabel"></span> are being tracked. | ||
</div> | ||
</ng-template> | ||
<hr> | ||
</div> | ||
<div class="popup-footer d-flex justify-content-end"> | ||
<button class="btn btn-secondary btn-sm me-2" (click)="closeModal()">Cancel</button> | ||
<button class="btn btn-sm btn-success" (click)="addMetrics()" [disabled]="addMetricValues.length == 0"><fa-icon | ||
[icon]="faPlus"></fa-icon> Add {{addMetricValues.length}} | ||
Metrics</button> | ||
</div> | ||
</div> |
23 changes: 23 additions & 0 deletions
23
...ard/pre-visit/company-kpi-details/kpm-database-modal/kpm-database-modal.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { KpmDatabaseModalComponent } from './kpm-database-modal.component'; | ||
|
||
describe('KpmDatabaseModalComponent', () => { | ||
let component: KpmDatabaseModalComponent; | ||
let fixture: ComponentFixture<KpmDatabaseModalComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [KpmDatabaseModalComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(KpmDatabaseModalComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
71 changes: 71 additions & 0 deletions
71
...p-wizard/pre-visit/company-kpi-details/kpm-database-modal/kpm-database-modal.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { ChangeDetectorRef, Component, EventEmitter, Input, Output } from '@angular/core'; | ||
import { faCheck, faPlus, IconDefinition } from '@fortawesome/free-solid-svg-icons'; | ||
import { IdbKeyPerformanceIndicator } from 'src/app/models/keyPerformanceIndicator'; | ||
import { getPerformanceMetrics, KeyPerformanceMetric, KeyPerformanceMetricValue } from 'src/app/shared/constants/keyPerformanceMetrics'; | ||
|
||
@Component({ | ||
selector: 'app-kpm-database-modal', | ||
templateUrl: './kpm-database-modal.component.html', | ||
styleUrl: './kpm-database-modal.component.css' | ||
}) | ||
export class KpmDatabaseModalComponent { | ||
@Output('emitClose') | ||
emitClose: EventEmitter<boolean> = new EventEmitter<boolean>(); | ||
@Input({ required: true }) | ||
keyPerformanceIndicator: IdbKeyPerformanceIndicator; | ||
@Output() | ||
emitAddMetrics: EventEmitter<Array<KeyPerformanceMetric>> = new EventEmitter<Array<KeyPerformanceMetric>>(); | ||
|
||
faPlus: IconDefinition = faPlus; | ||
faCheck: IconDefinition = faCheck; | ||
displayModal: boolean = false; | ||
|
||
keyPerformanceMetricOptions: Array<KeyPerformanceMetric>; | ||
addMetricValues: Array<KeyPerformanceMetricValue> = []; | ||
constructor(private cd: ChangeDetectorRef) { | ||
|
||
} | ||
|
||
ngOnInit() { | ||
let currentTrackedMetrics: Array<KeyPerformanceMetricValue> = this.keyPerformanceIndicator.performanceMetrics.flatMap(metric => { | ||
return metric.value; | ||
}) | ||
|
||
this.keyPerformanceMetricOptions = new Array(); | ||
|
||
let tmpKeyPerformanceMetricOptions: Array<KeyPerformanceMetric> = getPerformanceMetrics(this.keyPerformanceIndicator.optionValue, this.keyPerformanceIndicator.guid) | ||
tmpKeyPerformanceMetricOptions.forEach(option => { | ||
if (currentTrackedMetrics.includes(option.value) == false) { | ||
this.keyPerformanceMetricOptions.push(option); | ||
} | ||
}); | ||
} | ||
|
||
ngAfterViewInit() { | ||
this.displayModal = true; | ||
this.cd.detectChanges(); | ||
} | ||
|
||
closeModal() { | ||
this.displayModal = false; | ||
this.emitClose.emit(true); | ||
} | ||
|
||
toggleMetric(keyPerformanceMetric: KeyPerformanceMetric) { | ||
if (this.addMetricValues.includes(keyPerformanceMetric.value)) { | ||
this.addMetricValues = this.addMetricValues.filter(value => { | ||
return value != keyPerformanceMetric.value | ||
}); | ||
} else { | ||
this.addMetricValues.push(keyPerformanceMetric.value); | ||
} | ||
} | ||
|
||
addMetrics() { | ||
let metricsToAdd: Array<KeyPerformanceMetric> = this.keyPerformanceMetricOptions.filter(option => { | ||
return this.addMetricValues.includes(option.value) | ||
}) | ||
this.emitAddMetrics.emit(metricsToAdd); | ||
this.closeModal(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters