From 82689b27dae073e53c1fff0017ee7786fd00efe9 Mon Sep 17 00:00:00 2001
From: Alex ORLUC <alex.orluc@maarch.org>
Date: Fri, 4 Jan 2019 17:28:48 +0100
Subject: [PATCH] FEAT #8956 add not define label if empty data

---
 .../app/list/basket-list.component.html       | 11 ++-
 .../app/list/basket-list.component.ts         | 71 ++++++++++++-------
 2 files changed, 49 insertions(+), 33 deletions(-)

diff --git a/src/frontend/app/list/basket-list.component.html b/src/frontend/app/list/basket-list.component.html
index a587aa90a63..44f4a3b7c58 100644
--- a/src/frontend/app/list/basket-list.component.html
+++ b/src/frontend/app/list/basket-list.component.html
@@ -30,8 +30,7 @@
                             <mat-toolbar *ngIf="displayedSecondaryData.length > 0">
                                 <div class="resultCol {{data.class}}" *ngFor="let data of displayedSecondaryData">
                                     <span *ngIf="data.id == 'status_label'">
-                                        <mat-icon *ngIf="row.status_icon === null" title="{{lang.undefinedStatus}}" style="opacity: 0.5;color: #666" class="fas fa-question fa-2x"></mat-icon>
-                                        <mat-icon *ngIf="row.status_icon !== null" [ngStyle]="{'color': row.priority_color}" color="primary" class="{{row.status_icon.charAt(0)}}{{row.status_icon.charAt(1)}} {{row.status_icon}} {{row.status_icon.charAt(0)}}{{row.status_icon.charAt(1)}}-2x"
+                                        <mat-icon [ngStyle]="{'color': row.priority_color}" color="primary" class="{{row.status_icon.charAt(0)}}{{row.status_icon.charAt(1)}} {{row.status_icon}} {{row.status_icon.charAt(0)}}{{row.status_icon.charAt(1)}}-2x"
                                             title="{{row.status_label}} ({{row.status_id}})"></mat-icon><br />
                                     </span>
                                     <ng-container *ngIf="data.id == 'date'">
@@ -44,10 +43,11 @@
                                         &nbsp;
                                     </ng-container>
                                     <ng-container *ngIf="data.id == 'category_id'">
-                                        {{lang[row.category_id]}}
+                                        <span *ngIf="!lang[row.category_id]" style="opacity: 0.5" title="id: {{row.category_id}}">_UNDEFINED</span>
+                                        <span *ngIf="lang[row.category_id]">{{lang[row.category_id]}}</span>
                                     </ng-container>
                                     <ng-container *ngIf="data.id != 'status_label' && data.id != 'date' && data.id != 'category_id'">
-                                        {{row[data.id]}}
+                                        <span [class.undefined]="row[data.id] == lang.undefined">{{row[data.id]}}</span>
                                     </ng-container>
                                 </div>
                             </mat-toolbar>
@@ -58,8 +58,7 @@
                                 </div>
                                 <div class="resultCol {{data.class}}" *ngFor="let data of displayedMainData">
                                     <span *ngIf="data.id == 'alt_identifier'">
-                                        <mat-icon *ngIf="row.status_icon === null" title="{{lang.undefinedStatus}}" style="opacity: 0.5;color: #666" class="fas fa-question fa-2x"></mat-icon>
-                                        <mat-icon *ngIf="row.status_icon !== null" [ngStyle]="{'color': row.priority_color}" color="primary" class="{{row.status_icon.charAt(0)}}{{row.status_icon.charAt(1)}} {{row.status_icon}} {{row.status_icon.charAt(0)}}{{row.status_icon.charAt(1)}}-2x"
+                                        <mat-icon [ngStyle]="{'color': row.priority_color}" color="primary" class="{{row.status_icon.charAt(0)}}{{row.status_icon.charAt(1)}} {{row.status_icon}} {{row.status_icon.charAt(0)}}{{row.status_icon.charAt(1)}}-2x"
                                             title="{{row.status_label}} ({{row.status_id}})" style="cursor: crosshair;" (click)="$event.stopPropagation();filterThis(row.status_label)"></mat-icon><br />
                                         <span style="color: rgba(0,0,0,0.4);font-size: 90%;cursor: crosshair;" (click)="$event.stopPropagation();filterThis(row[data.id])">{{row[data.id]}}</span>
                                     </span>
