|
|
|
@ -45,6 +45,7 @@ import {CollectionResource} from "app/modules/hal/resources/collection-resource" |
|
|
|
|
import {DynamicCssService} from "app/modules/common/dynamic-css/dynamic-css.service"; |
|
|
|
|
import {GlobalSearchService} from "app/modules/global_search/global-search.service"; |
|
|
|
|
import {CurrentProjectService} from "app/components/projects/current-project.service"; |
|
|
|
|
import {DeviceService} from "app/modules/common/browser/device.service"; |
|
|
|
|
import {NgSelectComponent} from "@ng-select/ng-select"; |
|
|
|
|
import {debounceTime, distinctUntilChanged} from "rxjs/operators"; |
|
|
|
|
import {untilComponentDestroyed} from "ng2-rx-componentdestroyed"; |
|
|
|
@ -65,6 +66,7 @@ export class GlobalSearchInputComponent implements OnInit, OnDestroy { |
|
|
|
|
public expanded:boolean = false; |
|
|
|
|
public results:any[]; |
|
|
|
|
public suggestions:any[]; |
|
|
|
|
public mobileSearch:boolean = false; |
|
|
|
|
|
|
|
|
|
public searchTermChanged$:Subject<string> = new Subject<string>(); |
|
|
|
|
|
|
|
|
@ -77,7 +79,8 @@ export class GlobalSearchInputComponent implements OnInit, OnDestroy { |
|
|
|
|
all_projects: this.I18n.t('js.global_search.all_projects'), |
|
|
|
|
current_project: this.I18n.t('js.global_search.current_project'), |
|
|
|
|
current_project_and_all_descendants: this.I18n.t('js.global_search.current_project_and_all_descendants'), |
|
|
|
|
search: this.I18n.t('js.global_search.search') + ' ...' |
|
|
|
|
search: this.I18n.t('js.global_search.search') + ' ...', |
|
|
|
|
close_search: this.I18n.t('js.global_search.close_search') |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
constructor(readonly elementRef:ElementRef, |
|
|
|
@ -87,6 +90,7 @@ export class GlobalSearchInputComponent implements OnInit, OnDestroy { |
|
|
|
|
readonly dynamicCssService:DynamicCssService, |
|
|
|
|
readonly globalSearchService:GlobalSearchService, |
|
|
|
|
readonly currentProjectService:CurrentProjectService, |
|
|
|
|
readonly deviceService:DeviceService, |
|
|
|
|
readonly cdRef:ChangeDetectorRef) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -125,10 +129,22 @@ export class GlobalSearchInputComponent implements OnInit, OnDestroy { |
|
|
|
|
|
|
|
|
|
// handle click on search button
|
|
|
|
|
if (ContainHelpers.insideOrSelf(this.btn.nativeElement, event.target)) { |
|
|
|
|
this.submitNonEmptySearch(); |
|
|
|
|
if (this.deviceService.isMobile) { |
|
|
|
|
this.toggleMobileSearch(); |
|
|
|
|
// open ng-select menu on default
|
|
|
|
|
jQuery('.ng-input input').focus(); |
|
|
|
|
} else { |
|
|
|
|
this.submitNonEmptySearch(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// open or close mobile search
|
|
|
|
|
public toggleMobileSearch() { |
|
|
|
|
jQuery('.ng-select, #account-nav-right, #account-nav-left, #main-menu-toggle').toggleClass('hidden-for-mobile'); |
|
|
|
|
this.mobileSearch = !this.mobileSearch; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// load selected item
|
|
|
|
|
public onChange($event:any) { |
|
|
|
|
let selectedOption = $event; |
|
|
|
@ -162,8 +178,10 @@ export class GlobalSearchInputComponent implements OnInit, OnDestroy { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public onFocusOut() { |
|
|
|
|
this.expanded = (this.ngSelectComponent.filterValue.length > 0); |
|
|
|
|
this.ngSelectComponent.isOpen = false; |
|
|
|
|
if (!this.deviceService.isMobile) { |
|
|
|
|
this.expanded = (this.ngSelectComponent.filterValue.length > 0); |
|
|
|
|
this.ngSelectComponent.isOpen = false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public clearSearch() { |
|
|
|
|