RED-9861: fixed bulk-select issues.

This commit is contained in:
Nicoleta Panaghiu 2024-08-12 13:22:47 +03:00
parent e6a3b1a585
commit f82cdcf5bb
3 changed files with 63 additions and 39 deletions

View File

@ -6,7 +6,7 @@
class="mt-6 mr-10" class="mt-6 mr-10"
></redaction-annotation-icon> ></redaction-annotation-icon>
<div [class.flex-1]="!isDocumine"> <div class="flex-1">
<div> <div>
<strong>{{ annotation.superTypeLabel | translate }}</strong> <strong>{{ annotation.superTypeLabel | translate }}</strong>
&nbsp; &nbsp;

View File

@ -44,34 +44,9 @@
</ng-template> </ng-template>
</ng-container> </ng-container>
<div *ngIf="multiSelectService.active()" class="multi-select"> @if (!isDocumine) {
<div class="selected-wrapper"> <ng-container [ngTemplateOutlet]="multiSelectTemplate()"></ng-container>
<iqser-round-checkbox }
(click)="annotationManager.deselect()"
[indeterminate]="listingService.areSomeSelected$ | async"
type="with-bg"
></iqser-round-checkbox>
<span class="all-caps-label">{{ listingService.selectedLength$ | async }} selected </span>
<redaction-annotation-actions
*ngIf="listingService.areSomeSelected$ | async"
[alwaysVisible]="true"
[annotations]="listingService.selectedEntities$ | async"
[canPerformAnnotationActions]="state.isWritable()"
buttonType="primary"
tooltipPosition="above"
></redaction-annotation-actions>
</div>
<iqser-circle-button
(action)="multiSelectService.deactivate()"
[tooltip]="'file-preview.tabs.multi-select.close' | translate"
[type]="circleButtonTypes.primary"
icon="iqser:close"
tooltipPosition="before"
></iqser-circle-button>
</div>
<div class="annotations-wrapper" [class.documine-direction]="isDocumine"> <div class="annotations-wrapper" [class.documine-direction]="isDocumine">
<div [class.border-left]="isDocumine"> <div [class.border-left]="isDocumine">
@ -158,6 +133,10 @@
</div> </div>
</div> </div>
@if (isDocumine) {
<ng-container [ngTemplateOutlet]="multiSelectTemplate()"></ng-container>
}
<div <div
#annotationsElement #annotationsElement
(keydown)="preventKeyDefault($event)" (keydown)="preventKeyDefault($event)"
@ -263,3 +242,34 @@
<ng-template #documentInfo> <ng-template #documentInfo>
<redaction-document-info id="document-info"></redaction-document-info> <redaction-document-info id="document-info"></redaction-document-info>
</ng-template> </ng-template>
<ng-template #multiSelect>
<div *ngIf="multiSelectService.active()" [class.documine-width]="isDocumine" class="multi-select">
<div class="selected-wrapper">
<iqser-round-checkbox
(click)="annotationManager.deselect()"
[indeterminate]="listingService.areSomeSelected$ | async"
type="with-bg"
></iqser-round-checkbox>
<span class="all-caps-label">{{ listingService.selectedLength$ | async }} selected </span>
<redaction-annotation-actions
*ngIf="listingService.areSomeSelected$ | async"
[alwaysVisible]="true"
[annotations]="listingService.selectedEntities$ | async"
[canPerformAnnotationActions]="state.isWritable()"
buttonType="primary"
tooltipPosition="above"
></redaction-annotation-actions>
</div>
<iqser-circle-button
(action)="multiSelectService.deactivate()"
[tooltip]="'file-preview.tabs.multi-select.close' | translate"
[type]="circleButtonTypes.primary"
icon="iqser:close"
tooltipPosition="before"
></iqser-circle-button>
</div>
</ng-template>

View File

