Commit 7ef7ea02c35a2b5256fea9ae2ae39484054f8903
1 parent
488b1401
Exists in
master
and in
112 other branches
Add erase button to parameter drop field
Showing
3 changed files
with
60 additions
and
7 deletions
Show diff stats
js/app/models/PlotObjects/PlotPanelObject.js
... | ... | @@ -223,7 +223,7 @@ Ext.define('amdaPlotObj.PlotPanelObject', { |
223 | 223 | break; |
224 | 224 | case 'xyPlot' : |
225 | 225 | //X Axis |
226 | - var recs = this.axes().add({id : 'x'}); | |
226 | + var recs = this.axes().add({id : 'xaxis_id'}); | |
227 | 227 | recs[0].setDefaultValues('x'); |
228 | 228 | //Y Left Axis |
229 | 229 | recs = this.axes().add({id : 'y-left'}); |
... | ... | @@ -237,7 +237,7 @@ Ext.define('amdaPlotObj.PlotPanelObject', { |
237 | 237 | break; |
238 | 238 | case 'instantPlot' : |
239 | 239 | //X Axis |
240 | - var recs = this.axes().add({id : 'x'}); | |
240 | + var recs = this.axes().add({id : 'xaxis_id'}); | |
241 | 241 | recs[0].setDefaultValues('x'); |
242 | 242 | //Y Left Axis |
243 | 243 | recs = this.axes().add({id : 'y-left'}); |
... | ... |
... | ... | @@ -0,0 +1,25 @@ |
1 | +/** | |
2 | + * Project : AMDA-NG | |
3 | + * Name : EraseTrigger.js | |
4 | + * @class amdaPlotComp.EraseTrigger | |
5 | + * @extends Ext.form.field.Trigger | |
6 | + * @brief Erase button used to define a dropped parameter (cf. function addStandardParamDropTarget of PlotStandardForm) | |
7 | + * @author Benjamin Renard | |
8 | + * @version $Id: EraseTrigger.js benjamin $ | |
9 | + */ | |
10 | + | |
11 | +Ext.define('amdaPlotComp.EraseTrigger', { | |
12 | + extend: 'Ext.form.field.Trigger', | |
13 | + alias: 'widget.erasetrigger', | |
14 | + initComponent: function () { | |
15 | + var me = this; | |
16 | + | |
17 | + me.triggerCls = 'x-form-clear-trigger'; // native ExtJS class & icon | |
18 | + | |
19 | + me.callParent(arguments); | |
20 | + }, | |
21 | + // override onTriggerClick | |
22 | + onTriggerClick: function() { | |
23 | + this.setValue(''); | |
24 | + } | |
25 | +}); | |
0 | 26 | \ No newline at end of file |
... | ... |
js/app/views/PlotComponents/PlotStandardForm.js
... | ... | @@ -12,7 +12,8 @@ Ext.define('amdaPlotComp.PlotStandardForm', { |
12 | 12 | extend: 'Ext.form.Panel', |
13 | 13 | |
14 | 14 | requires : [ |
15 | - 'amdaPlotObj.PlotObjectConfig' | |
15 | + 'amdaPlotObj.PlotObjectConfig', | |
16 | + 'amdaPlotComp.EraseTrigger' | |
16 | 17 | ], |
17 | 18 | |
18 | 19 | //Object associated to this form |
... | ... | @@ -249,10 +250,9 @@ Ext.define('amdaPlotComp.PlotStandardForm', { |
249 | 250 | |
250 | 251 | addStandardParamDropTarget: function(name, label, onChange) { |
251 | 252 | return { |
252 | - xtype: 'textfield', | |
253 | + xtype: 'erasetrigger', | |
253 | 254 | name: name, |
254 | 255 | fieldLabel: label, |
255 | - readOnly: true, | |
256 | 256 | emptyText: 'Drop a parameter', |
257 | 257 | listeners: { |
258 | 258 | change: function(field, newValue, oldValue, eOpts) { |
... | ... | @@ -269,8 +269,36 @@ Ext.define('amdaPlotComp.PlotStandardForm', { |
269 | 269 | notifyDrop: function(ddSource, e, data) { |
270 | 270 | var selectedRecord = ddSource.dragData.records[0]; |
271 | 271 | |
272 | - field.setValue(selectedRecord.get('id')); | |
273 | - | |
272 | + switch (selectedRecord.$className) | |
273 | + { | |
274 | + case 'amdaModel.LocalParamNode' : | |
275 | + case 'amdaModel.RemoteParamNode' : | |
276 | + case 'amdaModel.RemoteSimuParamNode' : | |
277 | + if (!selectedRecord.get('isParameter') || selectedRecord.get('disable')) | |
278 | + return false; | |
279 | + if (selectedRecord.get('alias') != "" ) | |
280 | + field.setValue("#"+selectedRecord.get('alias')); | |
281 | + else | |
282 | + field.setValue(selectedRecord.get('id')); | |
283 | + return true; | |
284 | + case 'amdaModel.AliasNode' : | |
285 | + if (!selectedRecord.isLeaf()) | |
286 | + return false; | |
287 | + field.setValue("#"+selectedRecord.get('text')); | |
288 | + return true; | |
289 | + case 'amdaModel.DerivedParamNode' : | |
290 | + if (!selectedRecord.isLeaf()) | |
291 | + return false; | |
292 | + field.setValue("ws_"+selectedRecord.get('text')); | |
293 | + return true; | |
294 | + case 'amdaModel.MyDataParamNode' : | |
295 | + if (!selectedRecord.isLeaf()) | |
296 | + return false; | |
297 | + field.setValue("wsd_"+selectedRecord.get('text')); | |
298 | + return true; | |
299 | + default : | |
300 | + return false; | |
301 | + } | |
274 | 302 | return true; |
275 | 303 | } |
276 | 304 | } |
... | ... |