diff --git a/src/frontend/app/notes/note-editor.component.html b/src/frontend/app/notes/note-editor.component.html index e9e1a410d9a77c3b13047742a844083dde359597..cdf56c5033cc5bd66b0e07a38cf367f24e3d38a0 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 206d036c8a37b9ed6caac320e9a3d1b6adc028cf..a99dbe61058a7a4404e8dd7268350a6c9b3654d7 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 b33a27d1360f0ca5b47ee12742d29e3220ac40f9..108d3870b78499b889ce342c944b13cc7c9bc34f 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 2f52bd4f41ae2358c48390d0e12479a08e597f6f..bb390c6fb10fa6cf9408135dfd66f967707bf330 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 76828fdfc9c9fbaadc1d3548e57134534d1b7397..dee075e213524d69982b04adbbdb3faf1c42ba61 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 2c50a4bf6ab74c8abef5c2a2be50d9703c97fd56..6fed12ec9228f3b8038c2c70d6582455694b6174 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 d2e3aebe09a16482e19ee2978f3087203a6a3979..d66576a8e933e5b982358bf12fa248625d0b962f 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 d4b91c7eab37208c908b14415dccad06e477157b..716d83df86cdda54ffa30b06b63d74bf19848933 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