@ -1,5 +1,16 @@
import { AsyncPipe, NgIf, NgTemplateOutlet } from '@angular/common'; import { AsyncPipe, NgIf, NgTemplateOutlet } from '@angular/common';
import { ChangeDetectorRef, Component, computed, effect, ElementRef, HostListener, OnDestroy, OnInit, ViewChild } from '@angular/core'; import {
ChangeDetectorRef,
Component,
computed,
effect,
ElementRef,
HostListener,
OnDestroy,
OnInit,
TemplateRef,
viewChild,
} from '@angular/core';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { MatIcon } from '@angular/material/icon'; import { MatIcon } from '@angular/material/icon';
import { MatTooltip } from '@angular/material/tooltip'; import { MatTooltip } from '@angular/material/tooltip';
@ -20,7 +31,7 @@ import { AutoUnsubscribe, Debounce, IqserEventTarget } from '@iqser/common-ui/li
import { AnnotationWrapper } from '@models/file/annotation.wrapper'; import { AnnotationWrapper } from '@models/file/annotation.wrapper';
import { ListItem } from '@models/file/list-item'; import { ListItem } from '@models/file/list-item';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { ComponentLogEntry, WorkflowFileStatuses } from '@red/domain'; import { WorkflowFileStatuses } from '@red/domain';
import { workloadTranslations } from '@translations/workload-translations'; import { workloadTranslations } from '@translations/workload-translations';
import { UserPreferenceService } from '@users/user-preference.service'; import { UserPreferenceService } from '@users/user-preference.service';
import { getLocalStorageDataByFileId } from '@utils/local-storage'; import { getLocalStorageDataByFileId } from '@utils/local-storage';
@ -78,8 +89,9 @@ const ALL_HOTKEY_ARRAY = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'];
], ],
}) })
export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, OnDestroy { export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, OnDestroy {
@ViewChild('annotationsElement') private readonly _annotationsElement: ElementRef; private readonly _annotationsElement = viewChild<ElementRef>('annotationsElement');
@ViewChild('quickNavigation') private readonly _quickNavigationElement: ElementRef; private readonly _quickNavigationElement = viewChild<ElementRef>('quickNavigation');
readonly multiSelectTemplate = viewChild<TemplateRef<any>>('multiSelect');
readonly #isIqserDevMode = this._userPreferenceService.isIqserDevMode; readonly #isIqserDevMode = this._userPreferenceService.isIqserDevMode;
protected readonly iconButtonTypes = IconButtonTypes; protected readonly iconButtonTypes = IconButtonTypes;
protected readonly circleButtonTypes = CircleButtonTypes; protected readonly circleButtonTypes = CircleButtonTypes;
@ -280,18 +292,20 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On
} }
scrollAnnotationsToPage(page: number, mode: 'always' | 'if-needed' = 'if-needed'): void { scrollAnnotationsToPage(page: number, mode: 'always' | 'if-needed' = 'if-needed'): void {
if (this._annotationsElement) { if (this._annotationsElement()) {
const elements: HTMLElement[] = this._annotationsElement.nativeElement.querySelectorAll(`div[anotation-page-header="${page}"]`); const elements: HTMLElement[] = this._annotationsElement().nativeElement.querySelectorAll(
`div[anotation-page-header="${page}"]`,
);
FileWorkloadComponent._scrollToFirstElement(elements, mode); FileWorkloadComponent._scrollToFirstElement(elements, mode);
} }
} }
@Debounce() @Debounce()
scrollToSelectedAnnotation(): void { scrollToSelectedAnnotation(): void {
if (this.listingService.selected.length === 0 || !this._annotationsElement) { if (this.listingService.selected.length === 0 || !this._annotationsElement()) {
return; return;
} }
const elements: HTMLElement[] = this._annotationsElement.nativeElement.querySelectorAll( const elements: HTMLElement[] = this._annotationsElement().nativeElement.querySelectorAll(
`[annotation-id="${this._firstSelectedAnnotation?.id}"]`, `[annotation-id="${this._firstSelectedAnnotation?.id}"]`,
); );
FileWorkloadComponent._scrollToFirstElement(elements); FileWorkloadComponent._scrollToFirstElement(elements);
@ -514,8 +528,8 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On
} }
#scrollQuickNavigationToPage(page: number) { #scrollQuickNavigationToPage(page: number) {
if (this._quickNavigationElement) { if (this._quickNavigationElement()) {
const elements: HTMLElement[] = this._quickNavigationElement.nativeElement.querySelectorAll(`#quick-nav-page-${page}`); const elements: HTMLElement[] = this._quickNavigationElement().nativeElement.querySelectorAll(`#quick-nav-page-${page}`);
FileWorkloadComponent._scrollToFirstElement(elements); FileWorkloadComponent._scrollToFirstElement(elements);
} }
} }