Skip to content

Commit

Permalink
Add editor name prompt on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
GuzzoD committed Jun 20, 2023
1 parent 997a94e commit 713b252
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 1 deletion.
27 changes: 27 additions & 0 deletions desktop/src/app/components/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ChangeDetectorRef, Component } from '@angular/core';
import { Event, NavigationStart, Router } from '@angular/router';
import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
import { I18n } from '@ngx-translate/i18n-polyfill';
import { Messages } from './messages/messages';
import { SettingsService } from '../services/settings/settings-service';
Expand All @@ -10,6 +11,7 @@ import { UtilTranslations } from '../util/util-translations';
import { AppController } from '../services/app-controller';
import { ImageUrlMaker } from '../services/imagestore/image-url-maker';
import { ConfigurationChangeNotifications } from './configuration/notifications/configuration-change-notifications';
import { UpdateEditorComponent } from './settings/update-editor';

const remote = typeof window !== 'undefined' ? window.require('@electron/remote') : undefined;
const ipcRenderer = typeof window !== 'undefined' ? window.require('electron').ipcRenderer : undefined;
Expand All @@ -34,6 +36,7 @@ export class AppComponent {
configurationChangeNotifications: ConfigurationChangeNotifications,
imageUrlMaker: ImageUrlMaker,
settingsService: SettingsService,
private modalService: NgbModal,
private messages: Messages,
private i18n: I18n,
private utilTranslations: UtilTranslations,
Expand Down Expand Up @@ -61,6 +64,10 @@ export class AppComponent {
AppComponent.preventDefaultDragAndDropBehavior();
this.initializeUtilTranslations();
this.listenToSettingsChangesFromMenu();

if (settingsProvider.getSettings()["username"] == "anonymous") {
this.promptEditorName()
}
}


Expand Down Expand Up @@ -131,4 +138,24 @@ export class AppComponent {
document.addEventListener('dragover', event => event.preventDefault());
document.addEventListener('drop', event => event.preventDefault());
}

private async promptEditorName() {
//this.menus.setContext(MenuContext.CONFIGURATION_MODAL);

try {
const modalRef: NgbModalRef = this.modalService.open(
UpdateEditorComponent, { animation: false }
);

//await modalRef.result;
return true;
} catch (_) {
return false;
} finally {
//this.menus.setContext(MenuContext.CONFIGURATION);
}


//router.navigate(["settings"])
}
}
5 changes: 4 additions & 1 deletion desktop/src/app/components/settings/settings.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { WidgetsModule } from '../widgets/widgets.module';
import { SettingsComponent } from './settings.component';
import { LanguageSettingsComponent } from './language-settings.component';
import { LanguagePickerModalComponent } from '../widgets/languages/language-picker-modal.component';
import { UpdateEditorComponent } from './update-editor';



@NgModule({
Expand All @@ -20,7 +22,8 @@ import { LanguagePickerModalComponent } from '../widgets/languages/language-pick
declarations: [
SettingsComponent,
LanguageSettingsComponent,
LanguagePickerModalComponent
LanguagePickerModalComponent,
UpdateEditorComponent
],
providers: [],
entryComponents: [
Expand Down
35 changes: 35 additions & 0 deletions desktop/src/app/components/settings/update-editor.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<div class="modal-header">
<!-- TODO: Anpassen -->
<h5 i18n="@@settings.userName">Name des Bearbeiters/der Bearbeiterin</h5>
</div>

<div class="modal-body">
<div i18n="@@settings.userName.info">
Dieser Name wird in der Bearbeitungshistorie gespeichert,
damit Änderungen an Datensätzen einer Person zugeordnet werden können.
Diese Einstellung ist sehr <b>wichtig</b> bei der Datenbanksynchronisation,
sowohl zwischen Nutzern bzw. Nutzerinnen als auch zum Field-Server, da das System
so eventuelle Konflikte besser zuordnen und lösen kann. Sie sollte also in jedem Fall
vor Inbetriebnahme gesetzt werden. Empfohlen wird, den vollen Namen des aktuellen
Datenbanknutzers bzw. der Datenbanknutzerin einzutragen.
</div>

<div class="form-group" style="margin-bottom: 0; margin-top: 15px;">
<input id="username-input"
[ngModel]="currentEditor"
(ngModelChange)="currentEditor = $event"
class="form-control">
</div>
</div>

<div class="modal-footer">
<button id="confirm-button" class="btn btn-success"
(click)="confirm()">
<span class="mdi mdi-content-save"></span>
<span class="button-label" i18n="@@buttons.save">Speichern</span>
</button>
<div class="btn btn-secondary"
(click)="cancel()">
<span i18n="@@buttons.cancel">Abbrechen</span>
</div>
</div>
35 changes: 35 additions & 0 deletions desktop/src/app/components/settings/update-editor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Component } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { SettingsService } from '../../services/settings/settings-service';
import { SettingsProvider } from '../../services/settings/settings-provider';
import { Settings } from '../../services/settings/settings';


@Component({
templateUrl: './update-editor.html'
})
/**
* @author Danilo Guzzo
*/
export class UpdateEditorComponent {
public currentEditor: string;

constructor(
public activeModal: NgbActiveModal,
private settingsService: SettingsService,
private settingsProvider: SettingsProvider
) {
this.currentEditor = this.settingsProvider.getSettings()["username"];
}

public confirm = () => {
console.log(this.currentEditor);
let oldSettings: Settings = this.settingsProvider.getSettings();
oldSettings.username = this.currentEditor;

this.settingsService.updateSettings(oldSettings);
this.activeModal.close();
}

public cancel = () => this.activeModal.dismiss('cancel');
}

0 comments on commit 713b252

Please sign in to comment.