view mode fixes

This commit is contained in:
Dan Percic 2022-02-01 18:01:27 +02:00
parent f644b36c04
commit 577bc32417
5 changed files with 50 additions and 14 deletions

View File

@ -1,4 +1,4 @@
<div *ngIf="canPerformAnnotationActions" [class.always-visible]="alwaysVisible" class="annotation-actions">
<div *ngIf="canPerformAnnotationActions && annotationPermissions" [class.always-visible]="alwaysVisible" class="annotation-actions">
<!-- Resize Mode for annotation -> only resize accept and deny actions are available-->
<ng-container *ngIf="resizing">
<iqser-circle-button

View File

@ -34,6 +34,7 @@
&.removed {
text-decoration: line-through;
color: variables.$grey-7;
cursor: default;
}
.actions-wrapper {

View File

@ -4,6 +4,7 @@ import { FilterService, HelpModeService, IqserEventTarget } from '@iqser/common-
import { File } from '@red/domain';
import { MultiSelectService } from '../../services/multi-select.service';
import { AnnotationReferencesService } from '../../services/annotation-references.service';
import { ViewModeService } from '../../services/view-mode.service';
@Component({
selector: 'redaction-annotations-list',
@ -25,6 +26,7 @@ export class AnnotationsListComponent implements OnChanges {
constructor(
readonly multiSelectService: MultiSelectService,
readonly viewModeService: ViewModeService,
readonly helpModeService: HelpModeService,
readonly annotationReferencesService: AnnotationReferencesService,
private readonly _filterService: FilterService,
@ -41,7 +43,13 @@ export class AnnotationsListComponent implements OnChanges {
if (($event?.target as IqserEventTarget)?.localName === 'input') {
return;
}
if (annotation.isChangeLogRemoved) {
return;
}
this.pagesPanelActive.emit(false);
if (this.isSelected(annotation.annotationId)) {
this.deselectAnnotations.emit([annotation]);
} else {

View File

@ -194,7 +194,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
if (!file.canBeOpened) {
return this._router.navigate([this._dossiersService.find(this.dossierId)?.routerLink]);
}
this.viewModeService.viewMode = 'STANDARD';
this.viewModeService.switchToStandard();
await this.ngOnInit();
this._lastPage = previousRoute.queryParams.page;
@ -465,7 +465,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
const allPages = [...Array(file.numberOfPages).keys()].map(page => page + 1);
await clearStamps(pdfDoc, pdfNet, allPages);
if (this.viewModeService.viewMode === 'REDACTED') {
if (this.viewModeService.isRedacted) {
const dossier = this._dossiersService.find(this.dossierId);
if (dossier.watermarkPreviewEnabled) {
await this._stampPreview(pdfDoc, dossier.dossierTemplateId);
@ -617,10 +617,6 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
const currentFilters = this._filterService.getGroup('primaryFilters')?.filters || [];
this.rebuildFilters();
if (!this.viewModeService.isStandard) {
return;
}
const startTime = new Date().getTime();
const newAnnotations = newAnnotationsFilter ? this.visibleAnnotations.filter(newAnnotationsFilter) : this.visibleAnnotations;

View File

@ -1,24 +1,36 @@
import { Injectable } from '@angular/core';
import { BehaviorSubject, Observable } from 'rxjs';
import { ViewMode } from '@red/domain';
import { map } from 'rxjs/operators';
import { shareDistinctLast } from '@iqser/common-ui';
@Injectable()
export class ViewModeService {
readonly viewMode$: Observable<ViewMode>;
readonly compareMode$: Observable<Boolean>;
private readonly _viewMode$ = new BehaviorSubject<ViewMode>('STANDARD');
readonly compareMode$: Observable<boolean>;
readonly isRedacted$: Observable<boolean>;
readonly isStandard$: Observable<boolean>;
readonly isDelta$: Observable<boolean>;
private readonly _compareMode$ = new BehaviorSubject<Boolean>(false);
private readonly _viewMode$ = new BehaviorSubject<ViewMode>('STANDARD');
private readonly _compareMode$ = new BehaviorSubject<boolean>(false);
constructor() {
this.viewMode$ = this._viewMode$.asObservable();
this.compareMode$ = this._compareMode$.asObservable();
this.isRedacted$ = this._is('REDACTED');
this.isStandard$ = this._is('STANDARD');
this.isDelta$ = this._is('DELTA');
}
get viewMode() {
return this._viewMode$.value;
}
set viewMode(mode: ViewMode) {
this._viewMode$.next(mode);
}
get isStandard() {
return this._viewMode$.value === 'STANDARD';
}
@ -31,10 +43,6 @@ export class ViewModeService {
return this._viewMode$.value === 'REDACTED';
}
set viewMode(mode: ViewMode) {
this._viewMode$.next(mode);
}
get isCompare() {
return this._compareMode$.value;
}
@ -42,4 +50,27 @@ export class ViewModeService {
set compareMode(compareMode: boolean) {
this._compareMode$.next(compareMode);
}
switchToStandard() {
this._switchTo('STANDARD');
}
switchToDelta() {
this._switchTo('DELTA');
}
switchToRedacted() {
this._switchTo('REDACTED');
}
private _switchTo(mode: ViewMode) {
this._viewMode$.next(mode);
}
private _is(mode: ViewMode) {
return this.viewMode$.pipe(
map(value => value === mode),
shareDistinctLast(),
);
}
}