/** * 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; } });