Disable multi select in delta & preview
This commit is contained in:
parent
c87b641de7
commit
9b330a1f7d
@ -5,7 +5,6 @@ import { MultiSelectService } from '../../services/multi-select.service';
|
||||
import { AnnotationReferencesService } from '../../services/annotation-references.service';
|
||||
import { ViewModeService } from '../../services/view-mode.service';
|
||||
import { FilePreviewStateService } from '../../services/file-preview-state.service';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-annotations-list',
|
||||
@ -37,8 +36,7 @@ export class AnnotationsListComponent implements OnChanges {
|
||||
}
|
||||
}
|
||||
|
||||
async annotationClicked(annotation: AnnotationWrapper, $event: MouseEvent): Promise<void> {
|
||||
console.log(annotation);
|
||||
annotationClicked(annotation: AnnotationWrapper, $event: MouseEvent): void {
|
||||
if (($event?.target as IqserEventTarget)?.localName === 'input') {
|
||||
return;
|
||||
}
|
||||
@ -52,7 +50,7 @@ export class AnnotationsListComponent implements OnChanges {
|
||||
if (this.isSelected(annotation.annotationId)) {
|
||||
this.deselectAnnotations.emit([annotation]);
|
||||
} else {
|
||||
const canMultiSelect = await firstValueFrom(this._state.isWritable$);
|
||||
const canMultiSelect = this.multiSelectService.isEnabled;
|
||||
if (canMultiSelect && ($event?.ctrlKey || $event?.metaKey) && this.selectedAnnotations.length > 0) {
|
||||
this.multiSelectService.activate();
|
||||
}
|
||||
@ -60,8 +58,8 @@ export class AnnotationsListComponent implements OnChanges {
|
||||
}
|
||||
}
|
||||
|
||||
async referenceClicked(annotation: AnnotationWrapper): Promise<void> {
|
||||
await this.annotationClicked(annotation, null);
|
||||
referenceClicked(annotation: AnnotationWrapper): void {
|
||||
this.annotationClicked(annotation, null);
|
||||
if (this._filterService.filtersEnabled('primaryFilters')) {
|
||||
this._filterService.toggleFilter('primaryFilters', annotation.superType, true);
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
<div>
|
||||
<div
|
||||
(click)="multiSelectService.activate()"
|
||||
*ngIf="(multiSelectInactive$ | async) && state.isWritable$ | async"
|
||||
*ngIf="(multiSelectService.enabled$ | async) && (multiSelectInactive$ | async)"
|
||||
class="all-caps-label primary pointer"
|
||||
iqserHelpMode="bulk-select-annotations"
|
||||
translate="file-preview.tabs.annotations.select"
|
||||
|
||||
@ -242,10 +242,14 @@ export class PdfViewerComponent extends AutoUnsubscribe implements OnInit, OnCha
|
||||
await this._configureTextPopup();
|
||||
|
||||
this.annotationManager.addEventListener('annotationSelected', (annotations: Annotation[], action) => {
|
||||
this.annotationSelected.emit(this.annotationManager.getSelectedAnnotations().map(ann => ann.Id));
|
||||
const nextAnnotations = this.multiSelectService.isEnabled ? this.annotationManager.getSelectedAnnotations() : annotations;
|
||||
this.annotationSelected.emit(nextAnnotations.map(ann => ann.Id));
|
||||
if (action === 'deselected') {
|
||||
this._toggleRectangleAnnotationAction(true);
|
||||
} else {
|
||||
if (!this.multiSelectService.isEnabled) {
|
||||
this.utils.deselectAnnotations(this.annotations.filter(wrapper => !nextAnnotations.find(ann => ann.Id === wrapper.id)));
|
||||
}
|
||||
this._configureAnnotationSpecificActions(annotations);
|
||||
this._toggleRectangleAnnotationAction(annotations.length === 1 && annotations[0].ReadOnly);
|
||||
}
|
||||
|
||||
@ -206,6 +206,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
this._loadingService.start();
|
||||
await this.userPreferenceService.saveLastOpenedFileForDossier(this.dossierId, this.fileId);
|
||||
this._subscribeToFileUpdates();
|
||||
this.viewModeService.viewMode$.pipe(tap(() => this.#deactivateMultiSelect())).subscribe();
|
||||
|
||||
const file = await this.stateService.file;
|
||||
if (file?.analysisRequired) {
|
||||
@ -427,6 +428,12 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
download(data, file.filename);
|
||||
}
|
||||
|
||||
#deactivateMultiSelect(): void {
|
||||
this.multiSelectService.deactivate();
|
||||
this.viewerComponent?.utils?.deselectAllAnnotations();
|
||||
this.handleAnnotationSelected([]);
|
||||
}
|
||||
|
||||
private _setActiveViewerPage() {
|
||||
const currentPage = this._instance?.Core.documentViewer?.getCurrentPage();
|
||||
if (!currentPage) {
|
||||
|
||||
@ -1,15 +1,28 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
import { BehaviorSubject, combineLatest, Observable } from 'rxjs';
|
||||
import { boolFactory } from '@iqser/common-ui';
|
||||
import { ViewModeService } from './view-mode.service';
|
||||
import { map, tap } from 'rxjs/operators';
|
||||
import { FilePreviewStateService } from './file-preview-state.service';
|
||||
|
||||
@Injectable()
|
||||
export class MultiSelectService {
|
||||
readonly enabled$: Observable<boolean>;
|
||||
readonly active$: Observable<boolean>;
|
||||
readonly inactive$: Observable<boolean>;
|
||||
readonly #active$ = new BehaviorSubject(false);
|
||||
readonly #enabled$ = new BehaviorSubject(true);
|
||||
|
||||
constructor() {
|
||||
constructor(private readonly _viewModeService: ViewModeService, private readonly _state: FilePreviewStateService) {
|
||||
[this.active$, this.inactive$] = boolFactory(this.#active$.asObservable());
|
||||
this.enabled$ = combineLatest([this._viewModeService.isStandard$, _state.isWritable$]).pipe(
|
||||
map((result: boolean[]) => !result.some(res => !res)),
|
||||
tap(enabled => this.#enabled$.next(enabled)),
|
||||
);
|
||||
}
|
||||
|
||||
get isEnabled() {
|
||||
return this.#enabled$.value;
|
||||
}
|
||||
|
||||
get isActive() {
|
||||
@ -17,14 +30,12 @@ export class MultiSelectService {
|
||||
}
|
||||
|
||||
activate() {
|
||||
this.#active$.next(true);
|
||||
if (this.isEnabled) {
|
||||
this.#active$.next(true);
|
||||
}
|
||||
}
|
||||
|
||||
deactivate() {
|
||||
this.#active$.next(false);
|
||||
}
|
||||
|
||||
toggle() {
|
||||
this.#active$.next(!this.#active$.value);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user