RED-6412, some more refactoring.
This commit is contained in:
parent
eeeb54c084
commit
545e6e0f98
@ -1,4 +1,5 @@
|
||||
export interface ListItem<T> {
|
||||
item: T;
|
||||
isSelected: boolean;
|
||||
multiSelectActive: boolean;
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<div
|
||||
*ngIf="!annotation.isSelected && changesTooltip"
|
||||
*ngIf="noSelection && changesTooltip"
|
||||
[matTooltip]="changesTooltip"
|
||||
class="chip"
|
||||
matTooltipClass="multiline"
|
||||
@ -8,7 +8,7 @@
|
||||
<mat-icon [svgIcon]="'red:redaction-changes'"></mat-icon>
|
||||
</div>
|
||||
|
||||
<ng-container *ngIf="!annotation.isSelected && engines">
|
||||
<ng-container *ngIf="noSelection && engines">
|
||||
<div #trigger="cdkOverlayOrigin" (mouseout)="isPopoverOpen = false" (mouseover)="isPopoverOpen = true" cdkOverlayOrigin class="chip">
|
||||
<mat-icon *ngFor="let engine of engines" [svgIcon]="engine.icon"></mat-icon>
|
||||
</div>
|
||||
|
||||
@ -46,6 +46,7 @@ export class AnnotationDetailsComponent implements OnChanges {
|
||||
|
||||
engines: Engine[];
|
||||
changesTooltip: string;
|
||||
noSelection: boolean;
|
||||
|
||||
constructor(private readonly _translateService: TranslateService, private readonly _listingService: AnnotationsListingService) {}
|
||||
|
||||
@ -64,6 +65,7 @@ export class AnnotationDetailsComponent implements OnChanges {
|
||||
ngOnChanges() {
|
||||
this.engines = this.#extractEngines(this.annotation.item).filter(engine => engine.show);
|
||||
this.changesTooltip = this.getChangesTooltip();
|
||||
this.noSelection = !this.annotation.isSelected || !this.annotation.multiSelectActive;
|
||||
}
|
||||
|
||||
#extractEngines(annotation: AnnotationWrapper): Engine[] {
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
{{ annotation.item.comments.length }}
|
||||
</div>
|
||||
|
||||
<div *ngIf="multiSelectService.inactive$ | async" class="actions">
|
||||
<div *ngIf="!annotation.multiSelectActive" class="actions">
|
||||
<redaction-annotation-actions
|
||||
[annotations]="[annotation.item]"
|
||||
[canPerformAnnotationActions]="pdfProxyService.canPerformAnnotationActions$ | async"
|
||||
|
||||
@ -19,11 +19,7 @@ export class AnnotationWrapperComponent implements OnChanges {
|
||||
@HostBinding('class.active') active = false;
|
||||
readonly scrollableParentView = ScrollableParentViews.ANNOTATIONS_LIST;
|
||||
|
||||
constructor(
|
||||
readonly listingService: AnnotationsListingService,
|
||||
readonly multiSelectService: MultiSelectService,
|
||||
readonly pdfProxyService: PdfProxyService,
|
||||
) {}
|
||||
constructor(readonly listingService: AnnotationsListingService, readonly pdfProxyService: PdfProxyService) {}
|
||||
|
||||
ngOnChanges() {
|
||||
this.annotationId = this.annotation.item.id;
|
||||
|
||||
@ -15,8 +15,8 @@ import {
|
||||
shareDistinctLast,
|
||||
shareLast,
|
||||
} from '@iqser/common-ui';
|
||||
import { combineLatest, delay, Observable } from 'rxjs';
|
||||
import { map, tap } from 'rxjs/operators';
|
||||
import { combineLatest, delay, Observable, pipe } from 'rxjs';
|
||||
import { distinctUntilChanged, map, tap } from 'rxjs/operators';
|
||||
import { File } from '@red/domain';
|
||||
import { ExcludedPagesService } from '../../services/excluded-pages.service';
|
||||
import { MultiSelectService } from '../../services/multi-select.service';
|
||||
@ -158,31 +158,15 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnDestroy
|
||||
this.fileDataService.all$,
|
||||
primary$,
|
||||
secondary$,
|
||||
this.multiSelectInactive$,
|
||||
this.multiSelectService.active$.pipe(distinctUntilChanged()),
|
||||
this.listingService.selected$,
|
||||
]).pipe(
|
||||
delay(0),
|
||||
map(
|
||||
([annotations, primary, secondary, multiSelectInactive]) =>
|
||||
[this._filterAnnotations(annotations, primary, secondary), multiSelectInactive] as [
|
||||
Map<number, AnnotationWrapper[]>,
|
||||
boolean,
|
||||
],
|
||||
[this._filterAnnotations(annotations, primary, secondary), multiSelectInactive] as const,
|
||||
),
|
||||
map(([annotations, multiSelectInactive]) => {
|
||||
const listItemsMap = new Map<number, ListItem<AnnotationWrapper>[]>();
|
||||
if (!annotations) {
|
||||
return listItemsMap;
|
||||
}
|
||||
[...annotations.keys()].forEach(key => {
|
||||
const newValue = annotations.get(key).map(annotation => ({
|
||||
item: annotation,
|
||||
isSelected: this.listingService.isSelected(annotation) && !multiSelectInactive,
|
||||
}));
|
||||
listItemsMap.set(key, newValue);
|
||||
});
|
||||
return listItemsMap;
|
||||
}),
|
||||
this._mapListItemsFromAnnotationWrapperArray(),
|
||||
);
|
||||
}
|
||||
|
||||
@ -484,4 +468,24 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnDestroy
|
||||
FileWorkloadComponent._scrollToFirstElement(elements);
|
||||
}
|
||||
}
|
||||
|
||||
private _mapListItemsFromAnnotationWrapperArray() {
|
||||
return pipe(
|
||||
map(([annotations, multiSelectActive]) => {
|
||||
const listItemsMap = new Map<number, ListItem<AnnotationWrapper>[]>();
|
||||
if (!annotations) {
|
||||
return listItemsMap;
|
||||
}
|
||||
[...annotations.keys()].forEach(key => {
|
||||
const newValue = annotations.get(key).map(annotation => ({
|
||||
item: annotation,
|
||||
isSelected: this.listingService.isSelected(annotation),
|
||||
multiSelectActive,
|
||||
}));
|
||||
listItemsMap.set(key, newValue);
|
||||
});
|
||||
return listItemsMap;
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user