diff --git a/src/frontend/app/notes/note-editor.component.ts b/src/frontend/app/notes/note-editor.component.ts index 1d5fe2005a271bd1f8b54387a5592738b8f33ba6..491916810674f5879714658b45354c726fd09448 100644 --- a/src/frontend/app/notes/note-editor.component.ts +++ b/src/frontend/app/notes/note-editor.component.ts @@ -5,6 +5,7 @@ import { NotificationService } from '../notification.service'; import { catchError, tap } from 'rxjs/operators'; import { HeaderService } from '../../service/header.service'; import { of } from 'rxjs'; +import { FunctionsService } from '../../service/functions.service'; @Component({ selector: 'app-note-editor', @@ -36,7 +37,8 @@ export class NoteEditorComponent implements OnInit { constructor( public http: HttpClient, private notify: NotificationService, - public headerService: HeaderService) { } + public headerService: HeaderService, + public functions: FunctionsService) { } async ngOnInit() { await this.getEntities(); @@ -56,7 +58,7 @@ export class NoteEditorComponent implements OnInit { 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) { + if (this.entitiesRestriction.indexOf(data.field) === -1 && !this.functions.empty(data.field)) { this.entitiesRestriction.push(data.field); } this.entities.filter((entity: any) => this.entitiesRestriction.indexOf(entity.id) > -1).forEach((element: any) => { diff --git a/src/frontend/app/sendedResource/sended-resource-page/sended-resource-page.component.html b/src/frontend/app/sendedResource/sended-resource-page/sended-resource-page.component.html index d94cd8709eec5fa7c4f7334a033354f90079c76a..014927dd763269aaf142e64dc7c5df386998e1eb 100644 --- a/src/frontend/app/sendedResource/sended-resource-page/sended-resource-page.component.html +++ b/src/frontend/app/sendedResource/sended-resource-page/sended-resource-page.component.html @@ -29,9 +29,9 @@ [cdkDropListConnectedTo]="['copies-list','invcopies-list']" [cdkDropListData]="recipients" (cdkDropListDropped)="drop($event)"> <mat-chip cdkDrag class="recipients" *ngFor="let recipient of recipients" [selectable]="selectable" - [removable]="canManageMail()" (removed)="remove(recipient, 'recipients')" [title]="recipient.email" + [removable]="canManageMail()" (removed)="remove(recipient, 'recipients')" (click)="remove(recipient, 'recipients')" [title]="recipient.email" [class.badFormat]="recipient.badFormat"> - {{recipient.label}} + {{recipient.label}}{{recipient.label !== recipient.email ? ' (' + recipient.email + ')' : ''}} <mat-icon matChipRemove class="fa fa-times" *ngIf="canManageMail()"></mat-icon> </mat-chip> <input [formControl]="recipientsInput" [matChipInputFor]="recipientsList" @@ -52,9 +52,9 @@ [cdkDropListConnectedTo]="['recipients-list','invcopies-list']" [cdkDropListData]="copies" (cdkDropListDropped)="drop($event)"> <mat-chip cdkDrag class="copy" *ngFor="let copy of copies" [selectable]="selectable" - [removable]="canManageMail()" (removed)="remove(copy, 'copies')" [title]="copy.email" + [removable]="canManageMail()" (removed)="remove(copy, 'copies')" (click)="remove(copycopy, 'recipients')" [title]="copy.email" [class.badFormat]="copy.badFormat"> - {{copy.label}} + {{copy.label}}{{copy.label !== copy.email ? ' (' + copy.email + ')' : ''}} <mat-icon matChipRemove class="fa fa-times" *ngIf="canManageMail()"></mat-icon> </mat-chip> <input [formControl]="recipientsInput" [matChipInputFor]="copiesList" @@ -75,9 +75,9 @@ [cdkDropListConnectedTo]="['recipients-list','copies-list']" [cdkDropListData]="invisibleCopies" (cdkDropListDropped)="drop($event)"> <mat-chip class="copy" *ngFor="let invCopy of invisibleCopies" [selectable]="selectable" - [removable]="canManageMail()" (removed)="remove(invCopy, 'invisibleCopies')" [title]="invCopy.email" + [removable]="canManageMail()" (removed)="remove(invCopy, 'invisibleCopies')" (click)="remove(invCopy, 'recipients')" [title]="invCopy.email" [class.badFormat]="invCopy.badFormat"> - {{invCopy.label}} + {{invCopy.label}}{{invCopy.label !== invCopy.email ? ' (' + invCopy.email + ')' : ''}} <mat-icon matChipRemove class="fa fa-times" *ngIf="canManageMail()"></mat-icon> </mat-chip> <input [formControl]="recipientsInput" [matChipInputFor]="invCopiesList" @@ -97,7 +97,7 @@ <input matInput [placeholder]="lang.object" [readonly]="!canManageMail()" [(ngModel)]="emailsubject" maxlength="70"> <button mat-icon-button matSuffix *ngFor="let keyVal of emailAttachTool | keyvalue" - [disabled]="!canManageMail() || emailAttachTool[keyVal.key].list.length === 0" + [disabled]="!canManageMail() || (emailAttachTool[keyVal.key].list.length === 0)" [title]="emailAttachTool[keyVal.key].title" (click)="$event.stopPropagation();currentEmailAttachTool=keyVal.key;" [matMenuTriggerFor]="emailAttachListMenu"> @@ -110,7 +110,7 @@ <ng-container *ngIf="keyVal.key === currentEmailAttachTool"> <button mat-menu-item style="line-height: normal;" disableRipple *ngFor="let attach of emailAttachTool[keyVal.key].list" - [disabled]="isSelectedAttachMail(attach,keyVal.key)"> + [disabled]="isSelectedAttachMail(attach,keyVal.key)" (click)="$event.stopPropagation();"> <span (click)="toggleAttachMail(attach,keyVal.key,'original')" [title]="attach.label"> <div style="font-size: 10px;opacity: 0.5;">{{attach.chrono}} - {{attach.typeLabel}} ({{attach.creator}})</div> diff --git a/src/frontend/app/sendedResource/sended-resource-page/sended-resource-page.component.scss b/src/frontend/app/sendedResource/sended-resource-page/sended-resource-page.component.scss index f164fdcbe413319c4b1a4d5237b9e115d28f9d16..64aae6a167e60945dfcb1892f880b3f1a6e04b14 100644 --- a/src/frontend/app/sendedResource/sended-resource-page/sended-resource-page.component.scss +++ b/src/frontend/app/sendedResource/sended-resource-page/sended-resource-page.component.scss @@ -23,6 +23,7 @@ min-height: auto; height: auto; border-radius: 5px; + cursor: pointer; .mat-icon { width: auto; 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 2a6fa131cc6e53840a0c76a8f43b40c33fe52a6f..1ce2f39f5d528168672e82fbc8f0487d27ff390b 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 @@ -277,11 +277,12 @@ export class SendedResourcePageComponent implements OnInit { } remove(item: any, type: string): void { + if (this.canManageMail()) { + const index = this[type].indexOf(item); - const index = this[type].indexOf(item); - - if (index >= 0) { - this[type].splice(index, 1); + if (index >= 0) { + this[type].splice(index, 1); + } } } @@ -290,10 +291,7 @@ export class SendedResourcePageComponent implements OnInit { this.http.get(`../../rest/emails/${emailId}`).pipe( tap((data: any) => { this.emailCreatorId = data.userId; - this.currentSender = { - label: data.sender.email, - email: data.sender.email - }; + this.recipients = data.recipients.map((item: any) => { return { label: item, @@ -323,8 +321,16 @@ export class SendedResourcePageComponent implements OnInit { this.emailsubject = data.object; this.emailStatus = data.status; - this.emailContent = data.body; + if (!this.canManageMail()) { + this.currentSender = { + label: data.sender.email, + email: data.sender.email, + entityId : data.sender.entityId + }; + } + this.emailContent = data.body; + console.log(this.emailAttachTool); Object.keys(data.document).forEach(element => { if (['id', 'isLinked', 'original'].indexOf(element) === -1) { data.document[element].forEach((dataAttach: any) => { @@ -334,7 +340,8 @@ export class SendedResourcePageComponent implements OnInit { return { ...item, format: dataAttach.original || dataAttach.original === undefined ? item.format : 'pdf', - original: dataAttach.original + original: dataAttach.original, + size : dataAttach.original || dataAttach.original === undefined ? item.size : item.convertedDocument.size } }) } @@ -342,8 +349,10 @@ export class SendedResourcePageComponent implements OnInit { } else if (element === 'isLinked' && data.document.isLinked === true) { this.emailAttach.document.isLinked = true; this.emailAttach.document.original = data.document.original; + this.emailAttach.document.size = this.emailAttach.document.original ? this.emailAttachTool.document.list[0].size : this.emailAttachTool.document.list[0].convertedDocument.size } }); + resolve(true); }), catchError((err) => { @@ -460,7 +469,7 @@ export class SendedResourcePageComponent implements OnInit { this.http.get(`../../rest/resources/${this.data.resId}/emailsInitialization`).pipe( tap((data: any) => { Object.keys(data).forEach(element => { - if (element === 'resource') { + if (element === 'resource') { this.emailAttachTool.document.list = [data[element]]; } else { this.emailAttachTool[element].list = data[element].map((item: any) => { @@ -656,13 +665,15 @@ export class SendedResourcePageComponent implements OnInit { if (this.emailAttach.document.isLinked === false) { this.emailAttach.document.isLinked = true; this.emailAttach.document.original = mode === 'pdf' ? false : true; + this.emailAttach.document.size = mode === 'pdf' ? item.convertedDocument.size : item.size; } } else { if (this.emailAttach[type].filter((attach: any) => attach.id === item.id).length === 0) { this.emailAttach[type].push({ ...item, format: mode !== 'pdf' ? item.format : 'pdf', - original: mode === 'pdf' ? false : true + original: mode === 'pdf' ? false : true, + size : mode === 'pdf' ? item.convertedDocument.size : item.size }); } } diff --git a/src/frontend/lang/lang-fr.ts b/src/frontend/lang/lang-fr.ts index e2aff393507778f3c6a17cb5e93005ebac87a7d9..4fae0ce8c12c1d6eb2614964a1edee161ba0dffe 100755 --- a/src/frontend/lang/lang-fr.ts +++ b/src/frontend/lang/lang-fr.ts @@ -1551,7 +1551,7 @@ export const LANG_FR = { "copieShort" : "Cc", "invisibleCopyShort" : "Cci", "shipping" : "Envoi maileva", - "sendElement" : "Envoyer un element", + "sendElement" : "Envoyer un élément", "pdfVersion" : "Version PDF", "emailModel" : "Modèle de courriel", "sendInPlainText" : "Envoyer en texte brut",