Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(link-value): Show message when no search results returned (DEV-846) #736

Merged
merged 1 commit into from May 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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