|
|
|
@ -11,6 +11,8 @@ import { IHALCollection } from 'core-app/core/apiv3/types/hal-collection.type'; |
|
|
|
|
import { finalize } from 'rxjs/operators'; |
|
|
|
|
import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service'; |
|
|
|
|
import { HttpClient } from '@angular/common/http'; |
|
|
|
|
import { KeyCodes } from 'core-app/shared/helpers/keyCodes.enum'; |
|
|
|
|
import { projectListActionSelector } from 'core-app/shared/components/project-list/project-list.component'; |
|
|
|
|
|
|
|
|
|
@Injectable() |
|
|
|
|
export class SearchableProjectListService { |
|
|
|
@ -25,7 +27,7 @@ export class SearchableProjectListService { |
|
|
|
|
this.searchText$.next(val); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
searchText$ = new BehaviorSubject(''); |
|
|
|
|
searchText$ = new BehaviorSubject<string>(''); |
|
|
|
|
|
|
|
|
|
allProjects$ = new BehaviorSubject<IProject[]>([]); |
|
|
|
|
|
|
|
|
@ -73,4 +75,30 @@ export class SearchableProjectListService { |
|
|
|
|
], |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
registerArrowNavigationOnItems():void { |
|
|
|
|
let currentIndex = -1; |
|
|
|
|
|
|
|
|
|
document.addEventListener('keydown', (event) => { |
|
|
|
|
// Todo: Instead of collecting the items every time, do it once at the beginning.
|
|
|
|
|
// Keep in mind that the list needs to be loaded first, and the list might change when searched
|
|
|
|
|
const items = document.querySelectorAll(`[data-list-action-selector='${projectListActionSelector}']`); |
|
|
|
|
|
|
|
|
|
if (event.keyCode === KeyCodes.UP_ARROW) { |
|
|
|
|
// Decrease the counter
|
|
|
|
|
currentIndex = currentIndex > 0 ? currentIndex -= 1 : 0; |
|
|
|
|
} else if (event.keyCode === KeyCodes.DOWN_ARROW) { |
|
|
|
|
// Increase counter
|
|
|
|
|
currentIndex = currentIndex < items.length - 1 ? currentIndex += 1 : items.length - 1; |
|
|
|
|
} else { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
(items[currentIndex] as HTMLElement).focus(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
destroyArrowNavigation():void { |
|
|
|
|
// Todo: Implement
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|