ruby-extjs 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,7 +6,7 @@
6
6
  Ext.define('Abstract.util.Controller', {
7
7
  extend: 'Ext.app.Controller',
8
8
  mixins: {
9
- controls: 'Abstract.controller.Util'
9
+ controls: 'Abstract.util.Util'
10
10
  },
11
11
 
12
12
  modulo : false,
@@ -0,0 +1,441 @@
1
+ Ext.define('Abstract.controller.Util', {
2
+ mixins: {
3
+ observable: 'Ext.util.Observable'
4
+ },
5
+
6
+ titleErro: 'Erro!',
7
+ avisoText: 'Aviso!',
8
+ saveFormText: 'Aguarde...',
9
+ delGridText: 'Deletando, Aguarde...',
10
+ delErroGrid: 'Selecione um Registro para Deletar!',
11
+ editErroGrid: 'Selecione um Registro para Editar!',
12
+ loadingGridText: 'Aguarde Carregando Dados...',
13
+ filteredText: 'Filtrar <span class="buttonFilter">*</span>',
14
+ filterText: 'Filtrar',
15
+ connectFalhaText: 'Comunica&ccedil;&atilde;o Ajax Perdida',
16
+ server_failure: 'Falha no Servidor Codigo de erro: ',
17
+ fieldsInvalidText: 'Campos com valores invalidos',
18
+ requiredsFieldsText: 'Existem campos obrigatorios...',
19
+
20
+ desejaDeletar: 'Deseja Deletar',
21
+ confirmText: 'Confirmar',
22
+
23
+ clearInterval: false,
24
+ storePai: false,
25
+ disabledCombo: 0,
26
+
27
+ /*reset*/
28
+ reset: function(button){
29
+ Ext.each(this.getForm().getForm().getFields().items, function(field){
30
+ if(field.isVisible()==true){
31
+ field.reset();
32
+ }
33
+ });
34
+ },
35
+
36
+ resetCombo: function(button){
37
+ var id = button.combo_id;
38
+ Ext.getCmp(id).reset();
39
+ button.setVisible(false);
40
+ },
41
+
42
+ resetFielter: function(button){
43
+ this.getFilterBtn().setText(this.filterText);
44
+ this.getList().store.proxy.extraParams = {
45
+ action: 'LIST'
46
+ };
47
+ this.getList().store.load();
48
+ this.getFilterWin().close();
49
+ },
50
+
51
+ /*button*/
52
+ btedit: function(button) {
53
+ if (this.getList().selModel.hasSelection()) {
54
+ var record = this.getList().getSelectionModel().getLastSelected();
55
+ this.edit(this.getList(), record);
56
+ }
57
+ else{
58
+ info(this.titleErro, this.editErroGrid);
59
+ return true;
60
+ }
61
+ },
62
+
63
+ btdel: function(button) {
64
+ var me = this;
65
+ if (me.getList().selModel.hasSelection()) {
66
+ var record = me.getList().getSelectionModel().getLastSelected();
67
+
68
+ if(me.deleteRecord){
69
+ var msg = me.desejaDeletar + ': ' + record.get(me.deleteRecord) + '?';
70
+ }
71
+ else{
72
+ var msg = me.desejaDeletar;
73
+ }
74
+
75
+ Ext.Msg.confirm(me.confirmText, msg, function(btn){
76
+ if(btn=='yes'){
77
+ me.del(me.getList(), record, button);
78
+ }
79
+ });
80
+ }
81
+ else{
82
+ info(me.titleErro, me.delErroGrid);
83
+ return true;
84
+ }
85
+ },
86
+
87
+ btfilter: function(button){
88
+ var me = this;
89
+ var win = me.getFilterWin();
90
+ if(!win) win = Ext.widget(me.filtermodulo);
91
+ win.show();
92
+ },
93
+
94
+ enableButton: function(comp){
95
+ var id = comp.button_id;
96
+ if(comp.getValue()!=null){
97
+ Ext.getCmp(id).setVisible(true);
98
+ }
99
+ else{
100
+ Ext.getCmp(id).setVisible(false);
101
+ }
102
+ },
103
+
104
+ gerarPdf: function(button){
105
+ var me = this;
106
+ window.open( me.modulo +'/pdf?'+
107
+ Ext.Object.toQueryString(me.getList().store.proxy.extraParams)
108
+ );
109
+ },
110
+
111
+ /*filter*/
112
+ filterSetFields: function(){
113
+ var me = this;
114
+ var p = me.getList().store.proxy.extraParams;
115
+ if(p.action=='FILTER'){
116
+ me.getFilterForm().getForm().setValues(p);
117
+ }
118
+ },
119
+
120
+ setFielter: function(button){
121
+ var me = this;
122
+ var form = me.getFilterForm().getValues();
123
+ Ext.each(me.getFilterForm().getForm().getFields().items, function(field){
124
+ if(field.xtype=='combobox'){
125
+ form[field.name+'_nome'] = field.getRawValue();
126
+ }
127
+ });
128
+ me.getList().store.proxy.extraParams = form;
129
+ me.getFilterBtn().setText(this.filteredText);
130
+ me.getList().store.load();
131
+ me.getFilterWin().close();
132
+ },
133
+
134
+ /*comboLoad && storeLoad*/
135
+ comboLoad: function(comp){
136
+ var me = this;
137
+ if(!comp.loadDisabled){
138
+ if(typeof comp.callback === 'function'){
139
+ comp.callback();
140
+ }
141
+
142
+ if(comp.store.getCount()==0){
143
+ //comp.store.load();
144
+ var callback = me.verifyCombo(comp);
145
+ comp.store.load({
146
+ callback: callback
147
+ });
148
+ }
149
+ }
150
+ },
151
+
152
+ getStoresDependes: function(){
153
+ var me = this;
154
+ if(me.storePai==true){
155
+ me.getStore('Combo'+me.id).load();
156
+ }
157
+ },
158
+
159
+ gridLoad: function(comp){
160
+ if(!comp.loadDisabled){
161
+ setTimeout(function(){
162
+ comp.store.load();
163
+ },100);
164
+ }
165
+ },
166
+
167
+ verifyCombo: function(comp, callbackParse){
168
+ var me = this;
169
+ if(me.getForm()){
170
+ var form = me.getForm();
171
+ }
172
+ else if(me.getFilterForm()){
173
+ var form = me.getFilterForm();
174
+ }
175
+ var callback = Ext.emptyFn;
176
+ if(comp.xtype=='combobox'){
177
+ if(me.disabledCombo==0){
178
+ form.el.mask(me.saveFormText);
179
+ setTimeout(function(){
180
+ form.el.mask(me.saveFormText);
181
+ },10);
182
+ }
183
+ me.disabledCombo++;
184
+ callback = function(){
185
+ me.disabledCombo--;
186
+ if(me.disabledCombo==0){
187
+ if(form){
188
+ form.el.unmask();
189
+
190
+ if(typeof callbackParse == 'function'){
191
+ callbackParse();
192
+ }
193
+ }
194
+ }
195
+ }
196
+ }
197
+ return callback;
198
+ },
199
+
200
+ processInterval: function(callback, combobox){
201
+ if(combobox){
202
+ this.clearInterval = setInterval(function(){
203
+ if(typeof callback === 'function'){
204
+ callback();
205
+ }
206
+ },1000);
207
+ }
208
+ else{
209
+ callback();
210
+ }
211
+ },
212
+
213
+ /*add del save getValues*/
214
+ del: function(grid, record, button) {
215
+ var me = this;
216
+ me.deleteAjax({
217
+ grid : grid,
218
+ tabela : me.modulo,
219
+ params : {
220
+ action: 'DELETAR',
221
+ id: record.get(me.chave)
222
+ },
223
+ button : button,
224
+ callback : false
225
+ });
226
+
227
+ },
228
+
229
+ add: function(button) {
230
+ var me = this;
231
+ var win = me.getAddWin();
232
+ if(!win) win = Ext.widget(me.addmodulo);
233
+ win.show();
234
+ },
235
+
236
+ edit: function(grid, record) {
237
+ var me = this;
238
+ var win = me.getAddWin();
239
+ if(!win) win = Ext.widget(me.addmodulo);
240
+ win.show();
241
+
242
+ me.getValuesForm({
243
+ form: me.getForm(),
244
+ win: win,
245
+ id: record.get(me.chave),
246
+ tabela: me.modulo
247
+ });
248
+
249
+ Ext.getCmp('action_'+ me.modulo).setValue('EDITAR');
250
+ },
251
+
252
+ update: function(button) {
253
+ var me = this;
254
+ //me.saveForm(me.getList(), me.getForm(), me.getAddWin(), button, false, false);
255
+ me.saveForm({
256
+ grid: me.getList(),
257
+ form: me.getForm(),
258
+ win : me.getAddWin(),
259
+ button : button,
260
+ callback: false
261
+ });
262
+ },
263
+
264
+ saveForm: function(options){
265
+ var me = this,
266
+ grid = options.grid,
267
+ form = options.form,
268
+ win = options.win,
269
+ button = options.button,
270
+ callback = options.callback;
271
+
272
+ if(form.getForm().isValid()){
273
+ form.el.mask(me.saveFormText);
274
+ button.setDisabled(true);
275
+ form.getForm().submit({
276
+ success: function(f, o){
277
+ button.setDisabled(false);
278
+ form.el.unmask();
279
+ if(o.result){
280
+ if(o.result.success==true){
281
+ info(me.avisoText, o.result.msg);
282
+
283
+ if(grid){
284
+ grid.store.load();
285
+ }
286
+
287
+ if(typeof callback == 'function'){
288
+ callback(o.result);
289
+ }
290
+
291
+ win.close();
292
+ me.getStoresDependes();
293
+ }
294
+ }
295
+ },
296
+ failure: function(f, action){
297
+ form.el.unmask();
298
+ switch (action.failureType) {
299
+ case Ext.form.action.Action.CLIENT_INVALID:
300
+ info(me.titleErro, me.fieldsInvalidText);
301
+ break;
302
+ case Ext.form.action.Action.CONNECT_FAILURE:
303
+ info(me.titleErro, me.connectFalhaText);
304
+ break;
305
+ case Ext.form.action.Action.SERVER_INVALID:
306
+ info(me.titleErro, action.result.msg);
307
+ }
308
+ button.setDisabled(false);
309
+ }
310
+ });
311
+ }
312
+ else{
313
+ info(me.titleErro, me.requiredsFieldsText);
314
+ }
315
+ },
316
+
317
+ deleteAjax: function(options){
318
+ var me = this,
319
+ grid = options.grid,
320
+ tabela = options.tabela,
321
+ params = options.params,
322
+ button = options.button,
323
+ callback = options.callback;
324
+
325
+ button.setDisabled(true);
326
+ grid.getEl().mask(me.delGridText);
327
+ Ext.Ajax.request({
328
+ url: tabela+'/delete.json',
329
+ params: params,
330
+ success: function(o){
331
+ var o = Ext.decode(o.responseText);
332
+ button.setDisabled(false);
333
+ if(o.success===true){
334
+ info(me.avisoText, o.msg);
335
+ grid.getEl().unmask();
336
+ grid.store.load();
337
+ if(typeof callback == 'function'){
338
+ callback();
339
+ }
340
+ me.getStoresDependes();
341
+ }
342
+ else{
343
+ info(me.titleErro, o.msg);
344
+ grid.getEl().unmask();
345
+ }
346
+ },
347
+ failure: function(o){
348
+ button.setDisabled(false);
349
+ info(me.titleErro, me.server_failure + o.status);
350
+ grid.getEl().unmask();
351
+ }
352
+ });
353
+ },
354
+
355
+ getPermissoes: function(){
356
+ var me = this;
357
+ var data = this.application.dados[this.modulo];
358
+ var items = me.getList().down('toolbar').items.items;
359
+
360
+ Ext.each(items, function(p){
361
+ Ext.each(data, function(j){
362
+ if(p.action && p.action==j.acao){
363
+ p.setVisible(true);
364
+ }
365
+ });
366
+ });
367
+ },
368
+
369
+ getValuesForm: function(options){
370
+ var me = this,
371
+ form = options.form,
372
+ win = options.win,
373
+ id = options.id,
374
+ tabela = options.tabela,
375
+ callback = options.callback,
376
+ combobox = options.combobox;
377
+
378
+ form.el.mask(me.saveFormText);
379
+
380
+ Ext.Ajax.request({
381
+ url: tabela+'/list.json',
382
+ params: {
383
+ id: id,
384
+ action: 'GET_VALUES'
385
+ },
386
+ success: function(o){
387
+ var dados = Ext.decode(o.responseText, true);
388
+ if(dados==null){
389
+ info(me.titleErro, response.responseText);
390
+ }
391
+ else if(dados.success==true){
392
+
393
+ me.processInterval(function(){
394
+ if(me.disabledCombo==0){
395
+ form.getForm().setValues(dados.dados);
396
+ form.el.unmask();
397
+ if(typeof callback == 'function'){
398
+ callback();
399
+ }
400
+ clearInterval(me.clearInterval);
401
+ return true;
402
+ }
403
+ }, combobox);
404
+
405
+ }
406
+ else{
407
+ info(me.avisoText, dados.msg);
408
+
409
+ if(dados.logout){
410
+ window.location = 'login';
411
+ }
412
+ }
413
+ if(form){
414
+ form.el.unmask();
415
+ }
416
+ },
417
+ failure: function(o){
418
+ var dados = Ext.decode(o.responseText, true);
419
+ if(dados==null){
420
+ info(me.titleErro, response.responseText);
421
+ }
422
+ else if(dados.logout){
423
+ window.location = 'login';
424
+ }
425
+
426
+ form.el.unmask();
427
+ }
428
+ });
429
+
430
+ },
431
+
432
+ getAddWindow: function(button){
433
+ this.application.getController(button.tabela).add(button);
434
+ },
435
+
436
+ constructor: function (config) {
437
+ this.mixins.observable.constructor.call(this, config);
438
+ }
439
+
440
+ });
441
+
@@ -25,7 +25,7 @@ Ext.define('<%=nameApp%>.view.<%=modulo.downcase%>.Edit', {
25
25
  bodyPadding: 10,
26
26
  autoScroll: true,
27
27
  method: 'POST',
28
- url : 'server/modulos/<%=modulo.downcase%>/save.php',
28
+ url : 'server/modulos/<%=modulo.downcase%>/save.json',
29
29
  items: [
30
30
  <%
31
31
  opcoes.each do |key, value|
@@ -0,0 +1,8 @@
1
+ module RubyExtjs
2
+ module Version
3
+ MAJOR = 1
4
+ MINOR = 0
5
+ PATCH = 1
6
+ STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
7
+ end
8
+ end
data/ruby-extjs.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "ruby-extjs"
3
- s.version = "1.0.0"
3
+ s.version = "1.0.1"
4
4
  s.description = "Simples Gerador Arquivos MVC ExtJs4 para Ruby on Rails"
5
5
  s.summary = "Gerar Arquivos MVC ExtJs para Ruby"
6
6
  s.author = "Maciel Sousa"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-extjs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -32,10 +32,12 @@ files:
32
32
  - lib/generators/sencha/templates/extjs/util/Store.js
33
33
  - lib/generators/sencha/templates/extjs/util/TabCloseMenu.js
34
34
  - lib/generators/sencha/templates/extjs/util/TextMask.js
35
+ - lib/generators/sencha/templates/extjs/util/Util.js
35
36
  - lib/generators/sencha/templates/extjs/view/edit.tpl
36
37
  - lib/generators/sencha/templates/extjs/view/filtro.tpl
37
38
  - lib/generators/sencha/templates/extjs/view/list.tpl
38
39
  - lib/generators/sencha/USAGE
40
+ - lib/ruby-extjs/version.rb
39
41
  - Gemfile
40
42
  - ruby-extjs.gemspec
41
43
  homepage: