From 791d4b0a9c02efa03d24b77563072b1e6595c7cc Mon Sep 17 00:00:00 2001
From: Hacene SI HADJ MOHAND <hacene.si-hadj-mohand@akka.eu>
Date: Thu, 13 Feb 2020 16:02:20 +0100
Subject: [PATCH] ok cat nok tt

---
 js/app/views/CatalogUI.js   | 42 ++++++++++++++++++++++++++++++++++++------
 js/app/views/TimeTableUI.js | 36 +++++++++++++++++++++++++++++++-----
 2 files changed, 67 insertions(+), 11 deletions(-)

diff --git a/js/app/views/CatalogUI.js b/js/app/views/CatalogUI.js
index 9572cdc..e49c8b7 100644
--- a/js/app/views/CatalogUI.js
+++ b/js/app/views/CatalogUI.js
@@ -233,6 +233,16 @@ Ext.define('amdaUI.CatalogUI', {
                         return value;
                     }
                 },
+                 {
+                    name: 'durationDay',
+                    type: 'float',
+                    convert: function (value, rec) {
+                        if (rec.get('stop') && rec.get('start') && (rec.get('stop') - rec.get('start')) >= 0) {
+                            return (rec.get('stop') - rec.get('start')) / 3600000.0/24.0;
+                        }
+                    },
+                    persist: false
+                },
                 {
                     name: 'durationHour',
                     type: 'float',
@@ -329,6 +339,26 @@ Ext.define('amdaUI.CatalogUI', {
                     },
                     filter: {type: 'date', dateFormat: 'Y-m-d'}
                 },
+                            {
+                    xtype: 'gridcolumn',
+                    text: 'Duration (day)',
+                    sortable: true,
+                    dataIndex: 'durationDay',
+                    width: 120,
+                    minWidth: 50,
+                    menuDisabled: false,
+                    hidden: true,
+                    id: amdaUI.CatalogUI.COL_TO_HIDE_DURATION + '1',
+                    renderer: function (value) {
+                        return Ext.util.Format.number(value, '0.00');
+                    },
+                    listeners: {
+                        beforeshow: function () {
+                            updateDurationColumnsVisibility(this.ownerCt.getGridColumns(), amdaUI.CatalogUI.COL_TO_HIDE_DURATION + '1');
+                        }
+                    },
+                    filter: {type: 'numeric'}
+                },
                 {
                     xtype: 'gridcolumn',
                     text: 'Duration (hour)',
@@ -338,13 +368,13 @@ Ext.define('amdaUI.CatalogUI', {
                     minWidth: 50,
                     menuDisabled: false,
                     hidden: true,
-                    id: amdaUI.CatalogUI.COL_TO_HIDE_DURATION + '1',
+                    id: amdaUI.CatalogUI.COL_TO_HIDE_DURATION + '2',
                     renderer: function (value) {
                         return Ext.util.Format.number(value, '0.00');
                     },
                     listeners: {
                         beforeshow: function () {
-                            updateDurationColumnsVisibility(this.ownerCt.getGridColumns(), amdaUI.CatalogUI.COL_TO_HIDE_DURATION + '1');
+                            updateDurationColumnsVisibility(this.ownerCt.getGridColumns(), amdaUI.CatalogUI.COL_TO_HIDE_DURATION + '2');
                         }
                     },
                     filter: {type: 'numeric'}
@@ -358,13 +388,13 @@ Ext.define('amdaUI.CatalogUI', {
                     minWidth: 50,
                     menuDisabled: false,
                     hidden: false,
-                    id: amdaUI.CatalogUI.COL_TO_HIDE_DURATION + '2',
+                    id: amdaUI.CatalogUI.COL_TO_HIDE_DURATION + '3',
                     renderer: function (value) {
                         return Ext.util.Format.number(value, '0.00');
                     },
                     listeners: {
                         beforeshow: function () {
-                            updateDurationColumnsVisibility(this.ownerCt.getGridColumns(), amdaUI.CatalogUI.COL_TO_HIDE_DURATION + '2');
+                            updateDurationColumnsVisibility(this.ownerCt.getGridColumns(), amdaUI.CatalogUI.COL_TO_HIDE_DURATION + '3');
                         }
                     },
                     filter: {type: 'numeric'}
@@ -378,13 +408,13 @@ Ext.define('amdaUI.CatalogUI', {
                     minWidth: 50,
                     menuDisabled: false,
                     hidden: true,
-                    id: amdaUI.CatalogUI.COL_TO_HIDE_DURATION + '3',
+                    id: amdaUI.CatalogUI.COL_TO_HIDE_DURATION + '4',
                     renderer: function (value) {
                         return Ext.util.Format.number(value, '0.00');
                     },
                     listeners: {
                         beforeshow: function () {
-                            updateDurationColumnsVisibility(this.ownerCt.getGridColumns(), amdaUI.CatalogUI.COL_TO_HIDE_DURATION + '3');
+                            updateDurationColumnsVisibility(this.ownerCt.getGridColumns(), amdaUI.CatalogUI.COL_TO_HIDE_DURATION + '4');
                         }
                     },
                     filter: {type: 'numeric'}
diff --git a/js/app/views/TimeTableUI.js b/js/app/views/TimeTableUI.js
index fcc3497..eab58a1 100755
--- a/js/app/views/TimeTableUI.js
+++ b/js/app/views/TimeTableUI.js
@@ -506,6 +506,7 @@ Ext.define('amdaUI.TimeTableUI', {
             encode: true, // json encode the filter query
             local: false, // defaults to false (remote filte
             filters: [
+                {type: 'numeric', dataIndex: 'durationDay'},
                 {type: 'numeric', dataIndex: 'durationHour'},
                 {type: 'numeric', dataIndex: 'durationMin'},
                 {type: 'numeric', dataIndex: 'durationSec'},
@@ -623,11 +624,12 @@ Ext.define('amdaUI.TimeTableUI', {
                         }
                     }
                 },
-                {
-                    header: 'Duration (hour)', width: 120, dataIndex: 'durationHour',
+                    {
+                    header: 'Duration (day)', width: 120, dataIndex: 'durationDay',
                     id: amdaUI.TimeTableUI.COL_TO_HIDE + '1',
                     hidden: true,
                     renderer: function (value) {
+                       
                         return Ext.util.Format.number(value, '0.00');
                     },
                     listeners: {
@@ -646,8 +648,9 @@ Ext.define('amdaUI.TimeTableUI', {
                     }
                 },
                 {
-                    header: 'Duration (min)', width: 120, dataIndex: 'durationMin',
+                    header: 'Duration (hour)', width: 120, dataIndex: 'durationHour',
                     id: amdaUI.TimeTableUI.COL_TO_HIDE + '2',
+                    hidden: true,
                     renderer: function (value) {
                         return Ext.util.Format.number(value, '0.00');
                     },
@@ -667,9 +670,8 @@ Ext.define('amdaUI.TimeTableUI', {
                     }
                 },
                 {
-                    header: 'Duration (sec)', width: 120, dataIndex: 'durationSec',
+                    header: 'Duration (min)', width: 120, dataIndex: 'durationMin',
                     id: amdaUI.TimeTableUI.COL_TO_HIDE + '3',
-                    hidden: true,
                     renderer: function (value) {
                         return Ext.util.Format.number(value, '0.00');
                     },
@@ -687,6 +689,28 @@ Ext.define('amdaUI.TimeTableUI', {
                             });
                         }
                     }
+                },
+                {
+                    header: 'Duration (sec)', width: 120, dataIndex: 'durationSec',
+                    id: amdaUI.TimeTableUI.COL_TO_HIDE + '4',
+                    hidden: true,
+                    renderer: function (value) {
+                        return Ext.util.Format.number(value, '0.00');
+                    },
+                    listeners: {
+                        beforeshow: function () {
+                            Ext.Array.each(this.ownerCt.getGridColumns(), function (item, index, all) {
+                                // if item is a column to hide automatically
+                                if (Ext.util.Format.substr(item.id, 0, amdaUI.TimeTableUI.COL_TO_HIDE.length) == amdaUI.TimeTableUI.COL_TO_HIDE) {
+                                    // if item isn't the column which is being declared and is not hidden
+                                    if (item.id != amdaUI.TimeTableUI.COL_TO_HIDE + '4' && !item.isHidden()) {
+                                        // hide this column
+                                        item.hide();
+                                    }
+                                }
+                            });
+                        }
+                    }
                 }
             ],
             frame: true,
@@ -757,10 +781,12 @@ Ext.define('amdaUI.TimeTableUI', {
                         e.record.set('durationHour', (e.record.get('stop') - e.record.get('start')) / 3600000.0);
                         e.record.set('durationMin', (e.record.get('stop') - e.record.get('start')) / 60000.0);
                         e.record.set('durationSec', (e.record.get('stop') - e.record.get('start')) / 1000.0);
+                        e.record.set('durationDay', (e.record.get('stop') - e.record.get('start')) / 3600000.0 / 24.0);
                         //  send refresh event to statistical plugin
                         this.fireEvent("refresh");
                     }
                 }
+                
             }
         });
 
--
libgit2 0.21.2