Blame view

js/app/views/ParamArgumentsUI.js 19.3 KB
7ac3ce50   Benjamin Renard   First implementat...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/**
 * Project   : AMDA-NG
 * Name      : ParamArgumentsUI.js
 * @class   amdaUI.ParamArgumentsUI
 * @extends Ext.container.Container
 * @brief   Parameter arguments definition (View)
 * @author  Benjamin Renard
 * @version $Id: ParamArgumentsUI.js benjamin $
 */


Ext.define('amdaUI.ParamArgumentsUI', {
	extend: 'Ext.container.Container',
	alias: 'widget.paramArguments',
4dbd97ec   Menouard AZIB   Goal is reached b...
15

51b7c77c   Benjamin Renard   Add templated par...
16
	regexp_istemplate: /^template_(.*)/,
4dbd97ec   Menouard AZIB   Goal is reached b...
17

bb6e93d9   Benjamin Renard   Implement templat...
18
	paramRequestObject: null,
7ac3ce50   Benjamin Renard   First implementat...
19
	onChange: null,
690e0a87   Benjamin Renard   Add sum in table ...
20
21
	onModifyHeight: null,
	pluginOwner: null,
4dbd97ec   Menouard AZIB   Goal is reached b...
22
23
	inRebuild: false,

3e77ccb3   Benjamin Renard   Add missing requires
24
25
26
27
	requires: [
		'amdaPlotObj.PlotObjectConfig'
	],

4dbd97ec   Menouard AZIB   Goal is reached b...
28
29
	constructor: function (config) {
		this.init(config);
7ac3ce50   Benjamin Renard   First implementat...
30
31
		this.callParent(arguments);
	},
4dbd97ec   Menouard AZIB   Goal is reached b...
32
33

	init: function (config) {
7ac3ce50   Benjamin Renard   First implementat...
34
35
36
37
		var myConf = {
			layout: {
				type: 'vbox',
				align: 'stretch'
4dbd97ec   Menouard AZIB   Goal is reached b...
38
			},
7ac3ce50   Benjamin Renard   First implementat...
39
		};
4dbd97ec   Menouard AZIB   Goal is reached b...
40
41

		Ext.apply(this, Ext.apply(arguments, myConf));
7ac3ce50   Benjamin Renard   First implementat...
42
	},
4dbd97ec   Menouard AZIB   Goal is reached b...
43
44

	editParameter: function (paramRequestObject, uiScope, onReady) {
bb6e93d9   Benjamin Renard   Implement templat...
45
		this.paramRequestObject = paramRequestObject;
29dfb596   Benjamin Renard   Rework of ParamAr...
46

7ac3ce50   Benjamin Renard   First implementat...
47
		var me = this;
7bc1d734   Benjamin Renard   Fix bug in derive...
48
		me.getEl().mask();
29dfb596   Benjamin Renard   Rework of ParamAr...
49
		me.resetArguments();
4dbd97ec   Menouard AZIB   Goal is reached b...
50

29dfb596   Benjamin Renard   Rework of ParamAr...
51
		var explorerModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id);
4dbd97ec   Menouard AZIB   Goal is reached b...
52

29dfb596   Benjamin Renard   Rework of ParamAr...
53
54
55
		if (explorerModule) {
			explorerModule.getParamInfo(paramRequestObject.get('paramid'), function (paramInfo) {
				if (paramInfo) {
255b183d   Benjamin Renard   Fix
56
					paramRequestObject.set("channels-param-info", paramInfo.data.tables);
4dbd97ec   Menouard AZIB   Goal is reached b...
57

29dfb596   Benjamin Renard   Rework of ParamAr...
58
59
60
					if (!paramRequestObject.get('is-init')) {
						if (paramInfo.data && paramInfo.data.dimensions) {
							//Init each dimensions and set parameter type (0: scalar, 1: vector or 2: Tab2D)
4dbd97ec   Menouard AZIB   Goal is reached b...
61
							paramRequestObject.set('type', 0);
29dfb596   Benjamin Renard   Rework of ParamAr...
62
							if (me.initDimension('dim1', paramInfo.data)) {
4dbd97ec   Menouard AZIB   Goal is reached b...
63
								paramRequestObject.set('type', paramRequestObject.get('type') + 1);
29dfb596   Benjamin Renard   Rework of ParamAr...
64
65
							}
							if (me.initDimension('dim2', paramInfo.data)) {
4dbd97ec   Menouard AZIB   Goal is reached b...
66
								paramRequestObject.set('type', paramRequestObject.get('type') + 1);
29dfb596   Benjamin Renard   Rework of ParamAr...
67
68
69
							}
							if (paramRequestObject.get('type') == 2) {
								//Tab2D
4dbd97ec   Menouard AZIB   Goal is reached b...
70
								var dim2RelatedTable = me.getRelatedTableFromDim('dim2', paramInfo.data.tables);
29dfb596   Benjamin Renard   Rework of ParamAr...
71
72
73
								if (!dim2RelatedTable.variable) {
									paramRequestObject.set('dim2-index', 0);
								}
367b8867   Benjamin Renard   Select sum in ran...
74
75
76
								else {
									paramRequestObject.set('dim2-sum-type', 1);
								}
29dfb596   Benjamin Renard   Rework of ParamAr...
77
							}
29dfb596   Benjamin Renard   Rework of ParamAr...
78
						}
eac92219   Benjamin Renard   Do not call onCha...
79
						paramRequestObject.set('is-init', true);
29dfb596   Benjamin Renard   Rework of ParamAr...
80
81
82
					}
					me.rebuildAll(paramInfo, uiScope);
				}
bb6e93d9   Benjamin Renard   Implement templat...
83
				if (onReady)
0314bd32   Benjamin Renard   Keep a registry o...
84
					onReady(uiScope);
7bc1d734   Benjamin Renard   Fix bug in derive...
85
				me.getEl().unmask();
4dbd97ec   Menouard AZIB   Goal is reached b...
86
			});
29dfb596   Benjamin Renard   Rework of ParamAr...
87
88
		}
		else
7bc1d734   Benjamin Renard   Fix bug in derive...
89
			me.getEl().unmask();
29dfb596   Benjamin Renard   Rework of ParamAr...
90
	},
dc9e2c14   Elena.Budnik   init + message + ...
91

4dbd97ec   Menouard AZIB   Goal is reached b...
92
	initDimension: function (relatedDim, data) {
29dfb596   Benjamin Renard   Rework of ParamAr...
93
94
95
96
97
98
99
100
		if (!data || !data.dimensions || !data.dimensions[relatedDim] || this.paramRequestObject.get('is-init')) {
			return false;
		}
		if (data.dimensions[relatedDim] && (parseInt(data.dimensions[relatedDim]) > 1)) {
			var relatedTable = this.getRelatedTableFromDim(relatedDim, data.tables);
			if (relatedTable) {
				var minmax = this.getDimensionMinMaxValues(relatedDim, data);
				if (!minmax) {
4dbd97ec   Menouard AZIB   Goal is reached b...
101
					myDesktopApp.warningMsg('Min/Max ' + this.getDimensionTitle(relatedDim, data) + ' values are undefined<br/>Arbitrary values are taken');
29dfb596   Benjamin Renard   Rework of ParamAr...
102
103
104
105
106
					minmax = {
						'min': 10,
						'max': 10000
					};
				}
4dbd97ec   Menouard AZIB   Goal is reached b...
107
108
109
110
				this.paramRequestObject.set(relatedDim + '-min-value', minmax['min']);
				this.paramRequestObject.set(relatedDim + '-max-value', minmax['max']);
				this.paramRequestObject.set(relatedDim + '-min-index', 0);
				this.paramRequestObject.set(relatedDim + '-max-index', parseInt(data.dimensions[relatedDim]) - 1);
29dfb596   Benjamin Renard   Rework of ParamAr...
111
112
113
114
115
116
			}
			return true;
		}
		return false;
	},

4dbd97ec   Menouard AZIB   Goal is reached b...
117
	getDimensionMinMaxValues: function (relatedDim, data) {
29dfb596   Benjamin Renard   Rework of ParamAr...
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
		var related