RED-7116, fixed double clicking causing infinite loop.
This commit is contained in:
parent
dc5f14c696
commit
d3ac14497d
@ -17,7 +17,7 @@
|
||||
[class.help-mode-active]="helpModeService?.isHelpModeActive$ | async"
|
||||
[id]="'item-' + entity.id"
|
||||
[ngClass]="getTableItemClasses(entity)"
|
||||
[routerLink]="entity.routerLink | tenant"
|
||||
(click)="initiateNavigation(entity.routerLink)"
|
||||
>
|
||||
<iqser-table-item
|
||||
(click)="multiSelect(entity, $event)"
|
||||
@ -31,7 +31,7 @@
|
||||
[class.help-mode-active]="helpModeService?.isHelpModeActive$ | async"
|
||||
[id]="'item-' + entity.id"
|
||||
[ngClass]="getTableItemClasses(entity)"
|
||||
[routerLink]="entity.routerLink | tenant"
|
||||
(click)="initiateNavigation(entity.routerLink)"
|
||||
>
|
||||
<iqser-table-item
|
||||
(click)="multiSelect(entity, $event)"
|
||||
|
||||
@ -1,13 +1,16 @@
|
||||
/* eslint-disable @angular-eslint/prefer-on-push-component-change-detection */
|
||||
import { AfterViewInit, Component, forwardRef, HostListener, Inject, Input, OnDestroy, Optional, ViewChild } from '@angular/core';
|
||||
import { AfterViewInit, Component, forwardRef, HostListener, inject, Inject, Input, OnDestroy, Optional, ViewChild } from '@angular/core';
|
||||
import { CdkVirtualScrollViewport } from '@angular/cdk/scrolling';
|
||||
import { delay, tap } from 'rxjs/operators';
|
||||
import { delay, filter, switchMap, tap, throttleTime } from 'rxjs/operators';
|
||||
import { AutoUnsubscribe, trackByFactory } from '../../utils';
|
||||
import { Id, IListable } from '../models';
|
||||
import { ListingComponent, ListingService } from '../index';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { HelpModeService } from '../../help-mode';
|
||||
import { HasScrollbarDirective } from '../../directives';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { TenantsService } from '../../tenants';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'iqser-table-content',
|
||||
@ -30,6 +33,9 @@ export class TableContentComponent<Class extends IListable<PrimaryKey>, PrimaryK
|
||||
|
||||
private _lastScrolledIndex = 0;
|
||||
private _multiSelectActive$ = new BehaviorSubject(false);
|
||||
readonly #navigationEvents = new BehaviorSubject<string>('');
|
||||
readonly #tenantsService = inject(TenantsService);
|
||||
readonly #router = inject(Router);
|
||||
|
||||
constructor(
|
||||
@Inject(forwardRef(() => ListingComponent)) readonly listingComponent: ListingComponent<Class>,
|
||||
@ -42,6 +48,16 @@ export class TableContentComponent<Class extends IListable<PrimaryKey>, PrimaryK
|
||||
this.scrollViewport?.checkViewportSize();
|
||||
}, 0);
|
||||
});
|
||||
this.#navigationEvents
|
||||
.asObservable()
|
||||
.pipe(
|
||||
filter(Boolean),
|
||||
throttleTime(1000),
|
||||
switchMap(route => this.#router.navigateByUrl(route)),
|
||||
takeUntilDestroyed(),
|
||||
)
|
||||
// eslint-disable-next-line rxjs/no-ignored-subscription
|
||||
.subscribe();
|
||||
}
|
||||
|
||||
multiSelect(entity: Class, $event: MouseEvent): void {
|
||||
@ -93,4 +109,9 @@ export class TableContentComponent<Class extends IListable<PrimaryKey>, PrimaryK
|
||||
private _disableMultiSelect() {
|
||||
this._multiSelectActive$.next(false);
|
||||
}
|
||||
|
||||
initiateNavigation(routerLink: string | undefined) {
|
||||
if (!routerLink) return;
|
||||
this.#navigationEvents.next('/' + this.#tenantsService.activeTenantId + routerLink);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user