Add aria-label and loadingInitialValue property to DsDynamicOneboxComponent

This commit is contained in:
Toni Prieto
2024-01-03 11:08:07 +01:00
parent 8d25ba764c
commit c596c6eb14
2 changed files with 16 additions and 2 deletions

View File

@@ -21,8 +21,8 @@
</ng-template>
<div *ngIf="!(isHierarchicalVocabulary() | async)" class="position-relative right-addon">
<i *ngIf="searching" class="fas fa-circle-notch fa-spin fa-2x fa-fw text-primary position-absolute mt-1 p-0" aria-hidden="true"></i>
<i *ngIf="!searching"
<i *ngIf="searching || loadingInitialValue" class="fas fa-circle-notch fa-spin fa-2x fa-fw text-primary position-absolute mt-1 p-0" aria-hidden="true"></i>
<i *ngIf="!searching && !loadingInitialValue"
dsAuthorityConfidenceState
class="far fa-circle fa-2x fa-fw position-absolute mt-1 p-0"
aria-hidden="true"
@@ -32,6 +32,7 @@
class="form-control"
[attr.aria-labelledby]="'label_' + model.id"
[attr.autoComplete]="model.autoComplete"
[attr.aria-label]="model.label | translate"
[class.is-invalid]="showErrorMessages"
[id]="model.id"
[inputFormatter]="formatter"
@@ -58,6 +59,7 @@
<input class="form-control"
[attr.aria-labelledby]="'label_' + model.id"
[attr.autoComplete]="model.autoComplete"
[attr.aria-label]="model.label | translate"
[class.is-invalid]="showErrorMessages"
[class.tree-input]="!model.readOnly"
[id]="id"

View File

@@ -55,6 +55,7 @@ export class DsDynamicOneboxComponent extends DsDynamicVocabularyComponent imple
pageInfo: PageInfo = new PageInfo();
searching = false;
loadingInitialValue = false;
searchFailed = false;
hideSearchingWhenUnsubscribed$ = new Observable(() => () => this.changeSearchingStatus(false));
click$ = new Subject<string>();
@@ -151,6 +152,15 @@ export class DsDynamicOneboxComponent extends DsDynamicVocabularyComponent imple
this.cdr.detectChanges();
}
/**
* Changes the loadingInitialValue status
* @param status
*/
changeLoadingInitialValueStatus(status: boolean) {
this.loadingInitialValue = status;
this.cdr.detectChanges();
}
/**
* Checks if configured vocabulary is Hierarchical or not
*/
@@ -257,8 +267,10 @@ export class DsDynamicOneboxComponent extends DsDynamicVocabularyComponent imple
setCurrentValue(value: any, init = false): void {
let result: string;
if (init) {
this.changeLoadingInitialValueStatus(true);
this.getInitValueFromModel()
.subscribe((formValue: FormFieldMetadataValueObject) => {
this.changeLoadingInitialValueStatus(false);
this.currentValue = formValue;
this.cdr.detectChanges();
});