Browse Source

fix(lint): resolve warnings

pull/6396/head
Kenrick Tandrian 1 month ago
parent
commit
3d311f07d9
  1. 10
      libs/ui/src/lib/assistant/assistant-list-item/assistant-list-item.component.ts
  2. 68
      libs/ui/src/lib/assistant/assistant.component.ts

10
libs/ui/src/lib/assistant/assistant-list-item/assistant-list-item.component.ts

@ -32,13 +32,10 @@ export class GfAssistantListItemComponent
implements FocusableOption, OnChanges
{
@HostBinding('attr.tabindex') tabindex = -1;
@HostBinding('class.has-focus') get getHasFocus() {
return this.hasFocus;
}
@Input() item: SearchResultItem;
@ViewChild('link') public linkElement: ElementRef;
@ViewChild('link') public linkElement: ElementRef<HTMLAnchorElement>;
public hasFocus = false;
public queryParams: Params;
@ -48,6 +45,11 @@ export class GfAssistantListItemComponent
public constructor(private changeDetectorRef: ChangeDetectorRef) {}
@HostBinding('class.has-focus')
public get getHasFocus() {
return this.hasFocus;
}
public ngOnChanges() {
if (this.item?.mode === SearchMode.ACCOUNT) {
this.queryParams = {

68
libs/ui/src/lib/assistant/assistant.component.ts

@ -85,37 +85,7 @@ import {
templateUrl: './assistant.html'
})
export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
@HostListener('document:keydown', ['$event']) onKeydown(
event: KeyboardEvent
) {
if (!this.isOpen) {
return;
}
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
for (const item of this.assistantListItems) {
item.removeFocus();
}
this.keyManager.onKeydown(event);
const currentAssistantListItem = this.getCurrentAssistantListItem();
if (currentAssistantListItem?.linkElement) {
currentAssistantListItem.linkElement.nativeElement?.scrollIntoView({
behavior: 'smooth',
block: 'center'
});
}
} else if (event.key === 'Enter') {
const currentAssistantListItem = this.getCurrentAssistantListItem();
if (currentAssistantListItem?.linkElement) {
currentAssistantListItem.linkElement.nativeElement?.click();
event.stopPropagation();
}
}
}
public static readonly SEARCH_RESULTS_DEFAULT_LIMIT = 5;
@Input() deviceType: string;
@Input() hasPermissionToAccessAdminControl: boolean;
@ -124,13 +94,12 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
@Input() user: User;
@ViewChild('menuTrigger') menuTriggerElement: MatMenuTrigger;
@ViewChild('search', { static: true }) searchElement: ElementRef;
@ViewChild('search', { static: true })
searchElement: ElementRef<HTMLInputElement>;
@ViewChildren(GfAssistantListItemComponent)
assistantListItems: QueryList<GfAssistantListItemComponent>;
public static readonly SEARCH_RESULTS_DEFAULT_LIMIT = 5;
public accounts: AccountWithPlatform[] = [];
public assetClasses: Filter[] = [];
public dateRangeFormControl = new FormControl<string | null>(null);
@ -187,6 +156,37 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
addIcons({ closeCircleOutline, closeOutline, searchOutline });
}
@HostListener('document:keydown', ['$event'])
public onKeydown(event: KeyboardEvent) {
if (!this.isOpen) {
return;
}
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
for (const item of this.assistantListItems) {
item.removeFocus();
}
this.keyManager.onKeydown(event);
const currentAssistantListItem = this.getCurrentAssistantListItem();
if (currentAssistantListItem?.linkElement) {
currentAssistantListItem.linkElement.nativeElement?.scrollIntoView({
behavior: 'smooth',
block: 'center'
});
}
} else if (event.key === 'Enter') {
const currentAssistantListItem = this.getCurrentAssistantListItem();
if (currentAssistantListItem?.linkElement) {
currentAssistantListItem.linkElement.nativeElement?.click();
event.stopPropagation();
}
}
}
public ngOnInit() {
this.assetClasses = Object.keys(AssetClass).map((assetClass) => {
return {

Loading…
Cancel
Save