-
Notifications
You must be signed in to change notification settings - Fork 441
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Authority confidence indicator component
- Loading branch information
1 parent
9ccc5ee
commit 04d0850
Showing
4 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
src/app/dso-shared/dso-edit-metadata/confidence-icon/confidence-icon.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,3 @@ | ||
<i class="fa-fw m-1 p-1" [ngClass]="getConfidenceTypeCSSClass()" | ||
[ngbTooltip]="'helptext.confidence.indicator.' + getConfidenceTypeName() | translate"></i> | ||
|
Empty file.
37 changes: 37 additions & 0 deletions
37
src/app/dso-shared/dso-edit-metadata/confidence-icon/confidence-icon.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,37 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { ConfidenceIconComponent } from './confidence-icon.component'; | ||
import { TranslateModule } from '@ngx-translate/core'; | ||
import { MetadataValue } from '../../../core/shared/metadata.models'; | ||
import { ConfidenceType } from '../../../core/shared/confidence-type'; | ||
|
||
describe('ConfidenceIconComponent', () => { | ||
let component: ConfidenceIconComponent; | ||
let fixture: ComponentFixture<ConfidenceIconComponent>; | ||
let metadataValue: MetadataValue; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ ConfidenceIconComponent ], | ||
imports: [TranslateModule.forRoot()] | ||
}) | ||
.compileComponents(); | ||
|
||
metadataValue = Object.assign(new MetadataValue(), { | ||
value: 'Regular Name', | ||
language: 'en', | ||
place: 0, | ||
authority: 'Authority value', | ||
confidence: ConfidenceType.CF_ACCEPTED | ||
}); | ||
|
||
fixture = TestBed.createComponent(ConfidenceIconComponent); | ||
component = fixture.componentInstance; | ||
component.mdValue = metadataValue; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
44 changes: 44 additions & 0 deletions
44
src/app/dso-shared/dso-edit-metadata/confidence-icon/confidence-icon.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,44 @@ | ||
import { Component, Input } from '@angular/core'; | ||
import { ConfidenceType } from 'src/app/core/shared/confidence-type'; | ||
import { MetadataValue } from '../../../core/shared/metadata.models'; | ||
|
||
@Component({ | ||
selector: 'ds-confidence-icon', | ||
templateUrl: './confidence-icon.component.html', | ||
styleUrls: ['./confidence-icon.component.scss'] | ||
}) | ||
/** | ||
* Component displaying a icon indicator confidence of an authority value | ||
*/ | ||
export class ConfidenceIconComponent { | ||
|
||
@Input() mdValue: MetadataValue; | ||
|
||
getConfidenceTypeCSSClass() { | ||
switch (this.mdValue.confidence) { | ||
case ConfidenceType.CF_ACCEPTED: return 'far fa-circle-check'; | ||
case ConfidenceType.CF_UNCERTAIN: return 'fa fa-gear'; | ||
case ConfidenceType.CF_AMBIGUOUS: return 'far fa-circle-question'; | ||
case ConfidenceType.CF_NOTFOUND: return 'far fa-thumbs-down'; | ||
case ConfidenceType.CF_FAILED: return 'fa fa-triangle-exclamation'; | ||
case ConfidenceType.CF_REJECTED: return 'fas fa-turn-down'; | ||
case ConfidenceType.CF_NOVALUE: return 'fas fa-ban'; | ||
case ConfidenceType.CF_UNSET: return 'fa fa-xmark'; | ||
} | ||
return 'fa fa-xmark'; | ||
} | ||
|
||
getConfidenceTypeName() { | ||
switch (this.mdValue.confidence) { | ||
case ConfidenceType.CF_ACCEPTED: return 'accepted'; | ||
case ConfidenceType.CF_UNCERTAIN: return 'uncertain'; | ||
case ConfidenceType.CF_AMBIGUOUS: return 'ambigous'; | ||
case ConfidenceType.CF_NOTFOUND: return 'notfound'; | ||
case ConfidenceType.CF_FAILED: return 'failed'; | ||
case ConfidenceType.CF_REJECTED: return 'rejected'; | ||
case ConfidenceType.CF_NOVALUE: return 'novalue'; | ||
case ConfidenceType.CF_UNSET: return 'unset'; | ||
} | ||
return 'unset'; | ||
} | ||
} |