Skip to content

Commit

Permalink
avoid the sorting changes the order of the modified entries in the do…
Browse files Browse the repository at this point in the history
…cument itself by creating variables
  • Loading branch information
the-last-pastafarian committed Jan 29, 2025
1 parent 231c798 commit 472424d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -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';


Expand All @@ -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();

Expand All @@ -37,11 +49,6 @@ export class ChangesHistoryModalComponent {
this.closeModal();
}
}

public async initialize() {

this.sortDownBy('date');
}


public formatDateTime( date: string | Date, locale: string = 'de-DE' ) {
Expand All @@ -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]) {
Expand All @@ -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]) {
Expand Down
6 changes: 3 additions & 3 deletions desktop/src/app/components/widgets/change-history-modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<div class="list resource-creation-info">
<div class="list-row">
<span class="resource-creation-info-label" i18n="@@widgets.changeHistoryModal.creator.name">Erstellt von: </span>
<span class="text-truncate" [ngbTooltip]="document.created.user" [textContent]="document.created.user"></span>
<span class="text-truncate" [ngbTooltip]="documentCreation.user" [textContent]="documentCreation.user"></span>
</div>
<div class="list-row">
<span class="resource-creation-info-label" i18n="@@widgets.changeHistoryModal.creation.date">Erstellungsdatum: </span>
<span [textContent]="formatDateTime(document.created.date)"></span>
<span [textContent]="formatDateTime(documentCreation.date)"></span>
</div>
</div>

Expand All @@ -44,7 +44,7 @@
</div>
<div class="list-body">
<div class="list-row">
@for (modification of document.modified; track modification.date) {
@for (modification of documentModificationList; track modification.date) {
<div class="list-body-field" [textContent]="formatDateTime(modification.date)"></div>
<div class="list-body-field text-truncate" [textContent]="modification.user" [ngbTooltip]="modification.user"></div>
}
Expand Down
Empty file.
Empty file.

0 comments on commit 472424d

Please sign in to comment.