From 472424d5c9e2a2575fd1af35cb66e04fb345cfbf Mon Sep 17 00:00:00 2001 From: the-last-pastafarian Date: Wed, 29 Jan 2025 18:42:18 +0100 Subject: [PATCH] avoid the sorting changes the order of the modified entries in the document itself by creating variables --- .../widgets/change-history-modal.component.ts | 27 ++++++++++++------- .../widgets/change-history-modal.html | 6 ++--- .../changes-history-modal.component.ts | 0 .../widgets/changes-history-modal.html | 0 4 files changed, 20 insertions(+), 13 deletions(-) create mode 100644 desktop/src/app/components/widgets/changes-history-modal.component.ts create mode 100644 desktop/src/app/components/widgets/changes-history-modal.html diff --git a/desktop/src/app/components/widgets/change-history-modal.component.ts b/desktop/src/app/components/widgets/change-history-modal.component.ts index f92bbf6840..d7416bfc60 100644 --- a/desktop/src/app/components/widgets/change-history-modal.component.ts +++ b/desktop/src/app/components/widgets/change-history-modal.component.ts @@ -1,7 +1,9 @@ import { Component} from '@angular/core'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +// import { DocumentHolder } from '../docedit/document-holder'; import { Document } from 'idai-field-core'; -import { Menus } from '../../services/menus'; +// import { Resource } from 'idai-field-core'; +// import { Menus } from '../../services/menus'; // import { MenuContext } from '../../services/menu-context'; @@ -18,15 +20,25 @@ import { Menus } from '../../services/menus'; export class ChangesHistoryModalComponent { public document: Document; + // public resource: Resource; public escapeKeyPressed: boolean; + public documentCreation: any; + public documentModificationList: any; public toggledDate: boolean; public toggledUser: boolean; + constructor(public activeModal: NgbActiveModal) {} + + + public async initialize() { + this.document; + this.documentModificationList = this.document.modified.slice(); + this.documentCreation = this.document.created; + this.sortDownBy('date'); + } - constructor(public activeModal: NgbActiveModal, private menus: Menus - ) {} public closeModal = () => this.activeModal.close(); @@ -37,11 +49,6 @@ export class ChangesHistoryModalComponent { this.closeModal(); } } - - public async initialize() { - - this.sortDownBy('date'); - } public formatDateTime( date: string | Date, locale: string = 'de-DE' ) { @@ -52,7 +59,7 @@ export class ChangesHistoryModalComponent { public sortUpBy(documentKey: string) { - this.document.modified.sort((a, b) => { + this.documentModificationList.sort((a, b) => { if (a[documentKey] > b[documentKey]) { return 1; } else if (a[documentKey] === b[documentKey]) { @@ -66,7 +73,7 @@ export class ChangesHistoryModalComponent { public sortDownBy(documentKey: string) { - this.document.modified.sort((a, b) => { + this.documentModificationList.sort((a, b) => { if (a[documentKey] < b[documentKey]) { return 1; } else if (a[documentKey] === b[documentKey]) { diff --git a/desktop/src/app/components/widgets/change-history-modal.html b/desktop/src/app/components/widgets/change-history-modal.html index b9ef96e1ab..586e9a16da 100644 --- a/desktop/src/app/components/widgets/change-history-modal.html +++ b/desktop/src/app/components/widgets/change-history-modal.html @@ -17,11 +17,11 @@
Erstellt von: - +
Erstellungsdatum: - +
@@ -44,7 +44,7 @@
- @for (modification of document.modified; track modification.date) { + @for (modification of documentModificationList; track modification.date) {
} diff --git a/desktop/src/app/components/widgets/changes-history-modal.component.ts b/desktop/src/app/components/widgets/changes-history-modal.component.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/desktop/src/app/components/widgets/changes-history-modal.html b/desktop/src/app/components/widgets/changes-history-modal.html new file mode 100644 index 0000000000..e69de29bb2