rails_db_admin 2.0.2 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/rails_db_admin/erp_app/desktop/base_controller.rb +3 -0
- data/lib/rails_db_admin/version.rb +1 -1
- data/public/javascripts/erp_app/desktop/applications/rails_db_admin/database_combo.js +4 -3
- data/public/javascripts/erp_app/desktop/applications/rails_db_admin/module.js +401 -405
- data/public/javascripts/erp_app/desktop/applications/rails_db_admin/query_panel.js +196 -190
- data/public/javascripts/erp_app/desktop/applications/rails_db_admin/readonly_table_data_grid.js +2 -5
- data/spec/controllers/rails_db_admin/erp_app/desktop/base_controller_spec.rb +50 -70
- data/spec/controllers/rails_db_admin/erp_app/desktop/queries_controller_spec.rb +15 -17
- metadata +7 -7
@@ -1,424 +1,420 @@
|
|
1
|
-
Ext.define("Compass.ErpApp.Desktop.Applications.RailsDbAdmin",{
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
1
|
+
Ext.define("Compass.ErpApp.Desktop.Applications.RailsDbAdmin", {
|
2
|
+
extend:"Ext.ux.desktop.Module",
|
3
|
+
id:'rails_db_admin-win',
|
4
|
+
|
5
|
+
queriesTreePanel:function () {
|
6
|
+
return this.accordion.down('.railsdbadmin_queriestreemenu');
|
7
|
+
},
|
8
|
+
|
9
|
+
setWindowStatus:function (status) {
|
10
|
+
this.window.setStatus(status);
|
11
|
+
},
|
12
|
+
|
13
|
+
clearWindowStatus:function () {
|
14
|
+
this.window.clearStatus();
|
15
|
+
},
|
16
|
+
|
17
|
+
getTableData:function (table) {
|
18
|
+
var self = this;
|
19
|
+
|
20
|
+
var grid = Ext.create('Compass.ErpApp.Shared.DynamicEditableGridLoaderPanel', {
|
21
|
+
title:table,
|
22
|
+
setupUrl:'/rails_db_admin/erp_app/desktop/base/setup_table_grid/' + table,
|
23
|
+
dataUrl:'/rails_db_admin/erp_app/desktop/base/table_data/' + table,
|
24
|
+
editable:true,
|
25
|
+
page:true,
|
26
|
+
pageSize:25,
|
27
|
+
displayMsg:'Displaying {0} - {1} of {2}',
|
28
|
+
emptyMsg:'Empty',
|
29
|
+
loadErrorMessage:'Tables Without Ids Can Not Be Edited',
|
30
|
+
closable:true,
|
31
|
+
params:{
|
32
|
+
database:self.getDatabase()
|
33
|
+
},
|
34
|
+
grid_listeners:{
|
35
|
+
validateedit:{
|
36
|
+
fn:function (editor, e) {
|
37
|
+
this.store.proxy.setOldModel(e.record);
|
38
|
+
}
|
39
|
+
}
|
40
|
+
},
|
41
|
+
proxy:{
|
42
|
+
type:'rest',
|
43
|
+
url:'/rails_db_admin/erp_app/desktop/base/table_data/' + table,
|
44
|
+
//private var to store the previous model in an
|
45
|
+
//update operation
|
46
|
+
oldModel:null,
|
47
|
+
setOldModel:function (old_model) {
|
48
|
+
this.oldModel = old_model.copy();
|
49
|
+
},
|
50
|
+
update:function (operation, callback, scope) {
|
51
|
+
operation.records.push(this.oldModel);
|
52
|
+
Ext.data.proxy.Rest.superclass.update.call(this, operation, callback, scope);
|
53
|
+
},
|
54
|
+
reader:{
|
55
|
+
type:'json',
|
56
|
+
successProperty:'success',
|
57
|
+
root:'data',
|
58
|
+
messageProperty:'message'
|
59
|
+
},
|
60
|
+
writer:{
|
61
|
+
type:'json',
|
62
|
+
writeAllFields:true,
|
63
|
+
root:'data'
|
64
|
+
},
|
65
|
+
listeners:{
|
66
|
+
exception:function (proxy, response, operation) {
|
67
|
+
var msg;
|
68
|
+
if (operation.getError() === undefined) {
|
69
|
+
var responseObject = Ext.JSON.decode(response.responseText);
|
70
|
+
msg = responseObject.exception;
|
71
|
+
} else {
|
72
|
+
msg = operation.getError();
|
73
|
+
}
|
74
|
+
Ext.MessageBox.show({
|
75
|
+
title:'REMOTE EXCEPTION',
|
76
|
+
msg:msg,
|
77
|
+
icon:Ext.MessageBox.ERROR,
|
78
|
+
buttons:Ext.Msg.OK
|
79
|
+
});
|
80
|
+
}
|
81
|
+
}
|
82
|
+
}
|
83
|
+
});
|
84
|
+
|
85
|
+
this.container.add(grid);
|
86
|
+
this.container.setActiveTab(this.container.items.length - 1);
|
87
|
+
},
|
88
|
+
|
89
|
+
selectTopFifty:function (table) {
|
90
|
+
this.setWindowStatus('Selecting Top 50 from ' + table + '...');
|
91
|
+
var self = this;
|
92
|
+
|
93
|
+
Ext.Ajax.request({
|
94
|
+
url:'/rails_db_admin/erp_app/desktop/queries/select_top_fifty/' + table,
|
95
|
+
timeout:60000,
|
96
|
+
params:{
|
97
|
+
database:self.getDatabase()
|
98
|
+
},
|
99
|
+
success:function (responseObject) {
|
100
|
+
self.clearWindowStatus();
|
101
|
+
var response = Ext.decode(responseObject.responseText);
|
102
|
+
var sql = response.sql;
|
103
|
+
var columns = response.columns;
|
104
|
+
var fields = response.fields;
|
105
|
+
var data = response.data;
|
106
|
+
|
107
|
+
var readOnlyDataGrid = Ext.create('Compass.ErpApp.Desktop.Applications.RailsDbAdmin.ReadOnlyTableDataGrid', {
|
108
|
+
region:'center',
|
109
|
+
columns:columns,
|
110
|
+
fields:fields,
|
111
|
+
data:data
|
112
|
+
});
|
113
|
+
|
114
|
+
var queryPanel = Ext.create('Compass.ErpApp.Desktop.Applications.RailsDbAdmin.QueryPanel', {
|
115
|
+
module:self,
|
116
|
+
sqlQuery:sql,
|
117
|
+
southRegion:readOnlyDataGrid
|
118
|
+
});
|
119
|
+
|
120
|
+
self.container.add(queryPanel);
|
121
|
+
self.container.setActiveTab(queryPanel.id);
|
122
|
+
|
123
|
+
//queryPanel.gridContainer.add(readOnlyDataGrid);
|
124
|
+
//queryPanel.gridContainer.getLayout().setActiveItem(0);
|
125
|
+
},
|
126
|
+
failure:function () {
|
127
|
+
self.clearWindowStatus();
|
128
|
+
Ext.Msg.alert('Status', 'Error loading grid');
|
129
|
+
}
|
130
|
+
});
|
131
|
+
},
|
132
|
+
|
133
|
+
addNewQueryTab:function () {
|
134
|
+
this.container.add({
|
135
|
+
xtype:'railsdbadmin_querypanel',
|
136
|
+
module:this
|
137
|
+
});
|
138
|
+
this.container.setActiveTab(this.container.items.length - 1);
|
139
|
+
},
|
140
|
+
|
141
|
+
connectToDatatbase:function () {
|
142
|
+
var database = this.getDatabase();
|
143
|
+
var tablestreePanelStore = this.accordion.down('.railsdbadmin_tablestreemenu').store;
|
144
|
+
var queriesTreePanelStore = this.accordion.down('.railsdbadmin_queriestreemenu').store;
|
145
|
+
|
146
|
+
tablestreePanelStore.setProxy({
|
147
|
+
type:'ajax',
|
148
|
+
url:'/rails_db_admin/erp_app/desktop/base/tables',
|
149
|
+
extraParams:{
|
150
|
+
database:database
|
74
151
|
}
|
75
|
-
Ext.MessageBox.show({
|
76
|
-
title: 'REMOTE EXCEPTION',
|
77
|
-
msg: msg,
|
78
|
-
icon: Ext.MessageBox.ERROR,
|
79
|
-
buttons: Ext.Msg.OK
|
80
|
-
});
|
81
|
-
}
|
82
|
-
}
|
83
|
-
}
|
84
|
-
});
|
85
|
-
|
86
|
-
this.container.add(grid);
|
87
|
-
this.container.setActiveTab(this.container.items.length - 1);
|
88
|
-
},
|
89
|
-
|
90
|
-
selectTopFifty : function(table){
|
91
|
-
this.setWindowStatus('Selecting Top 50 from '+ table +'...');
|
92
|
-
var self = this;
|
93
|
-
|
94
|
-
Ext.Ajax.request({
|
95
|
-
url: '/rails_db_admin/erp_app/desktop/queries/select_top_fifty/' + table,
|
96
|
-
timeout:60000,
|
97
|
-
params:{
|
98
|
-
database: self.getDatabase()
|
99
|
-
},
|
100
|
-
success: function(responseObject) {
|
101
|
-
self.clearWindowStatus();
|
102
|
-
var response = Ext.decode(responseObject.responseText);
|
103
|
-
var sql = response.sql;
|
104
|
-
var columns = response.columns;
|
105
|
-
var fields = response.fields;
|
106
|
-
var data = response.data;
|
107
|
-
|
108
|
-
var readOnlyDataGrid = new Compass.ErpApp.Desktop.Applications.RailsDbAdmin.ReadOnlyTableDataGrid({
|
109
|
-
columns:columns,
|
110
|
-
fields:fields,
|
111
|
-
data:data
|
112
152
|
});
|
153
|
+
tablestreePanelStore.load();
|
113
154
|
|
114
|
-
|
115
|
-
|
116
|
-
|
155
|
+
queriesTreePanelStore.setProxy({
|
156
|
+
type:'ajax',
|
157
|
+
url:'/rails_db_admin/erp_app/desktop/queries/saved_queries_tree',
|
158
|
+
extraParams:{
|
159
|
+
database:database
|
160
|
+
}
|
117
161
|
});
|
162
|
+
queriesTreePanelStore.load();
|
163
|
+
},
|
164
|
+
|
165
|
+
getDatabase:function () {
|
166
|
+
var database = Ext.getCmp('databaseCombo').getValue();
|
167
|
+
return database;
|
168
|
+
},
|
169
|
+
|
170
|
+
deleteQuery:function (queryName) {
|
171
|
+
var self = this;
|
172
|
+
Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete this query?', function (btn) {
|
173
|
+
if (btn === 'no') {
|
174
|
+
return false;
|
175
|
+
}
|
176
|
+
else if (btn === 'yes') {
|
177
|
+
self.setWindowStatus('Deleting ' + queryName + '...');
|
178
|
+
var database = self.getDatabase();
|
179
|
+
Ext.Ajax.request({
|
180
|
+
url:'/rails_db_admin/erp_app/desktop/queries/delete_query/',
|
181
|
+
params:{
|
182
|
+
database:database,
|
183
|
+
query_name:queryName
|
184
|
+
},
|
185
|
+
success:function (responseObject) {
|
186
|
+
self.clearWindowStatus();
|
187
|
+
var response = Ext.decode(responseObject.responseText);
|
188
|
+
if (response.success) {
|
189
|
+
Ext.Msg.alert('Error', 'Query deleted');
|
190
|
+
var queriesTreePanelStore = self.accordion.down('.railsdbadmin_queriestreemenu').store;
|
191
|
+
queriesTreePanelStore.setProxy({
|
192
|
+
type:'ajax',
|
193
|
+
url:'/rails_db_admin/erp_app/desktop/queries/saved_queries_tree',
|
194
|
+
extraParams:{
|
195
|
+
database:database
|
196
|
+
}
|
197
|
+
});
|
198
|
+
queriesTreePanelStore.load();
|
199
|
+
}
|
200
|
+
else {
|
201
|
+
Ext.Msg.alert('Error', response.exception);
|
202
|
+
}
|
203
|
+
|
204
|
+
},
|
205
|
+
failure:function () {
|
206
|
+
self.clearWindowStatus();
|
207
|
+
Ext.Msg.alert('Status', 'Error deleting query');
|
208
|
+
}
|
209
|
+
});
|
210
|
+
}
|
211
|
+
});
|
212
|
+
},
|
118
213
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
queryPanel.gridContainer.getLayout().setActiveItem(0);
|
124
|
-
},
|
125
|
-
failure: function() {
|
126
|
-
self.clearWindowStatus();
|
127
|
-
Ext.Msg.alert('Status', 'Error loading grid');
|
128
|
-
}
|
129
|
-
});
|
130
|
-
},
|
131
|
-
|
132
|
-
addNewQueryTab : function(){
|
133
|
-
this.container.add({
|
134
|
-
xtype:'railsdbadmin_querypanel',
|
135
|
-
module:this
|
136
|
-
});
|
137
|
-
this.container.setActiveTab(this.container.items.length - 1);
|
138
|
-
},
|
139
|
-
|
140
|
-
connectToDatatbase : function(){
|
141
|
-
var database = this.getDatabase();
|
142
|
-
var tablestreePanelStore = this.accordion.query('.railsdbadmin_tablestreemenu')[0].store;
|
143
|
-
var queriesTreePanelStore = this.accordion.query('.railsdbadmin_queriestreemenu')[0].store;
|
144
|
-
|
145
|
-
tablestreePanelStore.setProxy({
|
146
|
-
type: 'ajax',
|
147
|
-
url: '/rails_db_admin/erp_app/desktop/base/tables',
|
148
|
-
extraParams:{
|
149
|
-
database:database
|
150
|
-
}
|
151
|
-
});
|
152
|
-
tablestreePanelStore.load();
|
153
|
-
|
154
|
-
queriesTreePanelStore.setProxy({
|
155
|
-
type: 'ajax',
|
156
|
-
url: '/rails_db_admin/erp_app/desktop/queries/saved_queries_tree',
|
157
|
-
extraParams:{
|
158
|
-
database:database
|
159
|
-
}
|
160
|
-
});
|
161
|
-
queriesTreePanelStore.load();
|
162
|
-
},
|
163
|
-
|
164
|
-
getDatabase : function(){
|
165
|
-
var database = Ext.getCmp('databaseCombo').getValue();
|
166
|
-
return database;
|
167
|
-
},
|
168
|
-
|
169
|
-
deleteQuery : function(queryName){
|
170
|
-
var self = this;
|
171
|
-
Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete this query?', function(btn){
|
172
|
-
if(btn === 'no'){
|
173
|
-
return false;
|
174
|
-
}
|
175
|
-
else
|
176
|
-
if(btn === 'yes')
|
177
|
-
{
|
178
|
-
self.setWindowStatus('Deleting '+ queryName +'...');
|
179
|
-
var database = self.getDatabase();
|
214
|
+
displayAndExecuteQuery:function (queryName) {
|
215
|
+
this.setWindowStatus('Executing ' + queryName + '...');
|
216
|
+
var self = this;
|
217
|
+
var database = this.getDatabase();
|
180
218
|
Ext.Ajax.request({
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
219
|
+
url:'/rails_db_admin/erp_app/desktop/queries/open_and_execute_query/',
|
220
|
+
params:{
|
221
|
+
database:database,
|
222
|
+
query_name:queryName
|
223
|
+
},
|
224
|
+
success:function (responseObject) {
|
225
|
+
var response = Ext.decode(responseObject.responseText);
|
226
|
+
var query = response.query;
|
227
|
+
|
228
|
+
var queryPanel = null;
|
229
|
+
|
230
|
+
if (response.success) {
|
231
|
+
self.clearWindowStatus();
|
232
|
+
var columns = response.columns;
|
233
|
+
var fields = response.fields;
|
234
|
+
var data = response.data;
|
235
|
+
|
236
|
+
var readOnlyDataGrid = Ext.create('Compass.ErpApp.Desktop.Applications.RailsDbAdmin.ReadOnlyTableDataGrid', {
|
237
|
+
region:'center',
|
238
|
+
columns:columns,
|
239
|
+
fields:fields,
|
240
|
+
data:data
|
241
|
+
});
|
242
|
+
|
243
|
+
var queryPanel = Ext.create('Compass.ErpApp.Desktop.Applications.RailsDbAdmin.QueryPanel', {
|
244
|
+
module:self,
|
245
|
+
sqlQuery:query,
|
246
|
+
southRegion:readOnlyDataGrid
|
247
|
+
});
|
248
|
+
|
249
|
+
self.container.add(queryPanel);
|
250
|
+
self.container.setActiveTab(queryPanel.id);
|
198
251
|
}
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
252
|
+
else {
|
253
|
+
Ext.Msg.alert('Error', response.exception);
|
254
|
+
queryPanel = Ext.create('Compass.ErpApp.Desktop.Applications.RailsDbAdmin.QueryPanel', {
|
255
|
+
module:self,
|
256
|
+
sqlQuery:query
|
257
|
+
});
|
258
|
+
|
259
|
+
self.container.add(queryPanel);
|
260
|
+
self.container.setActiveTab(self.container.items.length - 1);
|
261
|
+
}
|
262
|
+
|
263
|
+
},
|
264
|
+
failure:function () {
|
265
|
+
self.clearWindowStatus();
|
266
|
+
Ext.Msg.alert('Status', 'Error loading query');
|
205
267
|
}
|
268
|
+
});
|
269
|
+
},
|
270
|
+
|
271
|
+
init:function () {
|
272
|
+
this.launcher = {
|
273
|
+
text:'RailsDbAdmin',
|
274
|
+
iconCls:'icon-rails_db_admin',
|
275
|
+
handler:this.createWindow,
|
276
|
+
scope:this
|
277
|
+
};
|
278
|
+
},
|
279
|
+
|
280
|
+
displayQuery:function (queryName) {
|
281
|
+
this.setWindowStatus('Retrieving ' + queryName + '...');
|
282
|
+
var self = this;
|
283
|
+
var database = this.getDatabase();
|
284
|
+
Ext.Ajax.request({
|
285
|
+
url:'/rails_db_admin/erp_app/desktop/queries/open_query/',
|
286
|
+
params:{
|
287
|
+
database:database,
|
288
|
+
query_name:queryName
|
289
|
+
},
|
290
|
+
success:function (responseObject) {
|
291
|
+
var response = Ext.decode(responseObject.responseText);
|
292
|
+
var query = response.query;
|
293
|
+
|
294
|
+
var queryPanel = null;
|
295
|
+
|
296
|
+
if (response.success) {
|
297
|
+
self.clearWindowStatus();
|
298
|
+
|
299
|
+
queryPanel = Ext.create('Compass.ErpApp.Desktop.Applications.RailsDbAdmin.QueryPanel', {
|
300
|
+
module:self,
|
301
|
+
sqlQuery:query
|
302
|
+
});
|
303
|
+
|
304
|
+
self.container.add(queryPanel);
|
305
|
+
self.container.setActiveTab(self.container.items.length - 1);
|
306
|
+
}
|
307
|
+
else {
|
308
|
+
Ext.Msg.alert('Error', response.exception);
|
309
|
+
queryPanel = Ext.create('Compass.ErpApp.Desktop.Applications.RailsDbAdmin.QueryPanel', {
|
310
|
+
module:self,
|
311
|
+
sqlQuery:query
|
312
|
+
});
|
313
|
+
|
314
|
+
self.container.add(queryPanel);
|
315
|
+
self.container.setActiveTab(self.container.items.length - 1);
|
316
|
+
}
|
206
317
|
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
318
|
+
},
|
319
|
+
failure:function () {
|
320
|
+
self.clearWindowStatus();
|
321
|
+
Ext.Msg.alert('Status', 'Error loading query');
|
322
|
+
}
|
212
323
|
});
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
},
|
227
|
-
success: function(responseObject) {
|
228
|
-
var response = Ext.decode(responseObject.responseText);
|
229
|
-
var query = response.query;
|
230
|
-
|
231
|
-
var queryPanel = null;
|
232
|
-
|
233
|
-
if(response.success)
|
234
|
-
{
|
235
|
-
self.clearWindowStatus();
|
236
|
-
var columns = response.columns;
|
237
|
-
var fields = response.fields;
|
238
|
-
var data = response.data;
|
239
|
-
|
240
|
-
var readOnlyDataGrid = new Compass.ErpApp.Desktop.Applications.RailsDbAdmin.ReadOnlyTableDataGrid({
|
241
|
-
columns:columns,
|
242
|
-
fields:fields,
|
243
|
-
data:data
|
244
|
-
});
|
245
|
-
|
246
|
-
queryPanel = new Compass.ErpApp.Desktop.Applications.RailsDbAdmin.QueryPanel({
|
247
|
-
module:self,
|
248
|
-
sqlQuery:query
|
249
|
-
});
|
250
|
-
|
251
|
-
self.container.add(queryPanel);
|
252
|
-
self.container.setActiveTab(self.container.items.length - 1);
|
253
|
-
|
254
|
-
queryPanel.gridContainer.add(readOnlyDataGrid);
|
255
|
-
queryPanel.gridContainer.getLayout().setActiveItem(0);
|
256
|
-
}
|
257
|
-
else
|
258
|
-
{
|
259
|
-
Ext.Msg.alert('Error', response.exception);
|
260
|
-
queryPanel = new Compass.ErpApp.Desktop.Applications.RailsDbAdmin.QueryPanel({
|
261
|
-
module:self,
|
262
|
-
sqlQuery:query
|
263
|
-
});
|
264
|
-
|
265
|
-
self.container.add(queryPanel);
|
266
|
-
self.container.setActiveTab(self.container.items.length - 1);
|
267
|
-
}
|
324
|
+
},
|
325
|
+
|
326
|
+
createWindow:function () {
|
327
|
+
var self = this;
|
328
|
+
var desktop = this.app.getDesktop();
|
329
|
+
var win = desktop.getWindow('rails_db_admin');
|
330
|
+
if (!win) {
|
331
|
+
this.container = Ext.create('Ext.tab.Panel', {
|
332
|
+
region:'center',
|
333
|
+
margins:'0 0 0 0',
|
334
|
+
border:false,
|
335
|
+
minsize:300
|
336
|
+
});
|
268
337
|
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
}
|
314
|
-
else
|
315
|
-
{
|
316
|
-
Ext.Msg.alert('Error', response.exception);
|
317
|
-
queryPanel = new Compass.ErpApp.Desktop.Applications.RailsDbAdmin.QueryPanel({
|
318
|
-
module:self,
|
319
|
-
sqlQuery:query
|
320
|
-
});
|
321
|
-
|
322
|
-
self.container.add(queryPanel);
|
323
|
-
self.container.setActiveTab(self.container.items.length - 1);
|
324
|
-
}
|
338
|
+
this.accordion = Ext.create('Ext.panel.Panel', {
|
339
|
+
region:'west',
|
340
|
+
margins:'0 0 0 0',
|
341
|
+
cmargins:'0 0 0 0',
|
342
|
+
width:300,
|
343
|
+
collapsible:true,
|
344
|
+
layout:'accordion',
|
345
|
+
items:[
|
346
|
+
{
|
347
|
+
xtype:'railsdbadmin_tablestreemenu',
|
348
|
+
module:this
|
349
|
+
},
|
350
|
+
|
351
|
+
{
|
352
|
+
xtype:'railsdbadmin_queriestreemenu',
|
353
|
+
module:this
|
354
|
+
}
|
355
|
+
]
|
356
|
+
});
|
357
|
+
|
358
|
+
win = desktop.createWindow({
|
359
|
+
id:'rails_db_admin',
|
360
|
+
title:'RailsDBAdmin',
|
361
|
+
autoDestroy:true,
|
362
|
+
width:1200,
|
363
|
+
height:550,
|
364
|
+
iconCls:'icon-rails_db_admin',
|
365
|
+
shim:false,
|
366
|
+
animCollapse:false,
|
367
|
+
constrainHeader:true,
|
368
|
+
layout:'border',
|
369
|
+
tbar:{
|
370
|
+
items:[
|
371
|
+
{
|
372
|
+
text:'Database:'
|
373
|
+
},
|
374
|
+
{
|
375
|
+
xtype:'railsdbadmin_databasecombo',
|
376
|
+
module:self
|
377
|
+
}
|
378
|
+
]
|
379
|
+
},
|
380
|
+
items:[this.accordion, this.container]
|
381
|
+
});
|
325
382
|
|
326
|
-
|
327
|
-
failure: function() {
|
328
|
-
self.clearWindowStatus();
|
329
|
-
Ext.Msg.alert('Status', 'Error loading query');
|
330
|
-
}
|
331
|
-
});
|
332
|
-
},
|
333
|
-
|
334
|
-
createWindow : function(){
|
335
|
-
var self = this;
|
336
|
-
var desktop = this.app.getDesktop();
|
337
|
-
var win = desktop.getWindow('rails_db_admin');
|
338
|
-
if(!win){
|
339
|
-
this.container = new Ext.TabPanel({
|
340
|
-
region : 'center',
|
341
|
-
margins : '0 0 0 0',
|
342
|
-
minsize : 300
|
343
|
-
});
|
344
|
-
|
345
|
-
this.accordion = new Ext.Panel({
|
346
|
-
region : 'west',
|
347
|
-
margins : '0 0 0 0',
|
348
|
-
cmargins : '0 0 0 0',
|
349
|
-
width : 300,
|
350
|
-
collapsible: true,
|
351
|
-
layout: 'accordion',
|
352
|
-
items:[
|
353
|
-
{
|
354
|
-
xtype:'railsdbadmin_tablestreemenu',
|
355
|
-
module:this
|
356
|
-
},
|
357
|
-
|
358
|
-
{
|
359
|
-
xtype:'railsdbadmin_queriestreemenu',
|
360
|
-
module:this
|
383
|
+
this.window = win;
|
361
384
|
}
|
362
|
-
|
363
|
-
});
|
364
|
-
|
365
|
-
win = desktop.createWindow({
|
366
|
-
id: 'rails_db_admin',
|
367
|
-
title:'RailsDBAdmin',
|
368
|
-
autoDestroy:true,
|
369
|
-
width:1200,
|
370
|
-
height:550,
|
371
|
-
iconCls: 'icon-rails_db_admin',
|
372
|
-
shim:false,
|
373
|
-
animCollapse:false,
|
374
|
-
constrainHeader:true,
|
375
|
-
layout: 'border',
|
376
|
-
tbar:{
|
377
|
-
items:[
|
378
|
-
{
|
379
|
-
text:'Database:'
|
380
|
-
},
|
381
|
-
{
|
382
|
-
xtype:'railsdbadmin_databasecombo',
|
383
|
-
module: self
|
384
|
-
}
|
385
|
-
]
|
386
|
-
},
|
387
|
-
items:[this.accordion, this.container]
|
388
|
-
});
|
389
|
-
|
390
|
-
this.window = win;
|
385
|
+
win.show();
|
391
386
|
}
|
392
|
-
win.show();
|
393
|
-
}
|
394
387
|
});
|
395
388
|
|
396
|
-
Ext.define("Compass.ErpApp.Desktop.Applications.RailsDbAdmin.BooleanEditor",{
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
389
|
+
Ext.define("Compass.ErpApp.Desktop.Applications.RailsDbAdmin.BooleanEditor", {
|
390
|
+
extend:"Ext.form.ComboBox",
|
391
|
+
alias:'widget.booleancolumneditor',
|
392
|
+
initComponent:function () {
|
393
|
+
var trueFalseStore = Ext.create('Ext.data.ArrayStore', {
|
394
|
+
fields:['display', 'value'],
|
395
|
+
data:[
|
396
|
+
['False', '0'],
|
397
|
+
['True', '1']
|
398
|
+
]
|
399
|
+
});
|
400
|
+
|
401
|
+
this.store = trueFalseStore;
|
402
|
+
|
403
|
+
this.callParent(arguments);
|
404
|
+
},
|
405
|
+
constructor:function (config) {
|
406
|
+
config = Ext.apply({
|
407
|
+
valueField:'value',
|
408
|
+
displayField:'display',
|
409
|
+
triggerAction:'all',
|
410
|
+
forceSelection:true,
|
411
|
+
mode:'local'
|
412
|
+
}, config);
|
413
|
+
|
414
|
+
this.callParent([config]);
|
415
|
+
}
|
420
416
|
});
|
421
417
|
|
422
|
-
Compass.ErpApp.Desktop.Applications.RailsDbAdmin.renderBooleanColumn = function(v){
|
423
|
-
|
418
|
+
Compass.ErpApp.Desktop.Applications.RailsDbAdmin.renderBooleanColumn = function (v) {
|
419
|
+
return (v == 1) ? "True" : "False";
|
424
420
|
};
|