Skip to content

Commit

Permalink
feat(link-value): UI now shows that there are no search results (#736)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelez committed May 12, 2022
1 parent f54dafc commit 88b81bf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Expand Up @@ -14,6 +14,9 @@
</span>
</div>
<mat-autocomplete #auto="matAutocomplete" [displayWith]="displayResource">
<mat-option *ngIf="showNoResultsMessage" disabled="true">
No results were found.
</mat-option>
<mat-option *ngFor="let rc of resourceClasses" (click)="openDialog('createLinkResource', $event, propIri, rc)">
Create New: {{rc?.label}}
</mat-option>
Expand Down
Expand Up @@ -71,6 +71,7 @@ export class LinkValueComponent extends BaseValueDirective implements OnInit, On
properties: ResourcePropertyDefinition[];

loadingResults = false;
showNoResultsMessage = false;

constructor(
private _dialog: MatDialog,
Expand Down Expand Up @@ -98,6 +99,8 @@ export class LinkValueComponent extends BaseValueDirective implements OnInit, On
* @param searchTerm label to be searched
*/
searchByLabel(searchTerm: string) {
this.showNoResultsMessage = false;

// at least 3 characters are required
if (typeof searchTerm === 'string' && searchTerm.length >= 3) {
this.loadingResults = true;
Expand All @@ -106,6 +109,7 @@ export class LinkValueComponent extends BaseValueDirective implements OnInit, On
(response: ReadResourceSequence) => {
this.resources = response.resources;
this.loadingResults = false;
this.showNoResultsMessage = this.resources.length > 0 ? false : true;
});
} else {
this.resources = [];
Expand Down

0 comments on commit 88b81bf

Please sign in to comment.