RED-6168: Changed position of 'Load All Annotations' and added the display condition.
This commit is contained in:
parent
cfb11f70d2
commit
89c4b738db
@ -637,6 +637,8 @@ export class FilePreviewScreenComponent
|
||||
this._ngZone.run(() => this.#updateQueryParamsPage(page)),
|
||||
);
|
||||
|
||||
this.addActiveScreenSubscription = this._viewerHeaderService.toggleLoadAnnotations$.subscribe();
|
||||
|
||||
this.addActiveScreenSubscription = this.pdfProxyService.annotationSelected$.subscribe();
|
||||
|
||||
this.addActiveScreenSubscription = this._viewerHeaderService.events$
|
||||
|
||||
@ -10,10 +10,11 @@ import { ROTATION_ACTION_BUTTONS, ROTATION_BUTTONS, ViewerEvents } from '../util
|
||||
import { FilesMapService } from '@services/files/files-map.service';
|
||||
import { REDDocumentViewer } from './document-viewer.service';
|
||||
import { UserPreferenceService } from '@users/user-preference.service';
|
||||
import { Observable, Subject } from 'rxjs';
|
||||
import { ViewerEvent } from '../utils/types';
|
||||
import { fromEvent, Observable, Subject } from 'rxjs';
|
||||
import { ViewerEvent, VisibilityChangedEvent } from '../utils/types';
|
||||
import { ReadableRedactionsService } from './readable-redactions.service';
|
||||
import { ROLES } from '@users/roles';
|
||||
import { filter, map, tap } from 'rxjs/operators';
|
||||
|
||||
const divider: IHeaderElement = {
|
||||
type: 'divider',
|
||||
@ -27,7 +28,7 @@ export class ViewerHeaderService {
|
||||
[HeaderElements.SHAPE_TOOL_GROUP_BUTTON, true],
|
||||
[HeaderElements.TOGGLE_TOOLTIPS, true],
|
||||
[HeaderElements.TOGGLE_READABLE_REDACTIONS, false],
|
||||
[HeaderElements.LOAD_ALL_ANNOTATIONS, true],
|
||||
[HeaderElements.LOAD_ALL_ANNOTATIONS, false],
|
||||
[HeaderElements.COMPARE_BUTTON, true],
|
||||
[HeaderElements.CLOSE_COMPARE_BUTTON, false],
|
||||
[HeaderElements.ROTATE_LEFT_BUTTON, false],
|
||||
@ -37,6 +38,7 @@ export class ViewerHeaderService {
|
||||
]);
|
||||
#docBeforeCompare: Blob;
|
||||
readonly #events$ = new Subject<ViewerEvent>();
|
||||
toggleLoadAnnotations$: Observable<boolean>;
|
||||
|
||||
constructor(
|
||||
@Inject(BASE_HREF_FN) private readonly _convertPath: BaseHrefFn,
|
||||
@ -200,6 +202,27 @@ export class ViewerHeaderService {
|
||||
};
|
||||
}
|
||||
|
||||
private get _toggleLoadAnnotations$() {
|
||||
return this._expandedPanelEvent$.pipe(
|
||||
tap(isVisible => {
|
||||
if (isVisible) {
|
||||
this.enable([HeaderElements.LOAD_ALL_ANNOTATIONS]);
|
||||
} else {
|
||||
this.disable([HeaderElements.LOAD_ALL_ANNOTATIONS]);
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
private get _expandedPanelEvent$() {
|
||||
const visibilityEvent$ = fromEvent(this._pdf.instance?.UI, this._pdf.instance.UI?.Events.VISIBILITY_CHANGED);
|
||||
return visibilityEvent$.pipe(
|
||||
map<CustomEvent, VisibilityChangedEvent>(event => event.detail),
|
||||
filter(event => event.element === 'thumbnailsPanel'),
|
||||
map(event => event.isVisible),
|
||||
);
|
||||
}
|
||||
|
||||
init(): void {
|
||||
this.#buttons = new Map([
|
||||
[HeaderElements.SHAPE_TOOL_GROUP_BUTTON, this._rectangle],
|
||||
@ -213,6 +236,7 @@ export class ViewerHeaderService {
|
||||
[HeaderElements.COMPARE_BUTTON, this._compare],
|
||||
[HeaderElements.CLOSE_COMPARE_BUTTON, this._closeCompare],
|
||||
]);
|
||||
this.toggleLoadAnnotations$ = this._toggleLoadAnnotations$;
|
||||
|
||||
this.updateElements();
|
||||
}
|
||||
@ -233,7 +257,6 @@ export class ViewerHeaderService {
|
||||
[HeaderElements.TOGGLE_TOOLTIPS],
|
||||
[HeaderElements.TOGGLE_READABLE_REDACTIONS],
|
||||
[HeaderElements.SHAPE_TOOL_GROUP_BUTTON],
|
||||
[HeaderElements.LOAD_ALL_ANNOTATIONS],
|
||||
[
|
||||
HeaderElements.ROTATE_LEFT_BUTTON,
|
||||
HeaderElements.ROTATE_RIGHT_BUTTON,
|
||||
@ -241,8 +264,25 @@ export class ViewerHeaderService {
|
||||
HeaderElements.DISCARD_ROTATION,
|
||||
],
|
||||
];
|
||||
|
||||
const loadAllAnnotationsButton = this.#buttons.get(HeaderElements.LOAD_ALL_ANNOTATIONS);
|
||||
const startLoadAnnotations = 3;
|
||||
let startButtons = 10;
|
||||
let deleteCount = 14;
|
||||
|
||||
groups.forEach(group => this._pushGroup(enabledItems, group));
|
||||
header.getItems().splice(10, header.getItems().length - 14, ...enabledItems);
|
||||
|
||||
if (!header.getItems().includes(loadAllAnnotationsButton)) {
|
||||
if (this._isEnabled(HeaderElements.LOAD_ALL_ANNOTATIONS)) {
|
||||
header.getItems().splice(startLoadAnnotations, 0, loadAllAnnotationsButton);
|
||||
startButtons = 11;
|
||||
deleteCount = 15;
|
||||
}
|
||||
} else {
|
||||
header.getItems().splice(startLoadAnnotations, 1);
|
||||
}
|
||||
|
||||
header.getItems().splice(startButtons, header.getItems().length - deleteCount, ...enabledItems);
|
||||
});
|
||||
|
||||
this._pdf.instance?.UI.updateElement('selectToolButton', {
|
||||
|
||||
@ -19,3 +19,8 @@ export type AnnotationPredicate = (value: Annotation) => boolean;
|
||||
export interface ViewerEvent {
|
||||
readonly type: string;
|
||||
}
|
||||
|
||||
export interface VisibilityChangedEvent {
|
||||
readonly element: string;
|
||||
readonly isVisible: boolean;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user