Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show ressource change history issue223 #268

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d2b03e5
add tab Changes history (should be grouped as the other items)
the-last-pastafarian Nov 13, 2024
db2f6f2
change history table structure
the-last-pastafarian Nov 18, 2024
ec5ea54
change the structure for displayingthe changes after clicking on a bu…
the-last-pastafarian Nov 22, 2024
8fd6182
The context-menu show the changes of the previous selected document. …
the-last-pastafarian Dec 11, 2024
b2613eb
clean code and table forr changes into the modal - to do dynamic widt…
the-last-pastafarian Dec 12, 2024
60330f0
history in the context menu, still to do the css
the-last-pastafarian Dec 17, 2024
1596d0c
improve the css of the changes table
the-last-pastafarian Dec 19, 2024
2d6eb66
format the dates
the-last-pastafarian Dec 20, 2024
04fb44b
set the height of the modal according to the screen
the-last-pastafarian Jan 13, 2025
75575f2
cleaning
the-last-pastafarian Jan 14, 2025
b44fb2f
Merge branch 'master' into show_ressource_change_history_issue223
the-last-pastafarian Jan 14, 2025
a0732bf
create a private function for the code in common between editQRCode()…
the-last-pastafarian Jan 14, 2025
6949680
rename change-history-dialog.componet into change-history-modal.comp…
the-last-pastafarian Jan 14, 2025
7f7897e
text of history modal in German with i18n ids
the-last-pastafarian Jan 15, 2025
2362aa9
Merge branch 'master' into show_ressource_change_history_issue223
the-last-pastafarian Jan 15, 2025
7696838
Merge branch 'master' into show_ressource_change_history_issue223
the-last-pastafarian Jan 15, 2025
e96d173
import component
the-last-pastafarian Jan 15, 2025
9e554a1
change the layout.
the-last-pastafarian Jan 15, 2025
b41ea4a
move ChangesHistoryModalComponent into declarations
the-last-pastafarian Jan 15, 2025
9596856
fix the can´t bind ngFor and ngIf
the-last-pastafarian Jan 15, 2025
8e30b32
translation of the text in German
the-last-pastafarian Jan 15, 2025
4aef5a3
remove windowsclass in private function in common between qr-code and…
the-last-pastafarian Jan 20, 2025
fef56e0
function sort by: might be use for sorting by users or modification d…
the-last-pastafarian Jan 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions desktop/src/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,14 @@ select.form-control:not([size]):not([multiple]) {
overflow: hidden;
}

.history-modal-content .modal-content {
user-select: none;
width: fit-content;

}



