Commit 791d4b0a9c02efa03d24b77563072b1e6595c7cc
1 parent
41fdfe87
Exists in
master
and in
97 other branches
ok cat nok tt
Showing
2 changed files
with
67 additions
and
11 deletions
Show diff stats
js/app/views/CatalogUI.js
... | ... | @@ -233,6 +233,16 @@ Ext.define('amdaUI.CatalogUI', { |
233 | 233 | return value; |
234 | 234 | } |
235 | 235 | }, |
236 | + { | |
237 | + name: 'durationDay', | |
238 | + type: 'float', | |
239 | + convert: function (value, rec) { | |
240 | + if (rec.get('stop') && rec.get('start') && (rec.get('stop') - rec.get('start')) >= 0) { | |
241 | + return (rec.get('stop') - rec.get('start')) / 3600000.0/24.0; | |
242 | + } | |
243 | + }, | |
244 | + persist: false | |
245 | + }, | |
236 | 246 | { |
237 | 247 | name: 'durationHour', |
238 | 248 | type: 'float', |
... | ... | @@ -329,6 +339,26 @@ Ext.define('amdaUI.CatalogUI', { |
329 | 339 | }, |
330 | 340 | filter: {type: 'date', dateFormat: 'Y-m-d'} |
331 | 341 | }, |
342 | + { | |
343 | + xtype: 'gridcolumn', | |
344 | + text: 'Duration (day)', | |
345 | + sortable: true, | |
346 | + dataIndex: 'durationDay', | |
347 | + width: 120, | |
348 | + minWidth: 50, | |
349 | + menuDisabled: false, | |
350 | + hidden: true, | |
351 | + id: amdaUI.CatalogUI.COL_TO_HIDE_DURATION + '1', | |
352 | + renderer: function (value) { | |
353 | + return Ext.util.Format.number(value, '0.00'); | |
354 | + }, | |
355 | + listeners: { | |
356 | + beforeshow: function () { | |
357 | + updateDurationColumnsVisibility(this.ownerCt.getGridColumns(), amdaUI.CatalogUI.COL_TO_HIDE_DURATION + '1'); | |
358 | + } | |
359 | + }, | |
360 | + filter: {type: 'numeric'} | |
361 | + }, | |
332 | 362 | { |
333 | 363 | xtype: 'gridcolumn', |
334 | 364 | text: 'Duration (hour)', |
... | ... | @@ -338,13 +368,13 @@ Ext.define('amdaUI.CatalogUI', { |
338 | 368 | minWidth: 50, |
339 | 369 | menuDisabled: false, |
340 | 370 | hidden: true, |
341 | - id: amdaUI.CatalogUI.COL_TO_HIDE_DURATION + '1', | |
371 | + id: amdaUI.CatalogUI.COL_TO_HIDE_DURATION + '2', | |
342 | 372 | renderer: function (value) { |
343 | 373 | return Ext.util.Format.number(value, '0.00'); |
344 | 374 | }, |
345 | 375 | listeners: { |
346 | 376 | beforeshow: function () { |
347 | - updateDurationColumnsVisibility(this.ownerCt.getGridColumns(), amdaUI.CatalogUI.COL_TO_HIDE_DURATION + '1'); | |
377 | + updateDurationColumnsVisibility(this.ownerCt.getGridColumns(), amdaUI.CatalogUI.COL_TO_HIDE_DURATION + '2'); | |
348 | 378 | } |
349 | 379 | }, |
350 | 380 | filter: {type: 'numeric'} |
... | ... | @@ -358,13 +388,13 @@ Ext.define('amdaUI.CatalogUI', { |
358 | 388 | minWidth: 50, |
359 | 389 | menuDisabled: false, |
360 | 390 | hidden: false, |
361 | - id: amdaUI.CatalogUI.COL_TO_HIDE_DURATION + '2', | |
391 | + id: amdaUI.CatalogUI.COL_TO_HIDE_DURATION + '3', | |
362 | 392 | renderer: function (value) { |
363 | 393 | return Ext.util.Format.number(value, '0.00'); |
364 | 394 | }, |
365 | 395 | listeners: { |
366 | 396 | beforeshow: function () { |
367 | - updateDurationColumnsVisibility(this.ownerCt.getGridColumns(), amdaUI.CatalogUI.COL_TO_HIDE_DURATION + '2'); | |
397 | + updateDurationColumnsVisibility(this.ownerCt.getGridColumns(), amdaUI.CatalogUI.COL_TO_HIDE_DURATION + '3'); | |
368 | 398 | } |
369 | 399 | }, |
370 | 400 | filter: {type: 'numeric'} |
... | ... | @@ -378,13 +408,13 @@ Ext.define('amdaUI.CatalogUI', { |
378 | 408 | minWidth: 50, |
379 | 409 | menuDisabled: false, |
380 | 410 | hidden: true, |
381 | - id: amdaUI.CatalogUI.COL_TO_HIDE_DURATION + '3', | |
411 | + id: amdaUI.CatalogUI.COL_TO_HIDE_DURATION + '4', | |
382 | 412 | renderer: function (value) { |
383 | 413 | return Ext.util.Format.number(value, '0.00'); |
384 | 414 | }, |
385 | 415 | listeners: { |
386 | 416 | beforeshow: function () { |
387 | - updateDurationColumnsVisibility(this.ownerCt.getGridColumns(), amdaUI.CatalogUI.COL_TO_HIDE_DURATION + '3'); | |
417 | + updateDurationColumnsVisibility(this.ownerCt.getGridColumns(), amdaUI.CatalogUI.COL_TO_HIDE_DURATION + '4'); | |
388 | 418 | } |
389 | 419 | }, |
390 | 420 | filter: {type: 'numeric'} |
... | ... |
js/app/views/TimeTableUI.js
... | ... | @@ -506,6 +506,7 @@ Ext.define('amdaUI.TimeTableUI', { |
506 | 506 | encode: true, // json encode the filter query |
507 | 507 | local: false, // defaults to false (remote filte |
508 | 508 | filters: [ |
509 | + {type: 'numeric', dataIndex: 'durationDay'}, | |
509 | 510 | {type: 'numeric', dataIndex: 'durationHour'}, |
510 | 511 | {type: 'numeric', dataIndex: 'durationMin'}, |
511 | 512 | {type: 'numeric', dataIndex: 'durationSec'}, |
... | ... | @@ -623,11 +624,12 @@ Ext.define('amdaUI.TimeTableUI', { |
623 | 624 | } |
624 | 625 | } |
625 | 626 | }, |
626 | - { | |
627 | - header: 'Duration (hour)', width: 120, dataIndex: 'durationHour', | |
627 | + { | |
628 | + header: 'Duration (day)', width: 120, dataIndex: 'durationDay', | |
628 | 629 | id: amdaUI.TimeTableUI.COL_TO_HIDE + '1', |
629 | 630 | hidden: true, |
630 | 631 | renderer: function (value) { |
632 | + | |
631 | 633 | return Ext.util.Format.number(value, '0.00'); |
632 | 634 | }, |
633 | 635 | listeners: { |
... | ... | @@ -646,8 +648,9 @@ Ext.define('amdaUI.TimeTableUI', { |
646 | 648 | } |
647 | 649 | }, |
648 | 650 | { |
649 | - header: 'Duration (min)', width: 120, dataIndex: 'durationMin', | |
651 | + header: 'Duration (hour)', width: 120, dataIndex: 'durationHour', | |
650 | 652 | id: amdaUI.TimeTableUI.COL_TO_HIDE + '2', |
653 | + hidden: true, | |
651 | 654 | renderer: function (value) { |
652 | 655 | return Ext.util.Format.number(value, '0.00'); |
653 | 656 | }, |
... | ... | @@ -667,9 +670,8 @@ Ext.define('amdaUI.TimeTableUI', { |
667 | 670 | } |
668 | 671 | }, |
669 | 672 | { |
670 | - header: 'Duration (sec)', width: 120, dataIndex: 'durationSec', | |
673 | + header: 'Duration (min)', width: 120, dataIndex: 'durationMin', | |
671 | 674 | id: amdaUI.TimeTableUI.COL_TO_HIDE + '3', |
672 | - hidden: true, | |
673 | 675 | renderer: function (value) { |
674 | 676 | return Ext.util.Format.number(value, '0.00'); |
675 | 677 | }, |
... | ... | @@ -687,6 +689,28 @@ Ext.define('amdaUI.TimeTableUI', { |
687 | 689 | }); |
688 | 690 | } |
689 | 691 | } |
692 | + }, | |
693 | + { | |
694 | + header: 'Duration (sec)', width: 120, dataIndex: 'durationSec', | |
695 | + id: amdaUI.TimeTableUI.COL_TO_HIDE + '4', | |
696 | + hidden: true, | |
697 | + renderer: function (value) { | |
698 | + return Ext.util.Format.number(value, '0.00'); | |
699 | + }, | |
700 | + listeners: { | |
701 | + beforeshow: function () { | |
702 | + Ext.Array.each(this.ownerCt.getGridColumns(), function (item, index, all) { | |
703 | + // if item is a column to hide automatically | |
704 | + if (Ext.util.Format.substr(item.id, 0, amdaUI.TimeTableUI.COL_TO_HIDE.length) == amdaUI.TimeTableUI.COL_TO_HIDE) { | |
705 | + // if item isn't the column which is being declared and is not hidden | |
706 | + if (item.id != amdaUI.TimeTableUI.COL_TO_HIDE + '4' && !item.isHidden()) { | |
707 | + // hide this column | |
708 | + item.hide(); | |
709 | + } | |
710 | + } | |
711 | + }); | |
712 | + } | |
713 | + } | |
690 | 714 | } |
691 | 715 | ], |
692 | 716 | frame: true, |
... | ... | @@ -757,10 +781,12 @@ Ext.define('amdaUI.TimeTableUI', { |
757 | 781 | e.record.set('durationHour', (e.record.get('stop') - e.record.get('start')) / 3600000.0); |
758 | 782 | e.record.set('durationMin', (e.record.get('stop') - e.record.get('start')) / 60000.0); |
759 | 783 | e.record.set('durationSec', (e.record.get('stop') - e.record.get('start')) / 1000.0); |
784 | + e.record.set('durationDay', (e.record.get('stop') - e.record.get('start')) / 3600000.0 / 24.0); | |
760 | 785 | // send refresh event to statistical plugin |
761 | 786 | this.fireEvent("refresh"); |
762 | 787 | } |
763 | 788 | } |
789 | + | |
764 | 790 | } |
765 | 791 | }); |
766 | 792 | |
... | ... |