From ad44a9292ba93e742318e0839591bf40332279a0 Mon Sep 17 00:00:00 2001
From: Alex ORLUC <alex.orluc@maarch.org>
Date: Fri, 28 Feb 2020 19:12:19 +0100
Subject: [PATCH] FIX #13299 TIME 0:25 add badge filling

---
 .../contact-autocomplete.component.html       |  2 +-
 .../contact-autocomplete.component.scss       |  5 ++--
 .../contact-autocomplete.component.ts         | 25 +++++++++++++------
 3 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/src/frontend/app/contact/autocomplete/contact-autocomplete.component.html b/src/frontend/app/contact/autocomplete/contact-autocomplete.component.html
index 964b558a920..aab18914f73 100644
--- a/src/frontend/app/contact/autocomplete/contact-autocomplete.component.html
+++ b/src/frontend/app/contact/autocomplete/contact-autocomplete.component.html
@@ -126,7 +126,7 @@
                             *ngIf="!empty(this.valuesToDisplay[item.id].company)">
                             ({{this.valuesToDisplay[item.id].company}})</ng-container>
                     </span>
-                    <i class="fa fa-circle" [style.color]="valuesToDisplay[item.id].fillingRate.color" style="font-size: 9px;"></i>
+                    <i *ngIf="!functions.empty(valuesToDisplay[item.id].fillingRate.color)" class="fa fa-circle" [style.color]="valuesToDisplay[item.id].fillingRate.color" style="font-size: 9px;"></i>
                     <mat-icon matChipRemove class="fa fa-times" *ngIf="!controlAutocomplete.disabled"></mat-icon>
                 </mat-chip>
             </ng-container>
diff --git a/src/frontend/app/contact/autocomplete/contact-autocomplete.component.scss b/src/frontend/app/contact/autocomplete/contact-autocomplete.component.scss
index aac0aa2f020..626f76393de 100644
--- a/src/frontend/app/contact/autocomplete/contact-autocomplete.component.scss
+++ b/src/frontend/app/contact/autocomplete/contact-autocomplete.component.scss
@@ -10,8 +10,9 @@
 }
 
 .mat-chip.mat-standard-chip {
-    color: white;
-    background-color: lighten($primary, 10%);
+    color: lighten($primary, 10%);
+    background-color: white;
+    border: solid 1px lighten($primary, 10%);
 }
 
 .noResult {
diff --git a/src/frontend/app/contact/autocomplete/contact-autocomplete.component.ts b/src/frontend/app/contact/autocomplete/contact-autocomplete.component.ts
index 705cef1320e..0df47ebd84e 100755
--- a/src/frontend/app/contact/autocomplete/contact-autocomplete.component.ts
+++ b/src/frontend/app/contact/autocomplete/contact-autocomplete.component.ts
@@ -14,6 +14,7 @@ import { PrivilegeService } from '../../../service/privileges.service';
 import { ContactModalComponent } from '../../administration/contact/modal/contact-modal.component';
 import { ContactService } from '../../../service/contact.service';
 import { DocumentViewerComponent } from '../../viewer/document-viewer.component';
+import { FunctionsService } from '../../../service/functions.service';
 
 @Component({
     selector: 'app-contact-autocomplete',
@@ -22,7 +23,7 @@ import { DocumentViewerComponent } from '../../viewer/document-viewer.component'
         'contact-autocomplete.component.scss',
         '../../indexation/indexing-form/indexing-form.component.scss'
     ],
-    providers: [NotificationService, AppService, SortPipe, ContactService]
+    providers: [AppService, SortPipe, ContactService]
 })
 
 export class ContactAutocompleteComponent implements OnInit {
@@ -70,6 +71,7 @@ export class ContactAutocompleteComponent implements OnInit {
         private latinisePipe: LatinisePipe,
         private privilegeService: PrivilegeService,
         private contactService: ContactService,
+        public functions: FunctionsService
     ) {
 
     }
@@ -168,7 +170,10 @@ export class ContactAutocompleteComponent implements OnInit {
                 type: '',
                 firstname: '',
                 lastname: this.lang.undefined,
-                company: ''
+                company: '',
+                fillingRate: {
+                    color: ''
+                }
             };
 
             if (contact.type === 'contact') {
@@ -179,9 +184,9 @@ export class ContactAutocompleteComponent implements OnInit {
                             firstname: data.firstname,
                             lastname: data.lastname,
                             company: data.company,
-                            fillingRate: {
+                            fillingRate: !this.functions.empty(data.fillingRate) ? {
                                 color: this.contactService.getFillingColor(data.fillingRate.thresholdLevel)
-                            }
+                            } : ''
                         };
                     }),
                     finalize(() => this.loadingValues = false),
@@ -197,7 +202,9 @@ export class ContactAutocompleteComponent implements OnInit {
                             type: 'user',
                             firstname: data.firstname,
                             lastname: data.lastname,
-                            filling: ''
+                            fillingRate: {
+                                color: ''
+                            }
                         };
                     }),
                     finalize(() => this.loadingValues = false),
@@ -212,7 +219,9 @@ export class ContactAutocompleteComponent implements OnInit {
                         this.valuesToDisplay[data.id] = {
                             type: 'entity',
                             lastname: data.entity_label,
-                            filling: ''
+                            fillingRate: {
+                                color: ''
+                            }
                         };
                     }),
                     finalize(() => this.loadingValues = false),
@@ -234,9 +243,9 @@ export class ContactAutocompleteComponent implements OnInit {
                             id: contact.id,
                             type: contact.type,
                             lastname: contact.contact,
-                            fillingRate: {
+                            fillingRate: !this.functions.empty(data.fillingRate) ? {
                                 color: this.contactService.getFillingColor(contact.thresholdLevel)
-                            }
+                            } : ''
                         }
                     });
                     return contacts;
-- 
GitLab