PlotConstantObject.js
3.15 KB
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
33
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
/**
* Project : AMDA-NG
* Name : PlotConstantObject.js
* @class amdaPlotObj.PlotConstantObject
* @extends Ext.data.Model
* @brief Plot Constant Business Object Definition
* @author Benjamin Renard
* @version $Id: PlotConstantObject.js benjamin $
******************************************************************************
* FT Id : Date : Name - Description
******************************************************************************
* : :01/09/2015: BRE - file creation
*/
Ext.define('amdaPlotObj.PlotConstantObject', {
extend: 'Ext.data.Model',
idProperty: 'id',
requires: [
'amdaPlotObj.PlotObjectConfig'
],
fields : [
{name: 'id', type: 'int'},
{name: 'constant-axis-id', type: 'string'},
{name: 'constant-time-value', 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: 'constant-float-value', type: 'float'},
{name: 'constant-line-style', type: 'string'},
{name: 'constant-line-width', type: 'float'},
{name: 'constant-line-color', type: 'string'}
],
constructor: function(){
var me = this;
me.callParent(arguments);
if ((arguments.length > 0) && arguments[0])
{
}
else
{
//new object, set default fields values
me.setDefaultValues();
}
this.dirty = false;
},
setDefaultValues: function()
{
this.set('constant-axis-id', amdaPlotObj.PlotObjectConfig.defaultValues.constants.axisId);
this.set('constant-float-value', 0.);
this.set('constant-line-style', amdaPlotObj.PlotObjectConfig.defaultValues.constants.line.style);
this.set('constant-line-width', amdaPlotObj.PlotObjectConfig.defaultValues.constants.line.width);
this.set('constant-line-color', amdaPlotObj.PlotObjectConfig.defaultValues.constants.line.color);
},
getShortInfo : function()
{
var axis = amdaPlotObj.PlotObjectConfig.getValueByKey(amdaPlotObj.PlotObjectConfig.availableConstantAxes, this.get('constant-axis-id'));
return 'Id : '+this.get('id')+', '+axis;
},
getJsonValues : function()
{
var constantValues = new Object();
constantValues['id'] = this.get('id');
constantValues['constant-axis-id'] = this.get('constant-axis-id');
constantValues['constant-time-value'] = this.get('constant-time-value');
constantValues['constant-float-value'] = this.get('constant-float-value');
constantValues['constant-line-style'] = this.get('constant-line-style');
constantValues['constant-line-width'] = this.get('constant-line-width');
constantValues['constant-line-color'] = this.get('constant-line-color');
return constantValues;
}
});