delta view sort of
This commit is contained in:
parent
e034e6661e
commit
99e31a571a
@ -13,6 +13,8 @@ export class AnnotationData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class FileDataModel {
|
export class FileDataModel {
|
||||||
|
static readonly DELTA_VIEW_TIME = 10 * 60 * 1000; // 10 minutes;
|
||||||
|
|
||||||
hasChangeLog: boolean;
|
hasChangeLog: boolean;
|
||||||
|
|
||||||
constructor(public file: File, public fileData: Blob, public redactionLog: RedactionLog, public viewedPages?: ViewedPages) {}
|
constructor(public file: File, public fileData: Blob, public redactionLog: RedactionLog, public viewedPages?: ViewedPages) {}
|
||||||
@ -103,25 +105,24 @@ export class FileDataModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _isChangeLogEntry(redactionLogEntry: RedactionLogEntry, wrapper: RedactionLogEntryWrapper) {
|
private _isChangeLogEntry(redactionLogEntry: RedactionLogEntry, wrapper: RedactionLogEntryWrapper) {
|
||||||
redactionLogEntry.changes.sort((a, b) => moment(a.dateTime).date() - moment(b.dateTime).date());
|
redactionLogEntry.changes.sort((a, b) => moment(a.dateTime).valueOf() - moment(b.dateTime).valueOf());
|
||||||
|
|
||||||
const lastChange =
|
const lastChange =
|
||||||
redactionLogEntry.changes.length >= 1 ? redactionLogEntry.changes[redactionLogEntry.changes.length - 1] : undefined;
|
redactionLogEntry.changes.length >= 1 ? redactionLogEntry.changes[redactionLogEntry.changes.length - 1] : undefined;
|
||||||
const page = redactionLogEntry.positions?.[0].page;
|
const page = redactionLogEntry.positions?.[0].page;
|
||||||
const viewTime = this.viewedPages.pages
|
|
||||||
.filter(p => p.page === page)
|
const viewedPage = this.viewedPages.pages.filter(p => p.page === page).pop();
|
||||||
.map(p => moment(p.viewedTime))
|
|
||||||
.pop();
|
|
||||||
|
|
||||||
// page has been seen -> let's see if it's a change
|
// page has been seen -> let's see if it's a change
|
||||||
if (viewTime) {
|
if (viewedPage) {
|
||||||
|
const viewTime = moment(viewedPage.viewedTime);
|
||||||
// these are all unseen changes
|
// these are all unseen changes
|
||||||
const relevantChanges = redactionLogEntry.changes.filter(change => moment(change.dateTime).date() > viewTime.date());
|
const relevantChanges = redactionLogEntry.changes.filter(change => moment(change.dateTime).valueOf() > viewTime.valueOf());
|
||||||
console.log(viewTime.date(), relevantChanges, redactionLogEntry.positions[0].page);
|
|
||||||
// at least one unseen change
|
// at least one unseen change
|
||||||
if (relevantChanges.length > 0) {
|
if (relevantChanges.length > 0) {
|
||||||
wrapper.changeLogType = relevantChanges[relevantChanges.length - 1].type;
|
wrapper.changeLogType = relevantChanges[relevantChanges.length - 1].type;
|
||||||
wrapper.isChangeLogEntry = true;
|
wrapper.isChangeLogEntry = true;
|
||||||
|
viewedPage.hasChanges = true;
|
||||||
this.hasChangeLog = true;
|
this.hasChangeLog = true;
|
||||||
} else {
|
} else {
|
||||||
// no relevant changes - hide removed anyway
|
// no relevant changes - hide removed anyway
|
||||||
|
|||||||
@ -29,7 +29,7 @@ export class AdminSideNavComponent implements OnInit {
|
|||||||
{
|
{
|
||||||
screen: 'dossier-templates',
|
screen: 'dossier-templates',
|
||||||
label: _('dossier-templates'),
|
label: _('dossier-templates'),
|
||||||
hideIf: !this.currentUser.isManager,
|
hideIf: !this.currentUser.isManager && !this.currentUser.isAdmin,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
screen: 'digital-signature',
|
screen: 'digital-signature',
|
||||||
|
|||||||
@ -31,8 +31,17 @@ export class PageIndicatorComponent implements OnChanges, OnInit, OnDestroy {
|
|||||||
private readonly _permissionService: PermissionsService,
|
private readonly _permissionService: PermissionsService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
get activePage() {
|
||||||
|
return this.viewedPages?.pages?.find(p => p.page === this.number);
|
||||||
|
}
|
||||||
|
|
||||||
get read() {
|
get read() {
|
||||||
return this.viewedPages?.pages?.findIndex(p => p.page === this.number) >= 0;
|
const activePage = this.activePage;
|
||||||
|
if (!activePage) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return !activePage.hasChanges;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
@ -99,7 +108,11 @@ export class PageIndicatorComponent implements OnChanges, OnInit, OnDestroy {
|
|||||||
this._viewedPagesControllerService
|
this._viewedPagesControllerService
|
||||||
.addPage({ page: this.number }, this._dossiersService.activeDossierId, this._appStateService.activeFileId)
|
.addPage({ page: this.number }, this._dossiersService.activeDossierId, this._appStateService.activeFileId)
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
|
if (this.activePage) {
|
||||||
|
this.activePage.hasChanges = false;
|
||||||
|
} else {
|
||||||
this.viewedPages?.pages?.push({ page: this.number, fileId: this._appStateService.activeFileId });
|
this.viewedPages?.pages?.push({ page: this.number, fileId: this._appStateService.activeFileId });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -15,4 +15,5 @@ export interface ViewedPage {
|
|||||||
page?: number;
|
page?: number;
|
||||||
userId?: string;
|
userId?: string;
|
||||||
viewedTime?: string;
|
viewedTime?: string;
|
||||||
|
hasChanges?: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user