.modal-dialog:not(.modal-dialog-centered) {
top: 14px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ export class EditFormComponent implements AfterViewInit, OnChanges {
if (!this.scrollTargetField) this.focusFirstInputElement();
}


ngOnChanges() {

if (isUndefinedOrEmpty(this.originalGroups)) return;

this.groups = [];
Expand All @@ -65,7 +64,7 @@ export class EditFormComponent implements AfterViewInit, OnChanges {


public getLabel(group: Group): string {

return group.name === 'conflicts'
? $localize `:@@docedit.group.conflicts:Konflikte`
: this.labels.get(group);
Expand Down
6 changes: 2 additions & 4 deletions desktop/src/app/components/docedit/core/edit-form.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
</a>
</li>
</ul>
</div>

</div>
<div class="col-md-9 forms-container">
<div id="{{activeGroup}}-group" class="scrollable-group"
*ngIf="activeGroup !== 'conflicts' && activeGroup !== 'images'">
*ngIf="activeGroup !== 'conflicts' && activeGroup !== 'images' && activeGroup !== 'changes'">
<edit-form-group [document]="document"
[originalDocument]="originalDocument"
[fieldDefinitions]="getFields(activeGroup)"
Expand All @@ -29,7 +28,6 @@
[scrollTargetField]="scrollTargetField">
</edit-form-group>
</div>

<div *ngIf="activeGroup === 'conflicts'" id="docedit-conflicts-tab">
<docedit-conflicts-tab [document]="document"
[inspectedRevisions]="inspectedRevisions">
Expand Down
13 changes: 11 additions & 2 deletions desktop/src/app/components/docedit/docedit.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import { ConflictDeletedModalComponent } from './dialog/conflict-deleted-modal.c
import { DuplicateModalComponent } from './dialog/duplicate-modal.component';
import { EditSaveDialogComponent } from '../widgets/edit-save-dialog.component';
import { MessagesConversion } from './messages-conversion';


import { ChangesHistoryModalComponent } from '../widgets/changes-history-modal.component';
@Component({
selector: 'detail-modal',
templateUrl: './docedit.html',
Expand Down Expand Up @@ -207,6 +206,16 @@ export class DoceditComponent {
}
}


public showChangeHistory() {
const modalRef: NgbModalRef = this.modalService.open(
ChangesHistoryModalComponent,
{ animation: false, backdrop: 'static', keyboard: false, windowClass : "history-modal-content" }
);

modalRef.componentInstance.document = this.documentHolder.clonedDocument;
}


private updateFields() {

Expand Down
8 changes: 8 additions & 0 deletions desktop/src/app/components/docedit/docedit.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
</div>

<div>
<div class="btn-group" id="show-changes-history">
<button class="btn btn-secondary"
id="document-edit-button-show-changes-history"
(click)="showChangeHistory()">
<span class="mdi mdi-history"></span>
<span class="button-label" i18n="@@buttons.history">Änderungshistorie</span>
</button>
</div>
<div class="btn-group" id="save-button-group">
<button class="btn btn-success disabled pull-right"
id="document-edit-button-save-document"
Expand Down
2 changes: 1 addition & 1 deletion desktop/src/app/components/docedit/docedit.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ import { LiteratureEntryModalComponent } from './core/forms/array-field/literatu
MessagesModule,
WidgetsModule,
ImageGridModule,
ImageRowModule
ImageRowModule
],
declarations: [
ConflictDeletedModalComponent,
Expand Down
6 changes: 6 additions & 0 deletions desktop/src/app/components/docedit/docedit.scss
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
outline: none;
}

#document-edit-button-show-changes-history,
#document-edit-button-save-document,
#document-edit-button-goto-view,
#document-edit-button-dropdown {
Expand All @@ -116,6 +117,11 @@
color: #fff;
}

#document-edit-button-show-changes-history {
margin-right: 7px;
}


#document-edit-button-goto-view {
margin-left: 7px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { MenuContext } from '../../../../services/menu-context';
import { Menus } from '../../../../services/menus';
import { ComponentHelpers } from '../../../component-helpers';
import { WarningsService } from '../../../../services/warnings/warnings-service';

import { NgbModal } from '@ng-bootstrap/ng-bootstrap';

@Component({
selector: 'sidebar-list',
Expand Down Expand Up @@ -42,6 +42,7 @@ export class SidebarListComponent extends BaseList implements AfterViewInit, OnC

constructor(private navigationService: NavigationService,
private warningsService: WarningsService,
private modalService: NgbModal,
resourcesComponent: ResourcesComponent,
loading: Loading,
viewFacade: ViewFacade,
Expand Down Expand Up @@ -147,6 +148,9 @@ export class SidebarListComponent extends BaseList implements AfterViewInit, OnC
case 'move':
await this.resourcesComponent.moveDocuments(this.contextMenu.documents as Array<FieldDocument>);
break;
case 'show-history':
await this.resourcesComponent.showHistory(this.selectedDocument);
break;
case 'delete':
await this.resourcesComponent.deleteDocument(this.contextMenu.documents as Array<FieldDocument>);
break;
Expand Down
40 changes: 25 additions & 15 deletions desktop/src/app/components/resources/resources.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { MsgWithParams } from '../messages/msg-with-params';
import { QrCodeEditorModalComponent } from './actions/edit-qr-code/qr-code-editor-modal.component';
import { StoragePlaceScanner } from './actions/scan-storage-place/storage-place-scanner';
import { WarningsService } from '../../services/warnings/warnings-service';
import { ChangesHistoryModalComponent } from '../widgets/changes-history-modal.component';


@Component({
Expand Down Expand Up @@ -193,22 +194,12 @@ export class ResourcesComponent implements OnDestroy {

public async editQRCode(document: Document) {

try {
this.menuService.setContext(MenuContext.QR_CODE_EDITOR);
this.initModal(document, QrCodeEditorModalComponent, MenuContext.QR_CODE_EDITOR)
}

const modalRef: NgbModalRef = this.modalService.open(
QrCodeEditorModalComponent,
{ animation: false, backdrop: 'static', keyboard: false }
);
modalRef.componentInstance.document = document;
await modalRef.componentInstance.initialize();
AngularUtility.blurActiveElement();
await modalRef.result;
} catch (err) {
console.error(err);
} finally {
this.menuService.setContext(MenuContext.DEFAULT);
}
public async showHistory(document: Document) {

this.initModal(document, ChangesHistoryModalComponent, MenuContext.HISTORY_MODAL)
}


Expand Down Expand Up @@ -449,4 +440,23 @@ export class ResourcesComponent implements OnDestroy {
await this.routingService.jumpToResource(movedDocuments[0], false);
}
}

private async initModal(document: Document, component, menuContext){

try {
this.menuService.setContext(menuContext);
const modalRef: NgbModalRef = this.modalService.open(
component,
{ animation: false, backdrop: 'static', keyboard: false}
);
modalRef.componentInstance.document = document;
await modalRef.componentInstance.initialize();
AngularUtility.blurActiveElement();
await modalRef.result;
} catch (err) {
console.error(err);
} finally {
this.menuService.setContext(MenuContext.DEFAULT);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { UtilTranslations } from '../../../util/util-translations';


export type ResourcesContextMenuAction = 'edit'|'move'|'delete'|'warnings'|'edit-qr-code'|'edit-images'
|'scan-storage-place'|'create-polygon'|'create-line-string'|'create-point'|'edit-geometry';
|'scan-storage-place'|'create-polygon'|'create-line-string'|'create-point'|'edit-geometry'|'show-history';


@Component({
Expand Down Expand Up @@ -49,6 +49,7 @@ export class ResourcesContextMenuComponent implements OnChanges {
public areAnyOptionsAvailable(): boolean {

return this.isDeleteOptionAvailable()
|| this.isShowHistoryOptionAvailable()
|| this.isEditOptionAvailable()
|| this.isCreateGeometryOptionAvailable()
|| this.isEditGeometryOptionAvailable()
Expand Down Expand Up @@ -79,6 +80,10 @@ export class ResourcesContextMenuComponent implements OnChanges {
&& (!this.isReadonly() || !this.isTypeResource());
}

public isShowHistoryOptionAvailable(): boolean {

return this.contextMenu.documents.length === 1 && !this.isReadonly();
}

public isWarningsOptionAvailable(): boolean {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
<span class="mdi mdi-file-tree"></span>
<span class="dropdown-entry-label" i18n="@@resources.contextMenu.move">Verschieben</span>
</div>
<div *ngIf="isShowHistoryOptionAvailable()"
id="context-menu-show-history-button" class="dropdown-item"
(click)="selectAction('show-history')">
<span class="mdi mdi-history"></span>
<span class="dropdown-entry-label" i18n="@@resources.contextMenu.history">Änderungshistorie</span>
</div>
<div *ngIf="isDeleteOptionAvailable()"
id="context-menu-delete-button" class="dropdown-item" (click)="selectAction('delete')">
<span class="mdi mdi-delete"></span>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { Component} from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { Document } from 'idai-field-core';
import { CommonModule } from '@angular/common';

@Component({
selector: 'changes-history-modal',
imports: [CommonModule],
templateUrl: './changes-history-modal.html',
styleUrls: ['./changes-history-modal.scss']
})

export class ChangesHistoryModalComponent {

public escapeKeyPressed: boolean;
public document: Document;

constructor( public activeModal: NgbActiveModal,
) {}


public async onKeyDown(event: KeyboardEvent) {
if (event.key === 'Escape' && !this.escapeKeyPressed) {
this.activeModal.dismiss('cancel');
}

}


public async onKeyUp(event: KeyboardEvent) {
if (event.key === 'Escape') this.escapeKeyPressed = false;
}

public async initialize() {
// TODO remove this function ( called in private function initModal() )
1
}

public formatDateTime( date: string | Date, locale: string = 'de-DE' ) {
return new Date(date).toLocaleString(locale);
}

public sortModificationsBy(prop: string) {
return this.document.modified.sort((a, b) => a[prop] < b[prop] ? 1 : a[prop] === b[prop] ? 0 : -1);
}

}
33 changes: 33 additions & 0 deletions desktop/src/app/components/widgets/changes-history-modal.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<div class="modal-header">
<h5 class="modal-title" i18n="@@widgets.historyModal.header">Änderunghistorie</h5>
</div>

<div class="modal-body">
<p i18n="@@document.created.information.text">Die Ressource <b>{{document.resource.identifier}}</b> wurde vom Benutzer {{document.created.user}} am {{formatDateTime(document.created.date)}} erstellt.</p>
<div id="changes-history-modal-body" class="modal-body">
<div *ngIf="document.modified[0].user">
<div id="list">
<div id="list-header">
<div class="list-header-field" i18n="@@changes.list.colnames.date">Änderungsdatum</div>
<div class="list-header-field" i18n="@@changes.list.colnames.user">Benutzer</div>
</div>
<div class="list-body">
<!-- <div *ngFor="let modification of document.modified.reverse()" -->
<!-- <div *ngFor="let modification of document.modified" -->
<div *ngFor="let modification of sortModificationsBy('date')"
class = "list-row">
<div class= "list-body-field" [textContent]="formatDateTime(modification.date)"></div>
<div class= "list-body-field" [textContent]="modification.user"></div>
</div>
</div>
</div>
</div>
</div>
</div>

<div class="modal-footer">
<button id="overview-save-confirmation-modal-cancel-button" type="button" class="btn btn-secondary"
(click)="activeModal.dismiss('cancel')" i18n="@@buttons.cancel">Abbrechen</button>
</div>


38 changes: 38 additions & 0 deletions desktop/src/app/components/widgets/changes-history-modal.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#list {
background: white;
margin-bottom: -20px;

#list-header {
user-select: none;
display: grid;
grid-template-columns: 230px 100px 250px;
font-size: 16px;
font-weight: 500;

.list-header-field {
padding: 5px 5px 5px 10px;
color: rgb(73, 80, 87);
border: solid 1px rgb(221, 221, 221);
}
}

.list-body{
max-height: 66vh;
overflow: auto;
}

.list-row {
user-select: none;
display: grid;
grid-template-columns: 230px 100px 250px;
font-size: 16px;
font-weight: 500;

.list-body-field {
padding: 5px 5px 0px 10px;
color: rgb(73, 80, 87);
border: solid 1px rgb(221, 221, 221);
border-top: none;
}
}
}
3 changes: 2 additions & 1 deletion desktop/src/app/services/menu-context.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export type MenuContext = 'default'|'docedit'|'modal'|'projects'|'configuration'|'geometryEdit'|'mapLayersEdit'
|'georeferenceEdit'|'configurationEdit'|'configurationValuelistEdit'|'configurationSubfieldEdit'
|'configurationModal'|'configurationManagement'|'warnings'|'qrCodeEditor'|'qrCodeScanner'|'printSettingsModal';
|'configurationModal'|'configurationManagement'|'warnings'|'qrCodeEditor'|'qrCodeScanner'|'historyModal'|'printSettingsModal';


/**
Expand All @@ -22,6 +22,7 @@ export module MenuContext {
export const CONFIGURATION_MANAGEMENT = 'configurationManagement';
export const WARNINGS = 'warnings';
export const QR_CODE_EDITOR = 'qrCodeEditor';
export const HISTORY_MODAL = 'historyModal';
export const QR_CODE_SCANNER = 'qrCodeScanner';
export const PRINT_SETTINGS_MODAL = 'printSettingsModal';
}
Loading