diff --git a/js/app/controllers/ExplorerModule.js b/js/app/controllers/ExplorerModule.js index e416609..7135e87 100644 --- a/js/app/controllers/ExplorerModule.js +++ b/js/app/controllers/ExplorerModule.js @@ -302,11 +302,41 @@ Ext.define('amdaDesktop.ExplorerModule', { },this); }, - getParamInfoInRegistry : function(paramId) { - return this.paramInfoRegistry[paramId]; - }, - - addParamInfoInRegistry : function(paramId, paramInfo) { - this.paramInfoRegistry[paramId] = paramInfo; + getParamInfo : function(paramId, onReady) { + if (this.paramInfoRegistry[paramId]) { + if (onReady) + onReady(this.paramInfoRegistry[paramId]); + return this.paramInfoRegistry[paramId]; + } + + var me = this; + AmdaAction.getParamInfo({"paramId" : paramId}, function (result, e) { + var paramInfo = null; + if (e.status === true) + { + if (!result.success) + { + //No available info for this parameter. Do not display an error message + /*if (result.message && result.message != '') + Ext.Msg.show({title:'Get parameter arguments error ', msg: result.message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK}); + else + Ext.Msg.show({title:'Get parameter arguments error', msg: 'Unknown error', icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK});*/ + } + else + { + //Store parameter info in registry + me.paramInfoRegistry[paramId] = result; + paramInfo = result; + } + } + else + { + Ext.Msg.show({title:'Error System', msg: e.message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK}); + } + + if (onReady) + onReady(paramInfo); + }); + return null; } }); diff --git a/js/app/models/Download.js b/js/app/models/Download.js index 7d06e43..cd56f06 100644 --- a/js/app/models/Download.js +++ b/js/app/models/Download.js @@ -80,9 +80,9 @@ Ext.define('amdaModel.Download', { var list = this.get('list'); myValues.list=[]; - Ext.each(list, function(item, index){ - myValues.list[index] = {'name' : item.get('name'), 'type' : item.get('type'), 'dim1' : item.get('dim1'), 'dim2' : item.get('dim2')}; - }); + Ext.each(list, function(item, index){ + myValues.list[index] = item.getJsonValues(); + }); } myValues.fileformat = this.get('fileformat'); myValues.timeformat = this.get('timeformat'); diff --git a/js/app/models/DownloadNode.js b/js/app/models/DownloadNode.js index e0493a9..5a570db 100644 --- a/js/app/models/DownloadNode.js +++ b/js/app/models/DownloadNode.js @@ -82,7 +82,7 @@ Ext.define('amdaModel.DownloadNode', { fullObject.tabs().each(function (tab) { tab.panels().each(function (panel) { panel.params().each(function (param) { - myValues.list[i] = param.get('param-id'); + myValues.list[i] = param.get('paramid'); ++i; }); }); diff --git a/js/app/models/DownloadParam.js b/js/app/models/DownloadParam.js index ede687b..7c56c7a 100644 --- a/js/app/models/DownloadParam.js +++ b/js/app/models/DownloadParam.js @@ -3,7 +3,7 @@ * Name : DownloadParam.js * Description : Download Param Business Object Definition * @class amdaModel.DownloadParam - * @extends amdaModel.AmdaObject + * @extends amdaModel.RequestParamObject * * @author benjamin * @version $Id: Download.js 2068 2016-04-21 11:27:38Z benjamin $ @@ -15,12 +15,5 @@ Ext.define('amdaModel.DownloadParam', { - extend: 'amdaModel.AmdaObject', - - fields : [ - {name: 'type', type: 'int'}, - {name: 'dim1', type: 'string'}, - {name: 'dim2', type: 'string'} - ] - + extend: 'amdaModel.RequestParamObject' }); diff --git a/js/app/models/PlotObjects/PlotPanelObject.js b/js/app/models/PlotObjects/PlotPanelObject.js index a5798fc..e93555d 100644 --- a/js/app/models/PlotObjects/PlotPanelObject.js +++ b/js/app/models/PlotObjects/PlotPanelObject.js @@ -276,7 +276,7 @@ Ext.define('amdaPlotObj.PlotPanelObject', { var emptyPanel = (this.params().getCount() == 0); var recs = this.params().add({id : this.get('last-param-id')}); - recs[0].set('param-id', paramId); + recs[0].set('paramid', paramId); var me = this; amdaPlotObj.PlotObjectConfig.getParamConfig(paramId, function (success, data) { diff --git a/js/app/models/PlotObjects/PlotParamObject.js b/js/app/models/PlotObjects/PlotParamObject.js index 2a6b179..c5a5045 100644 --- a/js/app/models/PlotObjects/PlotParamObject.js +++ b/js/app/models/PlotObjects/PlotParamObject.js @@ -2,7 +2,7 @@ * Project  : AMDA-NG * Name : PlotParamObject.js * @class amdaPlotObj.PlotParamObject - * @extends Ext.data.Model + * @extends amdaModel.RequestParamObject * @brief Plot Param Business Object Definition * @author Benjamin Renard * @version $Id: PlotParamObject.js benjamin $ @@ -14,8 +14,7 @@ Ext.define('amdaPlotObj.PlotParamObject', { - extend: 'Ext.data.Model', - idProperty: 'id', + extend: 'amdaModel.RequestParamObject', requires: [ 'amdaPlotObj.PlotObjectConfig', @@ -29,14 +28,8 @@ Ext.define('amdaPlotObj.PlotParamObject', { ], fields : [ - {name: 'id', type: 'int'}, - {name: 'param-id', type: 'string'}, - {name: 'param-type', type: 'int'}, - {name: 'param-dim-1', type: 'string'}, - {name: 'param-dim-2', type: 'string'}, {name: 'param-drawing-type', type: 'string'}, - {name: 'param-drawing-object', type: 'auto'}, - {name: 'param-template-args', type: 'auto'} + {name: 'param-drawing-object', type: 'auto'} ], associations : [ @@ -152,35 +145,9 @@ Ext.define('amdaPlotObj.PlotParamObject', { var availableDrawingObjects = this.getAvailableDrawingObjectByPlotType(plotType); var type = amdaPlotObj.PlotObjectConfig.getValueByKey(availableDrawingObjects, this.get('param-drawing-type')); - var info = ''; - - var paramIndexes = ''; - switch (this.get('param-type')) { - case 0: - //scalar - nothing to do - break; - case 1: - //Tab1D - if ((this.get('param-dim-1') != '') && (this.get('param-dim-1') != '*')) - paramIndexes = '('+this.get('param-dim-1')+')'; - else if ((this.get('param-dim-2') != '') && (this.get('param-dim-2') != '*')) - paramIndexes = '('+this.get('param-dim-2')+')'; - break; - case 2: - //Tab2D - var dim1 = this.get('param-dim-1') != '' ? this.get('param-dim-1') : "*"; - var dim2 = this.get('param-dim-2') != '' ? this.get('param-dim-2') : "*"; - if ((dim1 != '*') || (dim2 != '*')) - paramIndexes = '('+dim1+','+dim2+')'; - } + var fullName = this.getParamFullName(); - var template_args = ""; - if (this.get('param-template-args')) { - Ext.Object.each(this.get('param-template-args'), function (argKey, argValue) { - template_args += "_"; - template_args += argValue; - }); - } + var info = ''; switch (plotType) { @@ -188,16 +155,16 @@ Ext.define('amdaPlotObj.PlotParamObject', { if (this.get('param-drawing-type') == 'orbit-serie') { var projection = amdaPlotObj.PlotObjectConfig.getValueByKey(amdaPlotObj.PlotObjectConfig.availableOrbitSerieProjections, this.get('param-drawing-object').get('serie-projection')); - info = this.get('param-id')+template_args+paramIndexes+', '+projection; + info = fullName+', '+projection; } else - info = this.get('param-id')+template_args+paramIndexes+' = f('+this.get('param-drawing-object').get('serie-xaxis-param')+', t)'; + info = fullName+' = f('+this.get('param-drawing-object').get('serie-xaxis-param')+', t)'; break; case 'instantPlot' : - info = this.get('param-id')+template_args+paramIndexes; + info = fullName; break; default : - info = this.get('param-id')+template_args+paramIndexes+' = f(t)'; + info = fullName+' = f(t)'; } info += ', '+type; @@ -229,26 +196,12 @@ Ext.define('amdaPlotObj.PlotParamObject', { getJsonValues : function() { - var paramValues = new Object(); + var paramValues = this.callParent(arguments); - paramValues['id'] = this.get('id'); - - paramValues['param-id'] = this.get('param-id'); - paramValues['param-type'] = this.get('param-type'); - paramValues['param-dim-1'] = this.get('param-dim-1'); - paramValues['param-dim-2'] = this.get('param-dim-2'); paramValues['param-drawing-type'] = this.get('param-drawing-type'); - if (this.get('param-drawing-object') != null) paramValues['param-drawing-object'] = this.get('param-drawing-object').getJsonValues(); - if (this.get('param-template-args') != null) { - paramValues['param-template-args'] = new Object(); - Ext.Object.each(this.get('param-template-args'), function (argKey, argValue) { - paramValues['param-template-args'][argKey] = argValue; - }); - } - return paramValues; } }); \ No newline at end of file diff --git a/js/app/models/RequestParamObject.js b/js/app/models/RequestParamObject.js new file mode 100644 index 0000000..5533a0d --- /dev/null +++ b/js/app/models/RequestParamObject.js @@ -0,0 +1,83 @@ +/** + * Project  : AMDA-NG + * Name : RequestParamObject.js + * Description : Request Param Business Object Definition + * @class amdaModel.RequestParamObject + * @extends amdaModel.AmdaObject + * + * @author benjamin + * @version $Id: $ + ****************************************************************************** + * FT Id : Date : Name - Description + ****************************************************************************** + * : :13/06/2016: benjamin – creation + */ + + +Ext.define('amdaModel.RequestParamObject', { + extend: 'amdaModel.AmdaObject', + + idProperty: 'id', + + fields : [ + {name: 'type', type: 'int'}, + {name: 'paramid', type: 'string'}, + {name: 'dim1', type: 'string'}, + {name: 'dim2', type: 'string'}, + {name: 'template_args', type: 'auto', defaultValue: null} + ], + + getParamFullName : function() { + var paramIndexes = ''; + switch (this.get('type')) { + case 0: + //scalar - nothing to do + break; + case 1: + //Tab1D + if ((this.get('dim1') != '') && (this.get('dim1') != '*')) + paramIndexes = '('+this.get('dim1')+')'; + else if ((this.get('dim2') != '') && (this.get('dim2') != '*')) + paramIndexes = '('+this.get('dim2')+')'; + break; + case 2: + //Tab2D + var dim1 = this.get('dim1') != '' ? this.get('dim1') : "*"; + var dim2 = this.get('dim2') != '' ? this.get('dim2') : "*"; + if ((dim1 != '*') || (dim2 != '*')) + paramIndexes = '('+dim1+','+dim2+')'; + } + + var template_args = ""; + if (this.get('template_args')) { + Ext.Object.each(this.get('template_args'), function (argKey, argValue) { + template_args += "_"; + template_args += argValue; + }); + } + + return this.get('paramid')+template_args+paramIndexes; + }, + + getJsonValues : function() + { + var paramValues = new Object(); + + paramValues['id'] = this.get('id'); + paramValues['paramid'] = this.get('paramid'); + paramValues['name'] = this.get('name'); + paramValues['dim1'] = this.get('dim1'); + paramValues['dim2'] = this.get('dim2'); + paramValues['type'] = this.get('type'); + + if (this.get('template_args') != null) { + paramValues['template_args'] = new Object(); + Ext.Object.each(this.get('template_args'), function (argKey, argValue) { + paramValues['template_args'][argKey] = argValue; + }); + } + + return paramValues; + } + +}); \ No newline at end of file diff --git a/js/app/views/DownloadUI.js b/js/app/views/DownloadUI.js index e167be8..6c5773f 100644 --- a/js/app/views/DownloadUI.js +++ b/js/app/views/DownloadUI.js @@ -40,7 +40,7 @@ Ext.define('amdaUI.DownloadUI', { }, addTT : function(newTTName,newTTid) - { + { var tabPanel = this.formPanel.down(); var downloadSrc = tabPanel.items.indexOf(tabPanel.getActiveTab()); @@ -84,18 +84,15 @@ Ext.define('amdaUI.DownloadUI', { this.timeSelector.intervalSel.updateDuration(); }, - addParam : function(newParamName,isLeaf) + addParam : function(paramId,isArgsToDefined) { - // search for an existing record in store with this unique name - var existingIndex = this.paramGrid.store.findExact('name', newParamName); - // if no corresponding parameter found - if (existingIndex == -1){ - // adding the parameter to the paramGrid - var r = Ext.create('amdaModel.DownloadParam', {name: newParamName, type: 0, dim1: '', dim2: '' }); - var pos = newParamName.indexOf('ws_',0) == -1 ? 0 :this.paramGrid.store.getCount(); - this.paramGrid.store.insert(pos,r); - this.paramGrid.getView().refresh(); - } + // adding the parameter to the paramGrid + var r = Ext.create('amdaModel.DownloadParam', {paramid: paramId, type: 0, dim1: '', dim2: '', template_args: {} }); + var pos = paramId.indexOf('ws_',0) == -1 ? 0 :this.paramGrid.store.getCount(); + this.paramGrid.store.insert(pos,r); + this.paramGrid.getView().refresh(); + if (isArgsToDefined) + this.editParameterArgs(r); }, addParams: function(arrayParams) @@ -108,12 +105,12 @@ Ext.define('amdaUI.DownloadUI', { Ext.Array.each(arrayParams,function(item){ if (Ext.isObject(item)) { // for Parameter Name in Download Module - var r = Ext.create('amdaModel.DownloadParam', { name: item.get('name'), type: item.get('type'), dim1: item.get('dim1'), dim2: item.get('dim2')}); + var r = Ext.create('amdaModel.DownloadParam', { paramid: item.get('paramid'), type: item.get('type'), dim1: item.get('dim1'), dim2: item.get('dim2')}); } else { // for Download By Request in Operations menu //ToDo BRE - Components selection - var r = Ext.create('amdaModel.DownloadParam', { name: item }); + var r = Ext.create('amdaModel.DownloadParam', { paramid: item }); } arrayRec.push(r); }); @@ -262,23 +259,20 @@ Ext.define('amdaUI.DownloadUI', { actionItem: function(grid, cell, cellIndex, record, row, recordIndex, e){ + this.paramGrid.getView().select(row); if (cellIndex == 3) grid.getStore().remove(record); else if (cellIndex == 2) - this.editParameterArgs(record.get('name')); + this.editParameterArgs(record); }, - editParameterArgs: function(name) { + editParameterArgs: function(record) { var paramArgsPlug = this.getPlugin('download-param-arguments-plugin'); if (paramArgsPlug) - paramArgsPlug.show(name); + paramArgsPlug.show('download-param-arguments-plugin', record); }, - onApplyParameterArgs : function(parentUI, paramId, values) { - var selection = parentUI.paramGrid.getView().getSelectionModel().getSelection()[0]; - selection.set('type', values.type ? values.type : 0); - selection.set('dim1', values.dim_1 ? values.dim_1 : ''); - selection.set('dim2', values.dim_2 ? values.dim_2 : ''); + onApplyParameterArgs : function(parentUI, paramObject) { parentUI.paramGrid.getView().refresh(); }, @@ -330,26 +324,7 @@ Ext.define('amdaUI.DownloadUI', { sortable: false, menuDisabled : true , renderer: function (val, meta, rec) { - var fullVal = val; - switch (rec.get('type')) { - case 0: - //scalar - nothing to do - break; - case 1: - //Tab1D - if ((rec.get('dim1') != '') && (rec.get('dim1') != '*')) - fullVal += '('+rec.get('dim1')+')'; - else if ((rec.get('dim2') != '') && (rec.get('dim2') != '*')) - fullVal += '('+rec.get('dim2')+')'; - break; - case 2: - //Tab2D - var dim1 = rec.get('dim1') != '' ? rec.get('dim1') : "*"; - var dim2 = rec.get('dim2') != '' ? rec.get('dim2') : "*"; - if ((dim1 != '*') || (dim2 != '*')) - fullVal += '('+dim1+','+dim2+')'; - } - return fullVal; + return rec.getParamFullName(); } }, { @@ -400,31 +375,31 @@ Ext.define('amdaUI.DownloadUI', { { if (!this.valid) return false; - var nameToSent; + var idToSent; switch (data.records[0].data.nodeType) { case 'localParam' : case 'remoteParam': case 'remoteSimuParam': - nameToSent = data.records[0].get('id'); + idToSent = data.records[0].get('id'); if (data.records[0].get('alias')!= "" ) - var nameToSent = "#"+data.records[0].get('alias'); + var idToSent = "#"+data.records[0].get('alias'); break; case 'alias' : - nameToSent = "#"+data.records[0].get('text'); + idToSent = "#"+data.records[0].get('text'); break; case 'derivedParam' : - nameToSent = "ws_"+data.records[0].get('text'); + idToSent = "ws_"+data.records[0].get('text'); break; case 'myDataParam' : - nameToSent = "wsd_"+data.records[0].get('text'); + idToSent = "wsd_"+data.records[0].get('text'); break; default : return false; } var downModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.download.id); if (downModule) - downModule.addParam(nameToSent,true); + downModule.addParam(idToSent,!data.records[0].get('leaf') || data.records[0].get('needsArgs')); return true; } }); diff --git a/js/app/views/ParamArgumentsPlug.js b/js/app/views/ParamArgumentsPlug.js index 1ae1585..299195a 100644 --- a/js/app/views/ParamArgumentsPlug.js +++ b/js/app/views/ParamArgumentsPlug.js @@ -20,8 +20,8 @@ Ext.define('amdaUI.ParamArgumentsPlug', { win : null, form : null, + paramObject: null, paramArgs: null, - paramId: '', onApply: null, @@ -45,11 +45,11 @@ Ext.define('amdaUI.ParamArgumentsPlug', { /** * creation of the window */ - show : function(paramId, crtArgsValues) { + show : function(prefixId, paramRequestObject) { if (!this.win) { - this.win = new Ext.Window({ - id: 'param-comp-win', + this.win = new Ext.Window({ + id: prefixId + '-param-arg-win', width: 200, height: 150, x: 0, y: 0, @@ -61,7 +61,8 @@ Ext.define('amdaUI.ParamArgumentsPlug', { resizable: false, ghost: false, renderTo: this.hostCmp.ownerCt.body, - items: this.getFormConfig(), + items: this.getFormConfig(), + closeAction: 'hide', listeners: { scope: this, beforeclose: function() { @@ -77,16 +78,21 @@ Ext.define('amdaUI.ParamArgumentsPlug', { } } }); - + this.win.on('destroy', this.onDestroy, this); Ext.PluginManager.register(this); } - this.win.setTitle('Arguments for ' + paramId); + this.win.setTitle('Arguments for ' + paramRequestObject.get('paramid')); - this.paramId = paramId; - this.paramArgs.editParameter(paramId, crtArgsValues, this.hostCmp); + //Work with a clone of the request para object. + this.paramObject = paramRequestObject; + var workingParamObject = this.paramObject.copy(); + var me = this; + this.paramArgs.editParameter(workingParamObject, this.hostCmp, function() { + me.win.setHeight(me.paramArgs.items.getCount() * 30 + 75); + }); this.hostCmp.setDisabled(true); this.win.show(); @@ -119,17 +125,18 @@ Ext.define('amdaUI.ParamArgumentsPlug', { labelWidth: 60 }, items: [ - this.paramArgs + me.paramArgs ], buttons: [ { text: 'Apply', scope : this, handler: function(bt,event) { - if (me.paramArgs) { - if (me.onApply) - me.onApply(this.hostCmp, me.paramId, me.paramArgs.getValues()); - } + //Set modification + if (me.paramObject) + me.paramObject = me.paramArgs.paramRequestObject; + if (me.onApply) + me.onApply(me.hostCmp, me.paramArgs.paramRequestObject); me.close(); } }, diff --git a/js/app/views/ParamArgumentsUI.js b/js/app/views/ParamArgumentsUI.js index 87b5c55..ae465d2 100644 --- a/js/app/views/ParamArgumentsUI.js +++ b/js/app/views/ParamArgumentsUI.js @@ -15,6 +15,7 @@ Ext.define('amdaUI.ParamArgumentsUI', { regexp_istemplate: /^template_(.*)/, + paramRequestObject: null, onChange: null, // -1 -> unknown, 0 -> scalar, 1 -> Tab1D, 2 -> Tab2D @@ -36,7 +37,8 @@ Ext.define('amdaUI.ParamArgumentsUI', { Ext.apply (this , Ext.apply (arguments, myConf)); }, - editParameter: function(paramId, crtArgsValues, uiScope, onReady) { + editParameter: function(paramRequestObject, uiScope, onReady) { + this.paramRequestObject = paramRequestObject; var me = this; me.mask(); me.resetArguments(); @@ -44,94 +46,68 @@ Ext.define('amdaUI.ParamArgumentsUI', { var explorerModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id); if (explorerModule) { - paramInfo = explorerModule.getParamInfoInRegistry(paramId); - if (paramInfo) { - //Re-use already loaded param info - me.rebuildAll(paramInfo, crtArgsValues, uiScope); - if (onReady) + explorerModule.getParamInfo(paramRequestObject.get('paramid'), function (paramInfo) { + if (paramInfo) + me.rebuildAll(paramInfo, uiScope); + if (onReady) onReady(uiScope); - me.unmask(); - return; - } + me.unmask(); + }); } - - //Ajax request to get parameter info - AmdaAction.getParamInfo({"paramId" : paramId}, function (result, e) { - if (e.status === true) - { - if (!result.success) - { - if (result.message && result.message != '') - Ext.Msg.show({title:'Get parameter arguments error ', msg: result.message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK}); - else - Ext.Msg.show({title:'Get parameter arguments error', msg: 'Unknown error', icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK}); - } - else - { - //Store parameter info in registry - if (explorerModule) - explorerModule.addParamInfoInRegistry(paramId, result); - - me.rebuildAll(result, crtArgsValues, uiScope); - - if (onReady) - onReady(uiScope); - } - } - else - { - Ext.Msg.show({title:'Error System', msg: e.message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK}); - } + else me.unmask(); - }); }, - rebuildAll: function(paramInfoResult, crtArgsValues, uiScope) { + rebuildAll: function(paramInfoResult , uiScope) { //Rebuild arguments selection this.rebuildArguments(paramInfoResult, uiScope); - //Set values - var argsValues = crtArgsValues; - if (!argsValues) - argsValues = {}; + //Set parameter type (scalar, vector or Tab2D) + this.paramRequestObject.set('type', this.paramType); + + //Add default template args values + var templateArgsValues = this.paramRequestObject.get('template_args'); + if (!templateArgsValues) + templateArgsValues = {}; if (paramInfoResult.template && paramInfoResult.template.arguments) { - if (!argsValues['template_args']) - argsValues['template_args'] = {}; - //Add default template args definition if needed Ext.Object.each(paramInfoResult.template.arguments, function (argKey, argDef) { - if (!argsValues['template_args'][argKey]) - argsValues['template_args'][argKey] = argDef['default']; + if (!templateArgsValues[argKey]) + templateArgsValues[argKey] = argDef['default']; }, this); + + this.paramRequestObject.set('template_args', templateArgsValues); } - this.setValues(argsValues); - }, - - setValues: function(values) { - this.items.each(function (item) { - if (this.regexp_istemplate.test(item.getId())) { - var arg_key = this.regexp_istemplate.exec(item.getId())[1]; - if (values['template_args'] && values['template_args'][arg_key]) - item.setValue(values['template_args'][arg_key]); + + + //Init values in interface + this.items.each(function (item) { + if (!item.argId) + return; + if (this.regexp_istemplate.test(item.argId)) { + var arg_key = this.regexp_istemplate.exec(item.argId)[1]; + + if (this.paramRequestObject.get('template_args') && this.paramRequestObject.get('template_args')[arg_key]) + item.setValue(this.paramRequestObject.get('template_args')[arg_key]); } - else if (values[item.getId()]) - item.setValue(values[item.getId()]); + else if (this.paramRequestObject.get(item.argId)) + item.setValue(this.paramRequestObject.get(item.argId)); }, this); }, getValues: function() { var values = {type : this.paramType}; this.items.each(function(item) { - if (item.getId() == 'no-arg') + if (!item.argId) return; - if (this.regexp_istemplate.test(item.getId())) { - var arg_key = this.regexp_istemplate.exec(item.getId())[1]; + if (this.regexp_istemplate.test(item.argId)) { + var arg_key = this.regexp_istemplate.exec(item.argId)[1]; if (!values['template_args']) values['template_args'] = {}; values['template_args'][arg_key] = item.getValue(); } else - values[item.getId()] = item.getValue(); + values[item.argId] = item.getValue(); }, this); return values; @@ -146,7 +122,7 @@ Ext.define('amdaUI.ParamArgumentsUI', { resetArguments: function(noArgsMsg) { this.removeAll(); if (!noArgsMsg) - this.add(new Ext.form.Label({text: 'No argument for this parameter', id: 'no-arg'})); + this.add(new Ext.form.Label({text: 'No argument for this parameter', argId: null})); }, rebuildArguments: function(result, uiScope) { @@ -156,11 +132,11 @@ Ext.define('amdaUI.ParamArgumentsUI', { if (result.data && result.data.dimensions) { this.paramType = 0; if (result.data.dimensions.dim_1 && (parseInt(result.data.dimensions.dim_1) > 1)) { - this.buildDimIndexSelection("dim_1", result.data, uiScope); + this.buildDimIndexSelection("dim1", result.data, uiScope); ++this.paramType; } if (result.data.dimensions.dim_2 && (parseInt(result.data.dimensions.dim_2) > 1)) { - this.buildDimIndexSelection("dim_2", result.data, uiScope); + this.buildDimIndexSelection("dim2", result.data, uiScope); ++this.paramType; } } @@ -201,15 +177,15 @@ Ext.define('amdaUI.ParamArgumentsUI', { } else { //Else, use components - if (relatedDim == "dim_1") + if (relatedDim == "dim1") title = 'Dim. 1'; - else if (relatedDim == "dim_2") + else if (relatedDim == "dim2") title = 'Dim. 2'; Ext.Object.each(data.components, function (index, component) { - if (relatedDim == "dim_1" && component.index_1 != "") + if (relatedDim == "dim1" && component.index_1 != "") indexes.push({'key' : component.index_1, 'value' : index + ' : ' + component.name}); - else if (relatedDim == "dim_2" && component.index_2 != "") + else if (relatedDim == "dim2" && component.index_2 != "") indexes.push({'key' : component.index_2, 'value' : index + ' : ' + component.name}); }); } @@ -228,9 +204,10 @@ Ext.define('amdaUI.ParamArgumentsUI', { valueField: 'key', value: '*', editable: false, - id: relatedDim, + argId: relatedDim, listeners: { change: function(field, newValue, oldValue, eOpts) { + this.paramRequestObject.set(relatedDim, newValue); if (this.onChange != null) this.onChange(uiScope, relatedDim, newValue, oldValue, false); }, @@ -250,13 +227,18 @@ Ext.define('amdaUI.ParamArgumentsUI', { switch (argument.type) { case 'float' : var argumentField = Ext.create('Ext.form.NumberField', { - id: 'template_' + key, + argId: 'template_' + key, fieldLabel: argument.name, decimalPrecision : 3, allowBlank : false, value: parseFloat(argument.default), listeners: { change: function(field, newValue, oldValue, eOpts) { + var template_args = me.paramRequestObject.get('template_args'); + if (!template_args) + template_args = {}; + template_args[key] = newValue; + me.paramRequestObject.set('template_args', template_args); if (me.onChange != null) me.onChange(uiScope, key, newValue, oldValue, true); }, @@ -285,10 +267,15 @@ Ext.define('amdaUI.ParamArgumentsUI', { valueField: 'key', value: argument.default, editable: false, - id: 'template_' + key, + argId: 'template_' + key, listeners: { change: function(field, newValue, oldValue, eOpts) { - if (me.onChange != null) + var template_args = me.paramRequestObject.get('template_args'); + if (!template_args) + template_args = {}; + template_args[key] = newValue; + me.paramRequestObject.set('template_args', template_args); + if (me.onChange != null) me.onChange(uiScope, key, newValue, oldValue, true); }, scope: me diff --git a/js/app/views/ParameterUI.js b/js/app/views/ParameterUI.js index a757246..a9a1075 100755 --- a/js/app/views/ParameterUI.js +++ b/js/app/views/ParameterUI.js @@ -41,28 +41,9 @@ Ext.define('amdaUI.ParameterUI', { this.constructionField.setCaretPosition(this.constructionField.getValue().length); }, - onApplyParameterArgs : function(uiScope, paramId, values) { - var fullParam = paramId; - switch (values['type']) { - case 0: - //scalar - nothing to do - break; - case 1: - //Tab1D - if (values['dim_1'] && (values['dim_1'] != '') && (values['dim_1'] != '*')) - fullParam += '('+values['dim_1']+')'; - else if (values['dim_2'] && (values['dim_2'] != '') && (values['dim_2'] != '*')) - fullParam += '('+values['dim_2']+')'; - break; - case 2: - //Tab2D - var dim1 = (values['dim_1'] && (values['dim_1'] != '')) ? values['dim_1'] : "*"; - var dim2 = (values['dim_2'] && (values['dim_2'] != '')) ? values['dim_2'] : "*"; - if ((dim1 != '*') || (dim2 != '*')) - fullParam += '('+dim1+','+dim2+')'; - } - - uiScope.addParamInEditor(fullParam); + onApplyParameterArgs : function(uiScope, paramRequestObject) { + var fullParam = paramRequestObject.getParamFullName(); + uiScope.addParamInEditor(fullParam); }, addParam : function(newParamName, isArgsToDefined) { @@ -74,8 +55,10 @@ Ext.define('amdaUI.ParameterUI', { editParameterArgs: function(name) { var paramArgsPlug = this.getPlugin('derived-param-arguments-plugin'); - if (paramArgsPlug) - paramArgsPlug.show(name); + if (paramArgsPlug) { + var workinRequestParamObject = Ext.create('amdaModel.RequestParamObject', {paramid: name, type: 0, dim1: '', dim2: '', template_args: {} }); + paramArgsPlug.show('derived-param-arguments-plugin', workinRequestParamObject); + } }, setObject : function (object) { diff --git a/js/app/views/PlotComponents/PlotParamForm.js b/js/app/views/PlotComponents/PlotParamForm.js index 7765558..0ae846b 100644 --- a/js/app/views/PlotComponents/PlotParamForm.js +++ b/js/app/views/PlotComponents/PlotParamForm.js @@ -38,7 +38,7 @@ Ext.define('amdaPlotComp.PlotParamForm', { setObject : function(object) { this.object = object; this.loadRecord(this.object); - this.updateDrawingOptions(this.object.get('param-drawing-type'), this.object.get('param-id')); + this.updateDrawingOptions(this.object.get('param-drawing-type'), this.object.get('paramid')); }, getDrawingOptionsForm: function(type) { @@ -103,29 +103,12 @@ Ext.define('amdaPlotComp.PlotParamForm', { drawingOptionsForm.setObject(this.object); if (this.paramArgs && paramId) - this.paramArgs.editParameter(paramId, {'dim_1' : this.object.get('param-dim-1'), 'dim_2' : this.object.get('param-dim-2'), 'template_args' : this.object.get('param-template-args')}, this, function (uiScope) { - uiScope.object.set('param-type', uiScope.paramArgs.paramType); - var crtValues = uiScope.paramArgs.getValues(); - if (crtValues && crtValues['template_args']) - uiScope.object.set('param-template-args', crtValues['template_args']); + this.paramArgs.editParameter(this.object, this, function (uiScope) { uiScope.crtTree.refresh(); }); }, onChangeParamArgs: function(uiScope, args_key, newValue, oldValue, isTemplateArg) { - if (!isTemplateArg) { - if (args_key == 'dim_1') - uiScope.object.set('param-dim-1', newValue); - else if (args_key == 'dim_2') - uiScope.object.set('param-dim-2', newValue); - } - else { - var templateArgs = uiScope.object.get('param-template-args'); - if (!templateArgs) - templateArgs = {}; - templateArgs[args_key] = newValue; - uiScope.object.set('param-template-args', templateArgs); - } uiScope.crtTree.refresh(); }, diff --git a/js/app/views/PlotComponents/PlotTree.js b/js/app/views/PlotComponents/PlotTree.js index 9dd4202..84aeecd 100644 --- a/js/app/views/PlotComponents/PlotTree.js +++ b/js/app/views/PlotComponents/PlotTree.js @@ -67,13 +67,13 @@ Ext.define('amdaPlotComp.PlotTree', { this.buildPanelsNode(); }, - buildPanelsNode: function() { + buildPanelsNode: function(paramNodeToSelect) { if (this.panelsNode.hasChildNodes()) this.panelsNode.removeAll(); var me = this; this.tabObject.panels().each(function (panelObject) { - me.addPanelNode(panelObject); + me.addPanelNode(panelObject, paramNodeToSelect); }); }, @@ -280,7 +280,7 @@ Ext.define('amdaPlotComp.PlotTree', { this.getSelectionModel().select(selectedFillNode); }, - addPanelNode: function(panelObject) { + addPanelNode: function(panelObject, paramNodeToSelect) { var panelNode = this.panelsNode.appendChild(new amdaPlotObj.PlotPanelTreeNode({object : panelObject})); if (!this.tabObject.get('tree-simplified-view')) { @@ -290,7 +290,7 @@ Ext.define('amdaPlotComp.PlotTree', { this.buildPanelAdditionalObjectsNode(panelObject); } //Params node - this.buildPanelParamsNode(panelObject); + this.buildPanelParamsNode(panelObject, paramNodeToSelect); return panelNode; }, @@ -629,8 +629,8 @@ Ext.define('amdaPlotComp.PlotTree', { var me = this; panelObject.createNewParam(paramId, function (newParamObject) { //Rebuild params node - me.buildPanelsNode(); - //me.buildPanelParamsNode(panelObject, newParamObject.get('id')); + me.buildPanelsNode(newParamObject.getId()); + //BRE newParamObject }); }, diff --git a/js/app/views/SearchUI.js b/js/app/views/SearchUI.js index c3e8bf4..ebc2f4e 100755 --- a/js/app/views/SearchUI.js +++ b/js/app/views/SearchUI.js @@ -54,34 +54,17 @@ Ext.define('amdaUI.SearchUI', { this.constructionField.setCaretPosition(this.constructionField.getValue().length); }, - onApplyParameterArgs : function(uiScope, paramId, values) { - var fullParam = paramId; - switch (values['type']) { - case 0: - //scalar - nothing to do - break; - case 1: - //Tab1D - if (values['dim_1'] && (values['dim_1'] != '') && (values['dim_1'] != '*')) - fullParam += '('+values['dim_1']+')'; - else if (values['dim_2'] && (values['dim_2'] != '') && (values['dim_2'] != '*')) - fullParam += '('+values['dim_2']+')'; - break; - case 2: - //Tab2D - var dim1 = (values['dim_1'] && (values['dim_1'] != '')) ? values['dim_1'] : "*"; - var dim2 = (values['dim_2'] && (values['dim_2'] != '')) ? values['dim_2'] : "*"; - if ((dim1 != '*') || (dim2 != '*')) - fullParam += '('+dim1+','+dim2+')'; - } - + onApplyParameterArgs : function(uiScope, paramRequestObject) { + var fullParam = paramRequestObject.getParamFullName(); uiScope.addParamInEditor(fullParam); }, editParameterArgs: function(name) { var paramArgsPlug = this.getPlugin('search-param-components-plugin'); - if (paramArgsPlug) - paramArgsPlug.show(name); + if (paramArgsPlug) { + var workinRequestParamObject = Ext.create('amdaModel.RequestParamObject', {paramid: name, type: 0, dim1: '', dim2: '', template_args: {} }); + paramArgsPlug.show('search-param-components-plugin', workinRequestParamObject); + } }, /** -- libgit2 0.21.2