Commit 53b0bc1150cfd7c9854d4515fa1ce5a5f8943f73
1 parent
48fdb91e
Exists in
9660
ihm rm column
Showing
4 changed files
with
263 additions
and
182 deletions
Show diff stats
... | ... | @@ -0,0 +1,42 @@ |
1 | +/* | |
2 | + * To change this license header, choose License Headers in Project Properties. | |
3 | + * To change this template file, choose Tools | Templates | |
4 | + * and open the template in the editor. | |
5 | + */ | |
6 | +Ext.define('amdaModel.TTCatConfig', { | |
7 | + singleton: true, | |
8 | + catalog :{ | |
9 | + addcolumn: { | |
10 | + prompts : [ | |
11 | + { | |
12 | + type: 'string', | |
13 | + prompt: 'name', | |
14 | + default: 'column' | |
15 | + },{ | |
16 | + type: 'list', | |
17 | + prompt: 'type', | |
18 | + default: 'column', | |
19 | + subtype : 'dataType' | |
20 | + },{ | |
21 | + type: 'float', | |
22 | + prompt: 'size', | |
23 | + default: 1 | |
24 | + } | |
25 | + ], | |
26 | + storeList :[ | |
27 | + { | |
28 | + id :'dataType', | |
29 | + valuesStore : [ | |
30 | + {key: '0' , value: 'double', info: ''}, | |
31 | + {key: '1' , value: 'dateTime', info: ''}, | |
32 | + {key: '2' , value: 'string', info: ''}, | |
33 | + {key: '3' , value: 'int', info: ''} | |
34 | + ] | |
35 | + | |
36 | + } | |
37 | + | |
38 | + ] | |
39 | + } | |
40 | + } | |
41 | + }); | |
42 | + | ... | ... |
js/app/views/CalculatorUI.js
... | ... | @@ -16,192 +16,13 @@ |
16 | 16 | |
17 | 17 | var CalculatorData = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '(', ')', '[', ']', '+', '-', '*', '/', '^', '.', '>', '>=', '=', '!=', '<=', '<', '&', '|']; |
18 | 18 | |
19 | -Ext.define('amdaUI.PromptArgsWin', { | |
20 | - extend: 'Ext.window.Window', | |
21 | - | |
22 | - fieldsForm: null, | |
23 | - applyCallback: null, | |
24 | - | |
25 | - constructor: function(config) { | |
26 | - this.init(config); | |
27 | - this.callParent(arguments); | |
28 | - }, | |
29 | - | |
30 | - promptArgs : function(prompts, fn, scope) { | |
31 | - var me = this; | |
32 | - if (fn) | |
33 | - this.applyCallback = Ext.Function.bind(fn, scope); | |
34 | - else | |
35 | - this.applyCallback = null; | |
36 | - this.fieldsForm.removeAll(); | |
37 | - prompts.each(function(promptObj, index) { | |
38 | - switch (promptObj.get('type')) { | |
39 | - case 'float': | |
40 | - me.addFloatField(promptObj.get('prompt'), index, promptObj.get('default')); | |
41 | - break; | |
42 | - case 'list': | |
43 | - me.addComboField(promptObj.get('prompt'), promptObj.get('subtype'), index, promptObj.get('default')); | |
44 | - break; | |
45 | - case 'boolean': | |
46 | - me.addBooleanField(promptObj.get('prompt'), index, promptObj.get('default')); | |
47 | - break; | |
48 | - case 'string': | |
49 | - me.addStringField(promptObj.get('prompt'), index, promptObj.get('default')); | |
50 | - break; | |
51 | - default: | |
52 | - console.log('Unknown arg type: ' + promptObj.get('type')); | |
53 | - break; | |
54 | - } | |
55 | - }); | |
56 | - this.show(); | |
57 | - }, | |
58 | - | |
59 | - addFloatField: function(label, index, defaultVal) { | |
60 | - var field = this.fieldsForm.add({ | |
61 | - xtype: 'numberfield', | |
62 | - name: 'arg' + index, | |
63 | - fieldLabel: label, | |
64 | - decimalPrecision : 20, | |
65 | - allowBlank: false, | |
66 | - hideTrigger: true, | |
67 | - keyNavEnabled: false, | |
68 | - mouseWheelEnabled: false | |
69 | - }); | |
70 | - if (defaultVal != "") { | |
71 | - defaultVal = parseFloat(defaultVal); | |
72 | - if (!isNaN(defaultVal)) { | |
73 | - field.setValue(defaultVal); | |
74 | - } | |
75 | - } | |
76 | - }, | |
77 | - | |
78 | - addComboField: function(label, listtype, index, defaultVal) { | |
79 | - var argslistStore = amdaUI.CalculatorUI.argslistStore; | |
80 | - if (!argslistStore) { | |
81 | - return; | |
82 | - } | |
83 | - | |
84 | - var valuesStore = null; | |
85 | - argslistStore.each(function(arglist) { | |
86 | - if (arglist.get('id') == listtype) { | |
87 | - valuesStore = arglist.valuesStore; | |
88 | - } | |
89 | - }); | |
90 | - if (!valuesStore) { | |
91 | - return; | |
92 | - } | |
93 | - | |
94 | - | |
95 | - var listData = []; | |
96 | - valuesStore.each(function (item) { | |
97 | - listData.push({'key': item.get('key'), 'value': item.get('value'), 'info': item.get('info')}); | |
98 | - }); | |
99 | - | |
100 | - var comboStore = Ext.create('Ext.data.Store', { | |
101 | - fields: ['key', 'value', 'info'], | |
102 | - data : listData | |
103 | - }); | |
104 | - | |
105 | - var field = this.fieldsForm.add({ | |
106 | - xtype: 'combo', | |
107 | - name: 'arg' + index, | |
108 | - fieldLabel: label, | |
109 | - store: comboStore, | |
110 | - queryMode: 'local', | |
111 | - displayField: 'value', | |
112 | - valueField: 'key', | |
113 | - editable: false, | |
114 | - listConfig: { | |
115 | - getInnerTpl: function() { | |
116 | - return '<div data-qtip="{info}">{value} </div>'; | |
117 | - } | |
118 | - } | |
119 | - }); | |
120 | - | |
121 | - if (defaultVal != "") { | |
122 | - field.setValue(defaultVal); | |
123 | - } | |
124 | - }, | |
125 | - | |
126 | - addBooleanField: function(label, index, defaultVal) { | |
127 | - var field = this.fieldsForm.add({ | |
128 | - xtype: 'checkbox', | |
129 | - name: 'arg' + index, | |
130 | - boxLabel: label, | |
131 | - inputValue: '1', | |
132 | - uncheckedValue: '0' | |
133 | - }); | |
134 | - | |
135 | - if (defaultVal != "") { | |
136 | - field.setValue(defaultVal != '0'); | |
137 | - } | |
138 | - }, | |
139 | - | |
140 | - addStringField: function(label, index, defaultVal) { | |
141 | - var field = this.fieldsForm.add({ | |
142 | - xtype: 'textfield', | |
143 | - name: 'arg' + index, | |
144 | - fieldLabel: label | |
145 | - }); | |
146 | - | |
147 | - if (defaultVal != "") { | |
148 | - field.setValue(defaultVal); | |
149 | - } | |
150 | - }, | |
151 | - | |
152 | - init : function(config) { | |
153 | - this.fieldsForm = Ext.create('Ext.form.Panel', { | |
154 | - layout: { | |
155 | - type: 'vbox', | |
156 | - pack: 'start', | |
157 | - align: 'stretch', | |
158 | - defaultMargins: {top: 5, right: 5, bottom: 0, left: 5} | |
159 | - } | |
160 | - }); | |
161 | - | |
162 | - var myConf = { | |
163 | - layout: 'fit', | |
164 | - title: 'Function arguments', | |
165 | - modal: true, | |
166 | - closeAction: 'hide', | |
167 | - width: 300, | |
168 | - height: 200, | |
169 | - items: [ | |
170 | - this.fieldsForm | |
171 | - ], | |
172 | - buttons: [ | |
173 | - { | |
174 | - text: 'Apply', | |
175 | - scope : this, | |
176 | - handler: function(bt,event) { | |
177 | - if (this.applyCallback) | |
178 | - this.applyCallback(this.fieldsForm.getValues()); | |
179 | - this.close(); | |
180 | - }, | |
181 | - }, | |
182 | - { | |
183 | - text: 'Cancel', | |
184 | - scope : this, | |
185 | - handler: function(bt,event) { | |
186 | - this.close(); | |
187 | - } | |
188 | - } | |
189 | - ] | |
190 | - }; | |
191 | - | |
192 | - Ext.apply(this, Ext.apply(arguments, myConf)); | |
193 | - } | |
194 | -}); | |
195 | - | |
196 | - | |
197 | - | |
198 | 19 | Ext.define('amdaUI.CalculatorUI', { |
199 | 20 | extend: 'Ext.util.Observable', |
200 | 21 | |
201 | 22 | requires: [ |
23 | + 'amdaUI.PromptArgsWin', | |
202 | 24 | 'amdaModel.Constant', |
203 | 25 | 'amdaModel.Function', |
204 | - 'amdaUI.PromptArgsWin' | |
205 | 26 | ], |
206 | 27 | |
207 | 28 | alias: 'plugin.calculator', |
... | ... | @@ -387,6 +208,7 @@ Ext.define('amdaUI.CalculatorUI', { |
387 | 208 | this.processFormula(sel, currentBtn, params, afterParamsText); |
388 | 209 | } |
389 | 210 | }, this);*/ |
211 | + this.promptArgsWin.setStroreList(amdaUI.CalculatorUI.argslistStore); | |
390 | 212 | this.promptArgsWin.promptArgs(currentBtn.initialConfig.prompts, function (values) { |
391 | 213 | var afterParamsText = ''; |
392 | 214 | Ext.Object.each(values, function(key, value) { | ... | ... |
js/app/views/CatalogUI.js
... | ... | @@ -18,7 +18,9 @@ Ext.define('amdaUI.CatalogUI', { |
18 | 18 | 'Ext.ux.grid.filter.NumericFilter', |
19 | 19 | 'Ext.ux.grid.filter.StringFilter', |
20 | 20 | 'Ext.grid.plugin.BufferedRenderer', |
21 | - 'amdaUI.StatisticalPlug' | |
21 | + 'amdaUI.StatisticalPlug', | |
22 | + 'amdaUI.PromptArgsWin', | |
23 | + 'amdaModel.TTCatConfig' | |
22 | 24 | ], |
23 | 25 | |
24 | 26 | isCatalog: true, |
... | ... | @@ -121,6 +123,17 @@ Ext.define('amdaUI.CatalogUI', { |
121 | 123 | this.object.set('nbIntervals', this.TTGrid.getStore().getTotalCount()); |
122 | 124 | this.formPanel.getForm().findField('nbIntervals').setValue(this.object.get('nbIntervals')); |
123 | 125 | }, |
126 | + addColumn: function () { | |
127 | + var promptArgsWin = Ext.create('amdaUI.PromptArgsWin', {}); | |
128 | + promptArgsWin.setStroreList(amdaModel.TTCatConfig.catalog.storeList); | |
129 | + promptArgsWin.promptArgs(amdaModel.TTCatConfig, function (values) { | |
130 | + | |
131 | + Ext.Object.each(values, function(key, value) { | |
132 | + console.log(key); | |
133 | + console.log(value); | |
134 | + }); | |
135 | + }, this); | |
136 | + }, | |
124 | 137 | generateTT: function () { |
125 | 138 | if (this.fclose()) { |
126 | 139 | Ext.Msg.confirm('Generate TT', 'Current Catalog has been modified.\nDo you want to save it to include these changes in the generated Time Table ?', |
... | ... | @@ -638,6 +651,7 @@ Ext.define('amdaUI.CatalogUI', { |
638 | 651 | //Statistical plugin |
639 | 652 | me.fireEvent("refresh"); |
640 | 653 | }, |
654 | + | |
641 | 655 | |
642 | 656 | /** |
643 | 657 | * load object catalog into this view |
... | ... | @@ -1022,6 +1036,12 @@ Ext.define('amdaUI.CatalogUI', { |
1022 | 1036 | this.TTGrid.getStore().clearFilter(true); |
1023 | 1037 | this.TTGrid.filters.clearFilters(); |
1024 | 1038 | } |
1039 | + },{ | |
1040 | + text: 'Add Column', | |
1041 | + scope: this, | |
1042 | + handler: function () { | |
1043 | + this.addColumn(); | |
1044 | + } | |
1025 | 1045 | }] |
1026 | 1046 | }] |
1027 | 1047 | }); |
... | ... | @@ -1220,7 +1240,17 @@ Ext.define('amdaUI.CatalogUI', { |
1220 | 1240 | handler: function () { |
1221 | 1241 | this.generateTT(this.object.get('id')); |
1222 | 1242 | } |
1223 | - }]}, | |
1243 | + },{ | |
1244 | + xtype: 'button', | |
1245 | + text: 'Add Column', | |
1246 | + scope: this, | |
1247 | + //dock: 'bottom', | |
1248 | + //ui: 'footer', | |
1249 | + handler: function () { | |
1250 | + this.addColumn(); | |
1251 | + } | |
1252 | + } | |
1253 | + ]}, | |
1224 | 1254 | ], |
1225 | 1255 | |
1226 | 1256 | }, | ... | ... |
... | ... | @@ -0,0 +1,187 @@ |
1 | +/* | |
2 | + * To change this license header, choose License Headers in Project Properties. | |
3 | + * To change this template file, choose Tools | Templates | |
4 | + * and open the template in the editor. | |
5 | + */ | |
6 | + | |
7 | +Ext.define('amdaUI.PromptArgsWin', { | |
8 | + extend: 'Ext.window.Window', | |
9 | + | |
10 | + fieldsForm: null, | |
11 | + applyCallback: null, | |
12 | + argslistStore: null, | |
13 | + | |
14 | + constructor: function(config) { | |
15 | + this.init(config); | |
16 | + this.callParent(arguments); | |
17 | + }, | |
18 | + setStroreList:function(storeList){ | |
19 | + this.argslistStore = storeList; | |
20 | + }, | |
21 | + | |
22 | + promptArgs : function(prompts, fn, scope) { | |
23 | + | |
24 | + var me = this; | |
25 | + if (fn) | |
26 | + this.applyCallback = Ext.Function.bind(fn, scope); | |
27 | + else | |
28 | + this.applyCallback = null; | |
29 | + this.fieldsForm.removeAll(); | |
30 | + prompts.each(function(promptObj, index) { | |
31 | + switch (promptObj.get('type')) { | |
32 | + case 'float': | |
33 | + me.addFloatField(promptObj.get('prompt'), index, promptObj.get('default')); | |
34 | + break; | |
35 | + case 'list': | |
36 | + me.addComboField(promptObj.get('prompt'), promptObj.get('subtype'), index, promptObj.get('default')); | |
37 | + break; | |
38 | + case 'boolean': | |
39 | + me.addBooleanField(promptObj.get('prompt'), index, promptObj.get('default')); | |
40 | + break; | |
41 | + case 'string': | |
42 | + me.addStringField(promptObj.get('prompt'), index, promptObj.get('default')); | |
43 | + break; | |
44 | + default: | |
45 | + console.log('Unknown arg type: ' + promptObj.get('type')); | |
46 | + break; | |
47 | + } | |
48 | + }); | |
49 | + this.show(); | |
50 | + }, | |
51 | + | |
52 | + addFloatField: function(label, index, defaultVal) { | |
53 | + var field = this.fieldsForm.add({ | |
54 | + xtype: 'numberfield', | |
55 | + name: 'arg' + index, | |
56 | + fieldLabel: label, | |
57 | + decimalPrecision : 20, | |
58 | + allowBlank: false, | |
59 | + hideTrigger: true, | |
60 | + keyNavEnabled: false, | |
61 | + mouseWheelEnabled: false | |
62 | + }); | |
63 | + if (defaultVal != "") { | |
64 | + defaultVal = parseFloat(defaultVal); | |
65 | + if (!isNaN(defaultVal)) { | |
66 | + field.setValue(defaultVal); | |
67 | + } | |
68 | + } | |
69 | + }, | |
70 | + | |
71 | + addComboField: function(label, listtype, index, defaultVal, argslistStore) { | |
72 | + //var argslistStore = amdaUI.CalculatorUI.argslistStore; | |
73 | + if (!this.argslistStore) { | |
74 | + return; | |
75 | + } | |
76 | + | |
77 | + var valuesStore = null; | |
78 | + this.argslistStore.each(function(arglist) { | |
79 | + if (arglist.get('id') == listtype) { | |
80 | + valuesStore = arglist.valuesStore; | |
81 | + } | |
82 | + }); | |
83 | + if (!valuesStore) { | |
84 | + return; | |
85 | + } | |
86 | + | |
87 | + | |
88 | + var listData = []; | |
89 | + valuesStore.each(function (item) { | |
90 | + listData.push({'key': item.get('key'), 'value': item.get('value'), 'info': item.get('info')}); | |
91 | + }); | |
92 | + | |
93 | + var comboStore = Ext.create('Ext.data.Store', { | |
94 | + fields: ['key', 'value', 'info'], | |
95 | + data : listData | |
96 | + }); | |
97 | + | |
98 | + var field = this.fieldsForm.add({ | |
99 | + xtype: 'combo', | |
100 | + name: 'arg' + index, | |
101 | + fieldLabel: label, | |
102 | + store: comboStore, | |
103 | + queryMode: 'local', | |
104 | + displayField: 'value', | |
105 | + valueField: 'key', | |
106 | + editable: false, | |
107 | + listConfig: { | |
108 | + getInnerTpl: function() { | |
109 | + return '<div data-qtip="{info}">{value} </div>'; | |
110 | + } | |
111 | + } | |
112 | + }); | |
113 | + | |
114 | + if (defaultVal != "") { | |
115 | + field.setValue(defaultVal); | |
116 | + } | |
117 | + }, | |
118 | + | |
119 | + addBooleanField: function(label, index, defaultVal) { | |
120 | + var field = this.fieldsForm.add({ | |
121 | + xtype: 'checkbox', | |
122 | + name: 'arg' + index, | |
123 | + boxLabel: label, | |
124 | + inputValue: '1', | |
125 | + uncheckedValue: '0' | |
126 | + }); | |
127 | + | |
128 | + if (defaultVal != "") { | |
129 | + field.setValue(defaultVal != '0'); | |
130 | + } | |
131 | + }, | |
132 | + | |
133 | + addStringField: function(label, index, defaultVal) { | |
134 | + var field = this.fieldsForm.add({ | |
135 | + xtype: 'textfield', | |
136 | + name: 'arg' + index, | |
137 | + fieldLabel: label | |
138 | + }); | |
139 | + | |
140 | + if (defaultVal != "") { | |
141 | + field.setValue(defaultVal); | |
142 | + } | |
143 | + }, | |
144 | + | |
145 | + init : function(config) { | |
146 | + this.fieldsForm = Ext.create('Ext.form.Panel', { | |
147 | + layout: { | |
148 | + type: 'vbox', | |
149 | + pack: 'start', | |
150 | + align: 'stretch', | |
151 | + defaultMargins: {top: 5, right: 5, bottom: 0, left: 5} | |
152 | + } | |
153 | + }); | |
154 | + | |
155 | + var myConf = { | |
156 | + layout: 'fit', | |
157 | + title: 'Function arguments', | |
158 | + modal: true, | |
159 | + closeAction: 'hide', | |
160 | + width: 300, | |
161 | + height: 200, | |
162 | + items: [ | |
163 | + this.fieldsForm | |
164 | + ], | |
165 | + buttons: [ | |
166 | + { | |
167 | + text: 'Apply', | |
168 | + scope : this, | |
169 | + handler: function(bt,event) { | |
170 | + if (this.applyCallback) | |
171 | + this.applyCallback(this.fieldsForm.getValues()); | |
172 | + this.close(); | |
173 | + }, | |
174 | + }, | |
175 | + { | |
176 | + text: 'Cancel', | |
177 | + scope : this, | |
178 | + handler: function(bt,event) { | |
179 | + this.close(); | |
180 | + } | |
181 | + } | |
182 | + ] | |
183 | + }; | |
184 | + Ext.apply(this, Ext.apply(arguments, myConf)); | |
185 | + } | |
186 | +}); | |
187 | + | ... | ... |