diff --git a/src/frontend/app/notes/note-editor.component.ts b/src/frontend/app/notes/note-editor.component.ts index 949119d491db051036f64d007ddebe68fdca82b8..1d5fe2005a271bd1f8b54387a5592738b8f33ba6 100644 --- a/src/frontend/app/notes/note-editor.component.ts +++ b/src/frontend/app/notes/note-editor.component.ts @@ -53,15 +53,15 @@ export class NoteEditorComponent implements OnInit { setDefaultRestriction() { this.entitiesRestriction = []; - this.http.get(`../../rest/resources/${this.resIds[0]}?light=true`).pipe( + this.http.get(`../../rest/resources/${this.resIds[0]}/fields/destination`).pipe( tap((data: any) => { this.entitiesRestriction = this.headerService.user.entities.map((entity: any) => entity.entity_id); + if (this.entitiesRestriction.indexOf(data.field) === -1) { + this.entitiesRestriction.push(data.field); + } this.entities.filter((entity: any) => this.entitiesRestriction.indexOf(entity.id) > -1).forEach((element: any) => { element.selected = true; }); - if (this.entitiesRestriction.indexOf(data.destination) === -1) { - this.entitiesRestriction.push(data.destination); - } }), catchError((err: any) => { this.notify.handleSoftErrors(err); diff --git a/src/frontend/app/sendedResource/sended-resource-page/sended-resource-page.component.ts b/src/frontend/app/sendedResource/sended-resource-page/sended-resource-page.component.ts index 88c37a80fdca624c739e9bfc0aab2fc02d32dbd4..2a6fa131cc6e53840a0c76a8f43b40c33fe52a6f 100644 --- a/src/frontend/app/sendedResource/sended-resource-page/sended-resource-page.component.ts +++ b/src/frontend/app/sendedResource/sended-resource-page/sended-resource-page.component.ts @@ -553,19 +553,22 @@ export class SendedResourcePageComponent implements OnInit { onSubmit(textMode: string = 'html') { this.emailStatus = 'WAITING'; if (this.data.emailId === null) { - if (this.emailsubject === '') { - const dialogRef = this.dialog.open(ConfirmComponent, { autoFocus: false, disableClose: true, data: { title: this.lang.confirm, msg: 'Vous allez envoyer un courriel sans sujet, continuer ?' } }); - - dialogRef.afterClosed().pipe( - filter((data: string) => data === 'ok'), - tap(() => { - this.createEmail(textMode, true); - }) - ).subscribe(); + if (!this.isAllEmailRightFormat()) { + this.notify.error(this.lang.badEmailsFormat); } else { - this.createEmail(textMode, true); + if (this.emailsubject === '') { + const dialogRef = this.dialog.open(ConfirmComponent, { autoFocus: false, disableClose: true, data: { title: this.lang.confirm, msg: this.lang.warnEmptySubject } }); + + dialogRef.afterClosed().pipe( + filter((data: string) => data === 'ok'), + tap(() => { + this.createEmail(textMode, true); + }) + ).subscribe(); + } else { + this.createEmail(textMode, true); + } } - } else { this.updateEmail(textMode, true); } @@ -599,7 +602,7 @@ export class SendedResourcePageComponent implements OnInit { filter((data: string) => data === 'ok'), exhaustMap(() => this.http.delete(`../../rest/emails/${this.data.emailId}`)), tap(() => { - this.notify.success("Courriel supprimé"); + this.notify.success(this.lang.emailDeleted); this.closeModal('success'); }), catchError((err) => { @@ -734,4 +737,17 @@ export class SendedResourcePageComponent implements OnInit { return false; } } + + isAllEmailRightFormat() { + let state = true; + const allEmail = this.recipients.concat(this.copies).concat(this.invisibleCopies); + + allEmail.map(item => item.email).forEach(email => { + if (this.isBadEmailFormat(email)) { + state = false; + } + }); + + return state; + } } diff --git a/src/frontend/lang/lang-en.ts b/src/frontend/lang/lang-en.ts index dba973752594f800df9290ca602e77de68fb44ab..24a870467fc6ffc66b9e18886caf2aab1abf5569 100755 --- a/src/frontend/lang/lang-en.ts +++ b/src/frontend/lang/lang-en.ts @@ -1524,5 +1524,8 @@ export const LANG_EN = { "draftUpdated" : "Draft updated", "sendingEmail" : "Sending email...", "restrictions" : "Restrictions", - "contactDeleted" : "Contact deleted" + "contactDeleted" : "Contact deleted", + "badEmailsFormat" : "Some email address are not correct", + "warnEmptySubject" : "You will send an email without subject, continue ?", + "emailDeleted" : "Email deleted", }; diff --git a/src/frontend/lang/lang-fr.ts b/src/frontend/lang/lang-fr.ts index cc300c48b857e6d0fda955acfa56931a6713c3a5..8547422ce0aac8191ea42523a8ac70a8caddbc3b 100755 --- a/src/frontend/lang/lang-fr.ts +++ b/src/frontend/lang/lang-fr.ts @@ -1563,5 +1563,8 @@ export const LANG_FR = { "draftUpdated" : "Brouillon modifié", "sendingEmail" : "Email en cours d'envoi...", "restrictions" : "Restrictions", - "contactDeleted" : "Contact supprimé" + "contactDeleted" : "Contact supprimé", + "badEmailsFormat" : "Certaines adresses de courriel ne sont pas correctes", + "warnEmptySubject" : "Vous allez envoyer un courriel sans sujet, continuer ?", + "emailDeleted" : "Courriel supprimé", }; diff --git a/src/frontend/lang/lang-nl.ts b/src/frontend/lang/lang-nl.ts index daff9c6386d36ce20897f03e0a31f7e451a0cab2..e4e5634e0a0a46c988d733018660df211af108ce 100755 --- a/src/frontend/lang/lang-nl.ts +++ b/src/frontend/lang/lang-nl.ts @@ -1549,5 +1549,8 @@ export const LANG_NL = { "draftUpdated" : "Draft updated", //_TO_TRANSLATE "sendingEmail" : "Sending email...", //_TO_TRANSLATE "restrictions" : "Restrictions", //_TO_TRANSLATE - "contactDeleted" : "Contact deleted" //_TO_TRANSLATE + "contactDeleted" : "Contact deleted", //_TO_TRANSLATE + "badEmailsFormat" : "Some email address are not correct", //_TO_TRANSLATE + "warnEmptySubject" : "You will send an email without subject, continue ?", //_TO_TRANSLATE + "emailDeleted" : "Email deleted", //_TO_TRANSLATE };