diff --git a/src/frontend/app/list/basket-list.component.ts b/src/frontend/app/list/basket-list.component.ts
index 3a1a9e38b23..8c22d12c55a 100755
--- a/src/frontend/app/list/basket-list.component.ts
+++ b/src/frontend/app/list/basket-list.component.ts
@@ -42,7 +42,7 @@ export class BasketListComponent implements OnInit {
     homeData: any;
 
     filtersChange = new EventEmitter();
-    
+
     @ViewChild('snav') sidenavLeft: MatSidenav;
     @ViewChild('snav2') sidenavRight: MatSidenav;
 
@@ -64,34 +64,34 @@ export class BasketListComponent implements OnInit {
     //displayedSecondaryData: any = [];
     displayedSecondaryData: any = [
         {
-            'id' : 'priority_label',
-            'class' : '',
-            'icon' : ''
+            'id': 'priority_label',
+            'class': '',
+            'icon': ''
         },
         {
-            'id' : 'category_id',
-            'class' : '',
-            'icon' : ''
+            'id': 'category_id',
+            'class': '',
+            'icon': ''
         },
         {
-            'id' : 'doctype_label',
-            'class' : '',
-            'icon' : 'fa fa-file'
+            'id': 'doctype_label',
+            'class': '',
+            'icon': 'fa fa-file'
         },
         {
-            'id' : 'contact_society',
-            'class' : '',
-            'icon' : ''
+            'id': 'contact_society',
+            'class': '',
+            'icon': ''
         },
         {
-            'id' : 'contact_society',
-            'class' : '',
-            'icon' : ''
+            'id': 'contact_society',
+            'class': '',
+            'icon': ''
         },
         {
-            'id' : 'date',
-            'class' : 'rightData',
-            'icon' : ''
+            'id': 'date',
+            'class': 'rightData',
+            'icon': ''
         },
     ];
 
@@ -152,9 +152,9 @@ export class BasketListComponent implements OnInit {
             this.refreshDao();
 
         },
-        (err : any) => {
-            this.notify.handleErrors(err);
-        });
+            (err: any) => {
+                this.notify.handleErrors(err);
+            });
     }
 
     initResultList() {
@@ -175,8 +175,9 @@ export class BasketListComponent implements OnInit {
                 map(data => {
                     // Flip flag to show that loading has finished.
                     this.isLoadingResults = false;
-                    this.resultsLength = data.count;
+                    data = this.processPostData(data);
                     console.log(data);
+                    this.resultsLength = data.count;
                     this.headerService.setHeader(data.basketLabel, this.resultsLength + ' ' + this.lang.entries);
                     return data.resources;
                 }),
@@ -235,15 +236,31 @@ export class BasketListComponent implements OnInit {
         this.filtersTool.setInputSearch(value);
     }
 
-    viewThumbnail(row:any) {
-        this.thumbnailUrl = this.coreUrl+'rest/res/' + row.res_id + '/thumbnail';
+    viewThumbnail(row: any) {
+        this.thumbnailUrl = this.coreUrl + 'rest/res/' + row.res_id + '/thumbnail';
         $j('#viewThumbnail').show();
-        $j('#listContent').css({"overflow":"hidden"});
+        $j('#listContent').css({ "overflow": "hidden" });
     }
 
     closeThumbnail() {
         $j('#viewThumbnail').hide();
-        $j('#listContent').css({"overflow":"auto"});
+        $j('#listContent').css({ "overflow": "auto" });
+    }
+
+    processPostData(data: any) {
+        data.resources.forEach((element: any) => {
+            Object.keys(element).forEach((key) => {
+                if (key == 'status_icon' && element[key] == null) {
+                    element[key] = 'fa-question undefined';
+                }
+                if ((element[key] == null || element[key] == '') && ['process_limit_date', 'creation_date', 'closing_date', 'countAttachments', 'countNotes'].indexOf(key) === -1) {
+                    element[key] = this.lang.undefined;
+                }
+
+            });
+        });
+
+        return data;
     }
 }
 export interface BasketList {
-- 
GitLab