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