From 0a4ca3860a96ebeb4f2f53574d6e832a06da679c Mon Sep 17 00:00:00 2001 From: "florian.azizian" <florian.azizian@maarch.org> Date: Thu, 13 Feb 2020 16:54:04 +0100 Subject: [PATCH] FEAT #12071 TIME 1 front update note --- .../app/notes/note-editor.component.html | 4 ++++ .../app/notes/note-editor.component.ts | 19 ++++++++++++++++++- .../app/notes/notes-list.component.html | 8 ++++++-- .../app/notes/notes-list.component.scss | 8 +++++--- src/frontend/app/notes/notes.component.ts | 8 ++++++++ src/frontend/lang/lang-en.ts | 1 + src/frontend/lang/lang-fr.ts | 1 + src/frontend/lang/lang-nl.ts | 1 + 8 files changed, 44 insertions(+), 6 deletions(-) diff --git a/src/frontend/app/notes/note-editor.component.html b/src/frontend/app/notes/note-editor.component.html index e9e1a410d9a..cdf56c5033c 100644 --- a/src/frontend/app/notes/note-editor.component.html +++ b/src/frontend/app/notes/note-editor.component.html @@ -21,4 +21,8 @@ [disabled]="content.trim() == '' || loading"> <mat-icon fontSet="far" fontIcon="fa-paper-plane fa-2x"></mat-icon> </button> + <button *ngIf="upMode" color="primary" matSuffix mat-icon-button title="{{lang.validate}}" (click)="updateNote()" + [disabled]="content.trim() == '' || loading"> + <mat-icon fontSet="far" fontIcon="fa-paper-plane fa-2x"></mat-icon> + </button> </mat-form-field> \ No newline at end of file diff --git a/src/frontend/app/notes/note-editor.component.ts b/src/frontend/app/notes/note-editor.component.ts index 206d036c8a3..a99dbe61058 100644 --- a/src/frontend/app/notes/note-editor.component.ts +++ b/src/frontend/app/notes/note-editor.component.ts @@ -20,12 +20,20 @@ export class NoteEditorComponent implements AfterViewInit { @Input('content') content: string = ''; @Input('resIds') resIds: any[]; @Input('addMode') addMode: boolean; + @Input('upMode') upMode: boolean; + @Input('noteContent') noteContent: string; + @Input('noteId') noteId: number; @Output('refreshNotes') refreshNotes = new EventEmitter<string>(); constructor(public http: HttpClient) { } - ngAfterViewInit() { + ngOnInit() { + if (this.upMode) { + this.content = this.noteContent; + } + } + ngAfterViewInit() { } addNote() { @@ -37,6 +45,15 @@ export class NoteEditorComponent implements AfterViewInit { }); } + updateNote() { + this.loading = true; + this.http.put("../../rest/notes/" + this.noteId, { value: this.content, resId: this.resIds[0] }) + .subscribe((data: any) => { + this.refreshNotes.emit(this.resIds[0]); + this.loading = false; + }); + } + getNoteContent() { return this.content; } diff --git a/src/frontend/app/notes/notes-list.component.html b/src/frontend/app/notes/notes-list.component.html index b33a27d1360..108d3870b78 100644 --- a/src/frontend/app/notes/notes-list.component.html +++ b/src/frontend/app/notes/notes-list.component.html @@ -14,12 +14,16 @@ <mat-card-subtitle title='{{note.creation_date | fullDate}}' class="dateNote">{{note.creation_date | timeAgo}}</mat-card-subtitle> <mat-card-subtitle *ngIf="note.user_id == headerService.user.id" class="removeNote"> - <button matSuffix mat-icon-button title='{{lang.removeNote}}' (click)="removeNote(note)"> + <button matSuffix mat-icon-button title='{{lang.editNote}}' class="editNote" (click)="editNote(note)"> + <mat-icon fontSet="fas" fontIcon="fa-pencil-alt fa-2x"></mat-icon> + </button> + <button matSuffix mat-icon-button title='{{lang.removeNote}}' style="color: red;" (click)="removeNote(note)"> <mat-icon fontSet="far" fontIcon="fa-trash-alt fa-2x"></mat-icon> </button> </mat-card-subtitle> </mat-card-header> - <mat-card-content> + <app-note-editor *ngIf="note.edit" #noteEditor [resIds]="resIds" [upMode]="true" [noteId]="note.id" [noteContent]="note.value" (refreshNotes)="loadNotes($event)" style="margin: 20px;display: flex;"></app-note-editor> + <mat-card-content *ngIf="!note.edit"> <p class="noteTextContent"> {{note.value}} </p> diff --git a/src/frontend/app/notes/notes-list.component.scss b/src/frontend/app/notes/notes-list.component.scss index 2f52bd4f41a..bb390c6fb10 100644 --- a/src/frontend/app/notes/notes-list.component.scss +++ b/src/frontend/app/notes/notes-list.component.scss @@ -48,13 +48,15 @@ .removeNote { position: absolute; - font-size: 12px; - margin: 0; top: 22px; - color: red; right: 0px; } +.editNote { + margin-right: -10px; + color: $primary; +} + .noteTextContent { white-space: pre-line; padding: 30px; diff --git a/src/frontend/app/notes/notes.component.ts b/src/frontend/app/notes/notes.component.ts index 76828fdfc9c..dee075e2135 100644 --- a/src/frontend/app/notes/notes.component.ts +++ b/src/frontend/app/notes/notes.component.ts @@ -80,4 +80,12 @@ export class NotesListComponent implements OnInit { }) ).subscribe(); } + + editNote(note: any) { + if (!note.edit) { + note.edit = true; + } else { + note.edit = false; + } + } } diff --git a/src/frontend/lang/lang-en.ts b/src/frontend/lang/lang-en.ts index 2c50a4bf6ab..6fed12ec922 100755 --- a/src/frontend/lang/lang-en.ts +++ b/src/frontend/lang/lang-en.ts @@ -1471,6 +1471,7 @@ export const LANG_EN = { "chooseBAN": "Choose a BAN", "click": "Click", "removeNote" : "Remove note", + "editNote" : "Edit note", "noteRemoved" : "Note deleted", "confirmRemoveNote" : "Note deletion", "inSignatureBook_doc" : "Put the main document in signature book", diff --git a/src/frontend/lang/lang-fr.ts b/src/frontend/lang/lang-fr.ts index d2e3aebe09a..d66576a8e93 100755 --- a/src/frontend/lang/lang-fr.ts +++ b/src/frontend/lang/lang-fr.ts @@ -1510,6 +1510,7 @@ export const LANG_FR = { "chooseBAN": "Choisissez une BAN", "click": "Cliquez", "removeNote" : "Supprimer l'annotation", + "editNote" : "Modifier l'annotation", "noteRemoved" : "Annotation supprimée", "confirmRemoveNote" : "Suppression de l'annotation", "inSignatureBook_doc" : "Intégrer le document principal au parapheur", diff --git a/src/frontend/lang/lang-nl.ts b/src/frontend/lang/lang-nl.ts index d4b91c7eab3..716d83df86c 100755 --- a/src/frontend/lang/lang-nl.ts +++ b/src/frontend/lang/lang-nl.ts @@ -1496,6 +1496,7 @@ export const LANG_NL = { "chooseBAN": "Choose a BAN", //_TO_TRANSLATE "click": "Click", //_TO_TRANSLATE "removeNote" : "Remove note", //_TO_TRANSLATE + "editNote" : "Edit note", //_TO_TRANSLATE "noteRemoved" : "Note deleted", //_TO_TRANSLATE "confirmRemoveNote" : "Note deletion", //_TO_TRANSLATE "inSignatureBook_doc" : "Put the main document in signature book", //_TO_TRANSLATE -- GitLab