Blame view

js/app/models/AmdaTimeObject.js 3.12 KB
16035364   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
 * Project      : AMDA-NG
 * Name         : AmdaTimeObject.js
 * Description  : Base Amda Business Object Definition
 * @class amdaModel.AmdaTimeObject
 * @extends amdaModel.AmdaObject
 * 
 * @author elena
 * @version $Id: AmdaTimeObject.js 1534 2013-05-24 13:30:26Z myriam $ 
 * @todo Validations 
 ******************************************************************************
 *    FT Id     :   Date   : Name - Description
 ******************************************************************************
 *	:           :07/07/2011: elena – creation
 */


Ext.define('amdaModel.TTobject', {
    extend: 'amdaModel.AmdaObject',
     
     getJsonValues : function () {
         var values  = new Object();
         values.timeTableName = this.get('name');
         values.id = this.get('id');
         return values;
     }
}); 


Ext.define('amdaModel.AmdaTimeObject', {	
    extend: 'amdaModel.AmdaObject',    
    statics:{
437c4dbc   Benjamin Renard   First implementat...
33
        inputTimeSrc: ['TimeTable','Interval','Catalog']
16035364   Benjamin Renard   First commit
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
    },	
    fields : [
	      { name: 'resultId', type: 'string'}, 
	      { name: 'folderId', type: 'string'}, 
	      { name: 'processId', type: 'string'},
	      { name: 'timesrc', type: 'string'/*, defaultValue: amdaModel.AmdaTimeObject.inputTimeSrc[1] /*'Interval'*/ },
	      { name: 'startDate', type: 'date', defaultValue:Ext.Date.add(Ext.Date.clearTime(new Date()),Ext.Date.DAY,-1),
		convert: function(value,rec) {
		  if (!Ext.isDate(value)) {
		    var valueString = new String(value);
		    var date = new Date(valueString.replace(/\-/g,'\/').replace(/[T|Z]/g,' '));
		      return date;
		  }
		  return value;
		  }
	      },
	      { name: 'stopDate', type: 'date', defaultValue: Ext.Date.clearTime (new Date()), persist: false, 
		convert: function(value,rec) {
		   if (!Ext.isDate(value)){
		    var valueString = new String(value);
		    var date = new Date(valueString.replace(/\-/g,'\/').replace(/[T|Z]/g,' '));
		      return date;
		   }
		   return value;
		   }
		  
	      }, 
	      { 
	          name: 'durationDay', type: 'int',  
	          convert: function(value, rec) {                 		 
                  return Ext.String.leftPad(Math.floor((rec.get('stopDate') - rec.get('startDate'))/86400000),4,'0');      
	          }
	      }, 
	      { 
	          name: 'durationHour', type: 'int',  
	          convert: function(value, rec) {
	              var diffH = (rec.get('stopDate') - rec.get('startDate'))/3600000 % 24;
	              return Ext.String.leftPad(Math.floor(diffH), 2, '0');      
	          }
	      }, 
	      { 
	          name: 'durationMin', type: 'int',  
	          convert: function(value, rec) {
	              var diffM = (rec.get('stopDate') - rec.get('startDate'))/60000 % 60;
	              return Ext.String.leftPad(Math.floor(diffM), 2, '0');      
	          }
	      },
	      { 
	          name: 'durationSec', type: 'int',  
	          convert: function(value, rec) {
	              var diffS = (rec.get('stopDate') - rec.get('startDate'))/1000 % 60;
	              return Ext.String.leftPad(Math.floor(diffS), 2, '0');      
	          }
	      }, 
	      { name: 'timeTables', defaultValue: null }    // array of TTobject
	 ]
	 
});