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