fix spotlight search

This commit is contained in:
Dan Percic 2021-10-11 13:17:27 +03:00
parent 4023209432
commit 3db58f21af
5 changed files with 19 additions and 21 deletions

View File

@ -6,11 +6,11 @@
<mat-menu #menu="matMenu" class="search-menu" xPosition="after">
<ng-template matMenuContent>
<div *ngIf="currentActionIdx$ | async as currentIndex" class="wrapper">
<div class="wrapper">
<button
(click)="item.action(valueChanges$.getValue())"
*ngFor="let item of shownActions; let index = index"
[class.highlight]="currentIndex === index"
[class.highlight]="(currentActionIdx$ | async) === index"
class="spotlight-row pointer"
>
<mat-icon [svgIcon]="item.icon"></mat-icon>

View File

@ -13,22 +13,24 @@ import { MatMenuTrigger } from '@angular/material/menu';
export class SpotlightSearchComponent {
@Input() actions: readonly SpotlightSearchAction[];
@Input() placeholder?: string;
@ViewChild(MatMenuTrigger) private readonly _menuTrigger!: MatMenuTrigger;
private readonly _currentActionIdx$ = new BehaviorSubject(0);
readonly currentActionIdx$ = this._currentActionIdx$.asObservable().pipe(distinctUntilChanged());
readonly valueChanges$ = new BehaviorSubject<string>('');
@ViewChild(MatMenuTrigger) private readonly _menuTrigger!: MatMenuTrigger;
readonly showActions$ = this.valueChanges$.pipe(
debounceTime(300),
map(value => value !== ''),
tap(show => (show ? this._menuTrigger.openMenu() : this._menuTrigger.closeMenu())),
);
private readonly _currentActionIdx$ = new BehaviorSubject(0);
readonly currentActionIdx$ = this._currentActionIdx$.asObservable().pipe(distinctUntilChanged());
get shownActions(): readonly SpotlightSearchAction[] {
return this.actions.filter(a => !a.hide?.());
}
private get _currentActionIdx(): number {
return this._currentActionIdx$.getValue();
}
openMenuIfValue(): void {
const value = this.valueChanges$.getValue();
if (value && value !== '') {
@ -55,8 +57,4 @@ export class SpotlightSearchComponent {
const index = this._currentActionIdx - 1;
this._currentActionIdx$.next(index < 0 ? this.actions.length - 1 : index);
}
private get _currentActionIdx(): number {
return this._currentActionIdx$.getValue();
}
}

View File

@ -34,10 +34,10 @@
<div class="overlay-shadow"></div>
<div class="content-inner">
<div [class.extended]="collapsedDetails" class="content-container">
<div *ngIf="listingMode$ | async as mode" [class.extended]="collapsedDetails" class="content-container">
<iqser-table
(noDataAction)="fileInput.click()"
*ngIf="(listingMode$ | async) === listingModes.table"
*ngIf="mode === listingModes.table"
[bulkActions]="bulkActions"
[hasScrollButton]="true"
[itemSize]="80"
@ -54,7 +54,7 @@
<iqser-workflow
(addElement)="fileInput.click()"
(noDataAction)="fileInput.click()"
*ngIf="(listingMode$ | async) === listingModes.workflow"
*ngIf="mode === listingModes.workflow"
[config]="workflowConfig"
[itemClasses]="{ disabled: disabledFn }"
[itemTemplate]="workflowItemTemplate"

View File

@ -53,8 +53,8 @@ import { ConfigService as AppConfigService } from '@services/config.service';
import { ConfigService } from '../config.service';
import { DossiersService } from '../../../services/dossiers.service';
import { DossierTemplatesService } from '../../../services/dossier-templates.service';
import { LongPressEvent } from '../../../../shared/directives/long-press.directive';
import { UserPreferenceService } from '../../../../../services/user-preference.service';
import { LongPressEvent } from '@shared/directives/long-press.directive';
import { UserPreferenceService } from '@services/user-preference.service';
@Component({
templateUrl: './dossier-overview-screen.component.html',
@ -156,13 +156,13 @@ export class DossierOverviewScreenComponent extends ListingComponent<File> imple
this.addSubscription = timer(0, 10 * 1000).subscribe(async () => {
await this._appStateService.reloadActiveDossierFilesIfNecessary();
this._loadEntitiesFromState();
});
this.addSubscription = this._appStateService.fileChanged$.subscribe(() => {
this.calculateData();
});
// this.addSubscription = this._appStateService.fileChanged$.subscribe(() => {
// this.calculateData();
// });
this.addSubscription = this._dossierTemplatesService.entityChanged$.subscribe(() => {
this.fileAttributeConfigs = this._fileAttributesService.getFileAttributeConfig(
this.currentDossier.dossierTemplateId,

@ -1 +1 @@
Subproject commit 6adb38a61db759028e5e18d9b05c8e1b8f85e371
Subproject commit 2d45f05b7204f9a40b2cff66ced2aed004628496