Commit 3cedc95c7190204af4e7ff0a10cac73d4b9e43d2

Authored by Benjamin Renard
1 parent 429f876c

Fix functions definition

generic_data/Functions/constants.xml
1 1 <?xml version="1.0"?>
2   -<constants>
  2 +<constants xml:id="constants">
3 3 <constant info="astronomical unit" name="AU" units="m" kind="space">1.49598e+11</constant>
4 4 <constant info="Boltzmann constant" name="k" units="J/K" kind="physics">1.38054e-23</constant>
5 5 <constant info="kelvin to electron-volt" name="K2eV" units="eV/K" kind="units">8.622e-5</constant>
... ...
generic_data/Functions/functions.xml
1 1 <?xml version="1.0"?>
2   -<functions>
  2 +<functions xml:id="functions">
3 3 <function name="mean_(,)" args="1" kind="time">
4 4 <prompt>input averaging time in secs</prompt>
5 5 <info_brief>average</info_brief>
... ... @@ -88,11 +88,11 @@
88 88 <prompt/>
89 89 <info_brief>GSE to SM transformation</info_brief>
90 90 </function>-->
91   - <function name="cross(,)" params="2" kind="vectors">
  91 + <function name="cross(,)" args="2" kind="vectors">
92 92 <info_brief>Cross product</info_brief>
93 93 <new_kernel>cross</new_kernel>
94 94 </function>
95   - <function name="dot(,)" params="2" kind="vectors">
  95 + <function name="dot(,)" args="2" kind="vectors">
96 96 <info_brief>Dot product</info_brief>
97 97 <new_kernel>dot</new_kernel>
98 98 </function>
... ...
js/app/models/Function.js
... ... @@ -15,9 +15,8 @@ Ext.define(&#39;amdaModel.Function&#39;, {
15 15 fields : [
16 16 {name: 'name', mapping: '@name', type:'string'},
17 17 {name: 'kind', mapping: '@kind', type: 'string', defaultValue: 'amda'},
18   - {name: 'args', mapping: '@args', type: 'int', defaultValue: 0},
  18 + {name: 'args', mapping: '@args', type: 'int', defaultValue: 1},
19 19 {name: 'argv', mapping: '@argv', type: 'string'},
20   - {name: 'params', mapping: '@params', type:'int', defaultValue: 1},
21 20 {name: 'prompt', type: 'string', defaultValue: ''},
22 21 {name: 'info_brief', type: 'string', defaultValue: ''}
23 22 ],
... ... @@ -37,4 +36,4 @@ Ext.define(&#39;amdaModel.Function&#39;, {
37 36 record: 'function'
38 37 }
39 38 }
40   -});
41 39 \ No newline at end of file
  40 +});
... ...
js/app/views/CalculatorUI.js
... ... @@ -189,7 +189,7 @@ Ext.define(&#39;amdaUI.CalculatorUI&#39;, {
189 189  
190 190 processFormula : function(sel,currentBtn, params, afterParamsText){
191 191 // calculation of the required number of parameters
192   - var nbParams = currentBtn.initialConfig.params;
  192 + var nbParams = currentBtn.initialConfig.args;
193 193 var fnText = currentBtn.text.split('(');
194 194 var newConstruction = sel.beforeText + fnText[0]+"(";
195 195 // if there at least one parameter selected
... ... @@ -210,7 +210,7 @@ Ext.define(&#39;amdaUI.CalculatorUI&#39;, {
210 210  
211 211 // If we haven't the right number of selected parameters
212 212 if (params.length < nbParams){
213   - var stringParamRequired = currentBtn.initialConfig.params+" parameter(s)";
  213 + var stringParamRequired = currentBtn.initialConfig.args+" parameter(s)";
214 214 Ext.Msg.alert('Caution', 'you\'ll have to add '+ stringParamRequired +' to apply this function',
215 215 function(){
216 216 // set Caret Position at placement of required parameter in function
... ... @@ -446,7 +446,6 @@ Ext.define(&#39;amdaUI.CalculatorUI&#39;, {
446 446 {
447 447 text: f.get('name'),
448 448 args: f.get('args'),
449   - params: f.get('params'),
450 449 prompt: f.get('prompt'),
451 450 tooltip: f.get('info_brief'),
452 451 scope: this,
... ... @@ -466,8 +465,9 @@ Ext.define(&#39;amdaUI.CalculatorUI&#39;, {
466 465 Ext.Msg.alert("Invalid Selection", "Action aborted");
467 466 }
468 467 else {
  468 +console.log(params.length);
469 469 // calculation of the required number of parameters
470   - var nbParams = b.initialConfig.params;
  470 + var nbParams = b.initialConfig.args;
471 471  
472 472 if (params.length>nbParams)
473 473 {
... ...