From fa2d51551170f7d515ce91cc98791e0e82b77a5f Mon Sep 17 00:00:00 2001 From: Alex ORLUC <alex.orluc@maarch.org> Date: Wed, 26 Feb 2020 11:32:50 +0100 Subject: [PATCH] FEAT #13120 TIME 0:20 fix contacts card outgoing --- .../contact/list/contacts-list.component.html | 2 +- .../contact/list/contacts-list.component.ts | 2 +- .../app/process/process.component.html | 2 +- src/frontend/app/process/process.component.ts | 60 ++++++++++++++++++- 4 files changed, 61 insertions(+), 5 deletions(-) diff --git a/src/frontend/app/contact/list/contacts-list.component.html b/src/frontend/app/contact/list/contacts-list.component.html index a4555e1f26b..9bc356e98b4 100644 --- a/src/frontend/app/contact/list/contacts-list.component.html +++ b/src/frontend/app/contact/list/contacts-list.component.html @@ -64,7 +64,7 @@ <mat-list> <mat-list-item class="contact-item" *ngIf="!empty(contact.communicationMeans)" [title]="lang.communicationMean"> <mat-icon mat-list-icon class="contact-group fas fa-hashtag"></mat-icon> - <p mat-line class="contact-content"> {{contact.communicationMeans}} </p> + <p mat-line class="contact-content" [title]="contact.communicationMeans.url !== undefined ? contact.communicationMeans.url : contact.communicationMeans.email"> {{contact.communicationMeans.url !== undefined ? contact.communicationMeans.url : contact.communicationMeans.email}} </p> </mat-list-item> <ng-container *ngFor="let keyVal of contact.customFields | keyvalue" > <mat-list-item class="contact-item" *ngIf="keyVal.value.value !== null"> diff --git a/src/frontend/app/contact/list/contacts-list.component.ts b/src/frontend/app/contact/list/contacts-list.component.ts index 92dae84c4be..865c70ebb25 100644 --- a/src/frontend/app/contact/list/contacts-list.component.ts +++ b/src/frontend/app/contact/list/contacts-list.component.ts @@ -156,7 +156,7 @@ export class ContactsListComponent implements OnInit { Object.keys(data).forEach(element => { arrCustomFields.push({ - label: this.customFields.filter(custom => custom.id == element)[0].label, + label: this.customFields.filter(custom => custom.id == element).length > 0 ? this.customFields.filter(custom => custom.id == element)[0].label : element, value: data[element] }); }); diff --git a/src/frontend/app/process/process.component.html b/src/frontend/app/process/process.component.html index bf62e642bc0..cb0a0be81ce 100644 --- a/src/frontend/app/process/process.component.html +++ b/src/frontend/app/process/process.component.html @@ -202,7 +202,7 @@ {{this.currentResourceInformations.chrono}}</div> </div> <div class="content-item" (click)="openContact()" style="cursor:pointer"> - <div>{{lang.senders}} :</div> + <div>{{this.currentResourceInformations.categoryId !== 'outgoing' ? lang.senders : lang.recipient}} :</div> <div class="content-item-value">{{senderLightInfo.displayName}} <i *ngIf="this.senderLightInfo.filling" class="fas fa-circle" style="font-size: 8px" [style.color]="this.senderLightInfo.filling"></i></div> diff --git a/src/frontend/app/process/process.component.ts b/src/frontend/app/process/process.component.ts index fe9cfdac8f2..a806c5aff90 100755 --- a/src/frontend/app/process/process.component.ts +++ b/src/frontend/app/process/process.component.ts @@ -289,7 +289,11 @@ export class ProcessComponent implements OnInit { tap((data: any) => { this.currentResourceInformations = data; this.resourceFollowed = data.followed; - this.loadSenders(); + if (this.currentResourceInformations.categoryId !== 'outgoing') { + this.loadSenders(); + } else { + this.loadRecipients(); + } this.setEditDataPrivilege(); this.loadAvaibleIntegrations(data.integrations); this.headerService.setHeader(this.detailMode ? this.lang.detailDoc : this.lang.eventProcessDoc, this.lang[this.currentResourceInformations.categoryId]); @@ -425,6 +429,58 @@ export class ProcessComponent implements OnInit { } } + loadRecipients() { + + if (this.currentResourceInformations.recipients === undefined || this.currentResourceInformations.recipients.length === 0) { + this.hasContact = false; + this.senderLightInfo = { 'displayName': this.lang.noSelectedContact, 'filling': null }; + } else if (this.currentResourceInformations.recipients.length == 1) { + this.hasContact = true; + if (this.currentResourceInformations.recipients[0].type === 'contact') { + this.http.get('../../rest/contacts/' + this.currentResourceInformations.recipients[0].id).pipe( + tap((data: any) => { + const arrInfo = []; + if (this.empty(data.firstname) && this.empty(data.lastname)) { + if (!this.functions.empty(data.fillingRate)) { + this.senderLightInfo = { 'displayName': data.company, 'filling': this.contactService.getFillingColor(data.fillingRate.thresholdLevel) }; + } else { + this.senderLightInfo = { 'displayName': data.company }; + } + + } else { + arrInfo.push(data.firstname); + arrInfo.push(data.lastname); + if (!this.empty(data.company)) { + arrInfo.push('(' + data.company + ')'); + } + if (!this.functions.empty(data.fillingRate)) { + this.senderLightInfo = { 'displayName': arrInfo.filter(info => info !== '').join(' '), 'filling': this.contactService.getFillingColor(data.fillingRate.thresholdLevel) }; + } else { + this.senderLightInfo = { 'displayName': arrInfo.filter(info => info !== '').join(' ') }; + } + + } + }) + ).subscribe(); + } else if (this.currentResourceInformations.recipients[0].type == 'entity') { + this.http.get('../../rest/entities/' + this.currentResourceInformations.recipients[0].id).pipe( + tap((data: any) => { + this.senderLightInfo = { 'displayName': data.entity_label, 'filling': null }; + }) + ).subscribe(); + } else if (this.currentResourceInformations.recipients[0].type == 'user') { + this.http.get('../../rest/users/' + this.currentResourceInformations.recipients[0].id).pipe( + tap((data: any) => { + this.senderLightInfo = { 'displayName': data.firstname + ' ' + data.lastname, 'filling': null }; + }) + ).subscribe(); + } + } else if (this.currentResourceInformations.recipients.length > 1) { + this.hasContact = true; + this.senderLightInfo = { 'displayName': this.currentResourceInformations.recipients.length + ' ' + this.lang.recipients, 'filling': null }; + } + } + lockResource() { this.http.put(`../../rest/resourcesList/users/${this.currentUserId}/groups/${this.currentGroupId}/baskets/${this.currentBasketId}/lock`, { resources: [this.currentResourceInformations.resId] }).pipe( catchError((err: any) => { @@ -626,7 +682,7 @@ export class ProcessComponent implements OnInit { openContact() { if (this.hasContact) { - this.dialog.open(ContactsListModalComponent, { data: { title: `${this.currentResourceInformations.chrono} - ${this.currentResourceInformations.subject}`, mode: 'senders', resId: this.currentResourceInformations.resId } }); + this.dialog.open(ContactsListModalComponent, { data: { title: `${this.currentResourceInformations.chrono} - ${this.currentResourceInformations.subject}`, mode: this.currentResourceInformations.categoryId !== 'outgoing' ? 'senders' : 'recipients', resId: this.currentResourceInformations.resId } }); } } -- GitLab