Commit 0314bd3221c8cd50fbb1b79eb93a4fba361cde5f
1 parent
e748a7f5
Exists in
master
and in
111 other branches
Keep a registry of already loaded parameter info
Showing
2 changed files
with
51 additions
and
18 deletions
Show diff stats
js/app/controllers/ExplorerModule.js
... | ... | @@ -48,6 +48,8 @@ Ext.define('amdaDesktop.ExplorerModule', { |
48 | 48 | filter : null, |
49 | 49 | filtersStore : null, |
50 | 50 | |
51 | + paramInfoRegistry : {}, | |
52 | + | |
51 | 53 | constructor : function(config){ |
52 | 54 | this.callParent(arguments); |
53 | 55 | if (!this.filtersStore) { |
... | ... | @@ -59,7 +61,6 @@ Ext.define('amdaDesktop.ExplorerModule', { |
59 | 61 | } |
60 | 62 | }, |
61 | 63 | |
62 | - | |
63 | 64 | createWindow : function() { |
64 | 65 | var desktop = this.app.getDesktop(); |
65 | 66 | |
... | ... | @@ -299,5 +300,13 @@ Ext.define('amdaDesktop.ExplorerModule', { |
299 | 300 | Ext.Msg.show({title:'Error System', msg: e.message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK}); |
300 | 301 | } |
301 | 302 | },this); |
303 | + }, | |
304 | + | |
305 | + getParamInfoInRegistry : function(paramId) { | |
306 | + return this.paramInfoRegistry[paramId]; | |
307 | + }, | |
308 | + | |
309 | + addParamInfoInRegistry : function(paramId, paramInfo) { | |
310 | + this.paramInfoRegistry[paramId] = paramInfo; | |
302 | 311 | } |
303 | 312 | }); | ... | ... |
js/app/views/ParamArgumentsUI.js
... | ... | @@ -40,6 +40,22 @@ Ext.define('amdaUI.ParamArgumentsUI', { |
40 | 40 | var me = this; |
41 | 41 | me.mask(); |
42 | 42 | me.resetArguments(); |
43 | + | |
44 | + var explorerModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id); | |
45 | + | |
46 | + if (explorerModule) { | |
47 | + paramInfo = explorerModule.getParamInfoInRegistry(paramId); | |
48 | + if (paramInfo) { | |
49 | + //Re-use already loaded param info | |
50 | + me.rebuildAll(paramInfo, crtArgsValues, uiScope); | |
51 | + if (onReady) | |
52 | + onReady(uiScope); | |
53 | + me.unmask(); | |
54 | + return; | |
55 | + } | |
56 | + } | |
57 | + | |
58 | + //Ajax request to get parameter info | |
43 | 59 | AmdaAction.getParamInfo({"paramId" : paramId}, function (result, e) { |
44 | 60 | if (e.status === true) |
45 | 61 | { |
... | ... | @@ -52,25 +68,12 @@ Ext.define('amdaUI.ParamArgumentsUI', { |
52 | 68 | } |
53 | 69 | else |
54 | 70 | { |
55 | - //Rebuild arguments selection | |
56 | - me.rebuildArguments(result, uiScope); | |
71 | + //Store parameter info in registry | |
72 | + if (explorerModule) | |
73 | + explorerModule.addParamInfoInRegistry(paramId, result); | |
57 | 74 | |
58 | - //Set values | |
59 | - var argsValues = crtArgsValues; | |
60 | - if (!argsValues) | |
61 | - argsValues = {}; | |
62 | - if (result.template && result.template.arguments) { | |
63 | - if (!argsValues['template_args']) | |
64 | - argsValues['template_args'] = {}; | |
65 | - //Add default template args definition if needed | |
66 | - Ext.Object.each(result.template.arguments, function (argKey, argDef) { | |
67 | - if (!argsValues['template_args'][argKey]) | |
68 | - argsValues['template_args'][argKey] = argDef['default']; | |
69 | - }, me); | |
70 | - } | |
71 | - me.setValues(argsValues); | |
75 | + me.rebuildAll(result, crtArgsValues, uiScope); | |
72 | 76 | |
73 | - //Set default values | |
74 | 77 | if (onReady) |
75 | 78 | onReady(uiScope); |
76 | 79 | } |
... | ... | @@ -83,6 +86,27 @@ Ext.define('amdaUI.ParamArgumentsUI', { |
83 | 86 | }); |
84 | 87 | }, |
85 | 88 | |
89 | + rebuildAll: function(paramInfoResult, crtArgsValues, uiScope) { | |
90 | + //Rebuild arguments selection | |
91 | + this.rebuildArguments(paramInfoResult, uiScope); | |
92 | + | |
93 | + //Set values | |
94 | + var argsValues = crtArgsValues; | |
95 | + if (!argsValues) | |
96 | + argsValues = {}; | |
97 | + if (paramInfoResult.template && paramInfoResult.template.arguments) { | |
98 | + if (!argsValues['template_args']) | |
99 | + argsValues['template_args'] = {}; | |
100 | + | |
101 | + //Add default template args definition if needed | |
102 | + Ext.Object.each(paramInfoResult.template.arguments, function (argKey, argDef) { | |
103 | + if (!argsValues['template_args'][argKey]) | |
104 | + argsValues['template_args'][argKey] = argDef['default']; | |
105 | + }, this); | |
106 | + } | |
107 | + this.setValues(argsValues); | |
108 | + }, | |
109 | + | |
86 | 110 | setValues: function(values) { |
87 | 111 | this.items.each(function (item) { |
88 | 112 | if (this.regexp_istemplate.test(item.getId())) { | ... | ... |