Fixed canSwitchToDeltaView
This commit is contained in:
parent
5a020c6d9b
commit
92af6cdea0
@ -2,12 +2,12 @@ import { Dictionary, File, IRedactionLog, IRedactionLogEntry, IViewedPage, ViewM
|
||||
import { AnnotationWrapper } from './annotation.wrapper';
|
||||
import { RedactionLogEntryWrapper } from './redaction-log-entry.wrapper';
|
||||
import * as moment from 'moment';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
|
||||
export class FileDataModel {
|
||||
static readonly DELTA_VIEW_TIME = 10 * 60 * 1000; // 10 minutes;
|
||||
|
||||
hasChangeLog: boolean;
|
||||
allAnnotations: AnnotationWrapper[];
|
||||
readonly hasChangeLog$ = new BehaviorSubject<boolean>(false);
|
||||
|
||||
constructor(
|
||||
public file: File,
|
||||
@ -20,15 +20,15 @@ export class FileDataModel {
|
||||
this._buildAllAnnotations();
|
||||
}
|
||||
|
||||
get redactionLog() {
|
||||
return this._redactionLog;
|
||||
}
|
||||
|
||||
set redactionLog(redactionLog: IRedactionLog) {
|
||||
this._redactionLog = redactionLog;
|
||||
this._buildAllAnnotations();
|
||||
}
|
||||
|
||||
get redactionLog() {
|
||||
return this._redactionLog;
|
||||
}
|
||||
|
||||
getVisibleAnnotations(viewMode: ViewMode) {
|
||||
return this.allAnnotations.filter(annotation => {
|
||||
if (viewMode === 'STANDARD') {
|
||||
@ -122,7 +122,7 @@ export class FileDataModel {
|
||||
|
||||
private _isChangeLogEntry(redactionLogEntry: IRedactionLogEntry, wrapper: RedactionLogEntryWrapper) {
|
||||
if (this.file.numberOfAnalyses > 1) {
|
||||
var viableChanges = redactionLogEntry.changes.filter(c => c.analysisNumber > 1);
|
||||
const viableChanges = redactionLogEntry.changes.filter(c => c.analysisNumber > 1);
|
||||
viableChanges.sort((a, b) => moment(a.dateTime).valueOf() - moment(b.dateTime).valueOf());
|
||||
|
||||
const lastChange = viableChanges.length >= 1 ? viableChanges[viableChanges.length - 1] : undefined;
|
||||
@ -141,7 +141,7 @@ export class FileDataModel {
|
||||
wrapper.changeLogType = relevantChanges[relevantChanges.length - 1].type;
|
||||
wrapper.isChangeLogEntry = true;
|
||||
viewedPage.showAsUnseen = moment(viewedPage.viewedTime).valueOf() < moment(lastChange.dateTime).valueOf();
|
||||
this.hasChangeLog = true;
|
||||
this.hasChangeLog$.next(true);
|
||||
} else {
|
||||
// no relevant changes - hide removed anyway
|
||||
wrapper.isChangeLogEntry = false;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<ng-container *ngIf="viewModeService.viewMode$ | async as viewMode">
|
||||
<div
|
||||
<button
|
||||
(click)="switchView.emit('STANDARD')"
|
||||
[class.active]="viewModeService.isStandard"
|
||||
[matTooltip]="'file-preview.standard-tooltip' | translate"
|
||||
@ -7,27 +7,27 @@
|
||||
iqserHelpMode="standard-view"
|
||||
>
|
||||
{{ 'file-preview.standard' | translate }}
|
||||
</div>
|
||||
</button>
|
||||
|
||||
<div
|
||||
(click)="canSwitchToDeltaView && switchView.emit('DELTA')"
|
||||
<button
|
||||
(click)="switchView.emit('DELTA')"
|
||||
[class.active]="viewModeService.isDelta"
|
||||
[class.disabled]="!canSwitchToDeltaView"
|
||||
[disabled]="(canSwitchToDeltaView$ | async) === false"
|
||||
[matTooltip]="'file-preview.delta-tooltip' | translate"
|
||||
class="red-tab"
|
||||
iqserHelpMode="delta-view"
|
||||
>
|
||||
{{ 'file-preview.delta' | translate }}
|
||||
</div>
|
||||
</button>
|
||||
|
||||
<div
|
||||
<button
|
||||
(click)="canSwitchToRedactedView && switchView.emit('REDACTED')"
|
||||
[class.active]="viewModeService.isRedacted"
|
||||
[class.disabled]="!canSwitchToRedactedView"
|
||||
[disabled]="!canSwitchToRedactedView"
|
||||
[matTooltip]="'file-preview.redacted-tooltip' | translate"
|
||||
class="red-tab"
|
||||
iqserHelpMode="preview-view"
|
||||
>
|
||||
{{ 'file-preview.redacted' | translate }}
|
||||
</div>
|
||||
</button>
|
||||
</ng-container>
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from '@angular/core';
|
||||
import { File, ViewMode } from '@red/domain';
|
||||
import { ViewModeService } from '../../services/view-mode.service';
|
||||
import { FileDataModel } from '@models/file/file-data.model';
|
||||
import { FilePreviewStateService } from '../../services/file-preview-state.service';
|
||||
import { Observable } from 'rxjs';
|
||||
import { filter, switchMap } from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-view-switch [file]',
|
||||
@ -13,17 +15,17 @@ export class ViewSwitchComponent implements OnChanges {
|
||||
@Output() readonly switchView = new EventEmitter<ViewMode>();
|
||||
@Input() file: File;
|
||||
|
||||
canSwitchToDeltaView = false;
|
||||
readonly canSwitchToDeltaView$: Observable<boolean>;
|
||||
canSwitchToRedactedView = false;
|
||||
|
||||
constructor(readonly viewModeService: ViewModeService) {}
|
||||
constructor(readonly viewModeService: ViewModeService, private readonly _stateService: FilePreviewStateService) {
|
||||
this.canSwitchToDeltaView$ = this._stateService.fileData$.pipe(
|
||||
filter(fileData => !!fileData),
|
||||
switchMap(fileData => fileData?.hasChangeLog$),
|
||||
);
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges) {
|
||||
if (changes.fileData) {
|
||||
const fileData = changes.fileData.currentValue as FileDataModel;
|
||||
this.canSwitchToDeltaView = fileData?.hasChangeLog;
|
||||
}
|
||||
|
||||
if (changes.file) {
|
||||
const file = changes?.file.currentValue as File;
|
||||
this.canSwitchToRedactedView = !file.analysisRequired && !file.excluded;
|
||||
|
||||
@ -1 +1 @@
|
||||
Subproject commit d11b54bb118e639274c011c41594703c71018292
|
||||
Subproject commit 85ec2446a35436786573dfdad8fc5c7bb16d5ac0
|
||||
Loading…
x
Reference in New Issue
Block a user