ruby-extjs 1.0.1 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,441 +0,0 @@
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
-
@@ -1,26 +0,0 @@
1
- function getParams(a){
2
- var b = document.getElementsByTagName("script");
3
- for (var i = 0; i < b.length; i++){
4
- if (b[i].src.indexOf("/" + a) > -1){
5
- var c = b[i].src.split("?").pop().split("&");
6
- var p = {};
7
- for (var j = 0; j < c.length; j++){
8
- var d = c[j].split("=");
9
- p[d[0]] = d[1]
10
- }
11
- return p
12
- }
13
- }
14
- return {}
15
-
16
- }
17
-
18
- function isEmail(email){
19
- var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
20
- if(!filter.test(email)){
21
- return false;
22
- }
23
- else return true;
24
-
25
- }
26
-
@@ -1,133 +0,0 @@
1
- /**
2
- * @Autor: Maciel Sousa
3
- * @Email: macielcr7@gmail.com
4
- **/
5
-
6
- Ext.define('<%=nameApp%>.view.<%=modulo.downcase%>.Edit', {
7
- extend: 'Ext.window.Window',
8
- alias: 'widget.add<%=modulo.downcase%>win',
9
-
10
- id: 'Add<%=modulo.capitalize%>Win',
11
- layout: {
12
- type: 'fit'
13
- },
14
- title: '<%=modulo.capitalize%>',
15
-
16
- initComponent: function() {
17
- var me = this;
18
-
19
-
20
- Ext.applyIf(me, {
21
- items: [
22
- {
23
- xtype: 'form',
24
- id: 'Form<%=modulo.capitalize%>',
25
- bodyPadding: 10,
26
- autoScroll: true,
27
- method: 'POST',
28
- url : 'server/modulos/<%=modulo.downcase%>/save.json',
29
- items: [
30
- <%
31
- opcoes.each do |key, value|
32
- @c = typeEdit(value)
33
-
34
- if @c[0]==true and @c[1]==true
35
- %>
36
- {
37
- xtype: 'fieldcontainer',
38
- autoHeight: true,
39
- layout: {
40
- align: 'stretch',
41
- type: 'hbox'
42
- },
43
- items: [
44
- {
45
- xtype: 'combobox',
46
- store: 'Combo<%=@c[2].capitalize%>',
47
- name: '<%=key%>',
48
- id: '<%=key%>_<%=modulo.downcase%>',
49
- button_id: 'button_{$field.nome}_<%=modulo.downcase%>',
50
- flex: 1,
51
- anchor: '100%',
52
- fieldLabel: '<%=key.capitalize%>'
53
- },
54
- {
55
- xtype: 'buttonadd',
56
- iconCls: 'bt_cancel',
57
- hidden: true,
58
- id: 'button_{$field.nome}_<%=modulo.downcase%>',
59
- combo_id: '{$field.nome}_<%=modulo.downcase%>',
60
- action: 'reset_combo'
61
- },
62
- {
63
- xtype: 'buttonadd',
64
- tabela: '<%=@c[2].capitalize%>',
65
- action: 'add_win'
66
- }
67
- ]
68
- },<% else %>
69
- {
70
- xtype: 'textfield',<% if @c[0]==true and @c[1]=='chave' %>
71
- hidden: true,
72
- value: 0,<% end %>
73
- name: '<%=key%>',<% if @c[0]==true and @c[1]=='valid_email' %>
74
- validator: function(value){
75
- if(value!="" && !isEmail(value)){
76
- return 'E-mail Inválido...';
77
- }
78
- else{
79
- return true;
80
- }
81
- },<% end %>
82
- id: '<%=key%>_<%=modulo.downcase%>',<% if @c[0]==true and @c[1]=='type_pass' %>
83
- inputType: 'password',<% end %>
84
- anchor: '100%', <% if @c[0]==true and @c[1]=='mask' %>
85
- renderer: <%=@c[2]%>,<% end %>
86
- fieldLabel: '<%=key.capitalize%>'
87
- },<%end end %>
88
- {
89
- xtype: 'hidden',
90
- name: 'action',
91
- hidden: true,
92
- id: 'action_<%=modulo.downcase%>',
93
- value: 'INSERIR',
94
- anchor: '100%'
95
- }
96
- ]
97
- }
98
- ],
99
- dockedItems: [
100
- {
101
- xtype: 'toolbar',
102
- dock: 'bottom',
103
- items: [
104
- {
105
- xtype: 'tbfill'
106
- },
107
- {
108
- xtype: 'tbseparator'
109
- },
110
- {
111
- xtype: 'button',
112
- id: 'button_resetar_<%=modulo.downcase%>',
113
- iconCls: 'bt_cancel',
114
- action: 'resetar',
115
- text: 'Resetar'
116
- },
117
- {
118
- xtype: 'button',
119
- id: 'button_salvar_<%=modulo.downcase%>',
120
- iconCls: 'bt_save',
121
- action: 'salvar',
122
- text: 'Salvar'
123
- }
124
- ]
125
- }
126
- ]
127
- });
128
-
129
- me.callParent(arguments);
130
-
131
- }
132
-
133
- });
@@ -1,111 +0,0 @@
1
- /**
2
- * @Autor: Maciel Sousa
3
- * @Email: macielcr7@gmail.com
4
- **/
5
-
6
- Ext.define('<%=nameApp%>.view.<%=modulo.downcase%>.Filtro', {
7
- extend: 'Ext.window.Window',
8
- alias: 'widget.filter<%=modulo.downcase%>win',
9
-
10
- id: 'Filter<%=modulo.capitalize%>Win',
11
- layout: {
12
- type: 'fit'
13
- },
14
- title: '<%=modulo.capitalize%>',
15
-
16
- initComponent: function() {
17
- var me = this;
18
-
19
-
20
- Ext.applyIf(me, {
21
- items: [
22
- {
23
- xtype: 'form',
24
- id: 'FormFilter<%=modulo.capitalize%>',
25
- bodyPadding: 10,
26
- autoScroll: true,
27
- method: 'POST',
28
- items: [
29
- <%
30
- opcoes.each do |key, value|
31
- @c = typeEdit(value)
32
-
33
- if @c[0]==true and @c[1]==true
34
- %>
35
- {
36
- xtype: 'fieldcontainer',
37
- autoHeight: true,
38
- layout: {
39
- align: 'stretch',
40
- type: 'hbox'
41
- },
42
- items: [
43
- {
44
- xtype: 'combobox',
45
- store: 'Combo<%=@c[2].capitalize%>',
46
- name: '<%=key%>',
47
- id: '<%=key%>_filter_<%=modulo.downcase%>',
48
- button_id: 'button_{$field.nome}_filter_<%=modulo.downcase%>',
49
- flex: 1,
50
- anchor: '100%',
51
- fieldLabel: '<%=key.capitalize%>'
52
- },
53
- {
54
- xtype: 'buttonadd',
55
- iconCls: 'bt_cancel',
56
- hidden: true,
57
- id: 'button_{$field.nome}_filter_<%=modulo.downcase%>',
58
- combo_id: '{$field.nome}_filter_<%=modulo.downcase%>',
59
- action: 'reset_combo'
60
- }
61
- ]
62
- },<% else %>
63
- {
64
- xtype: 'textfield',
65
- name: '<%=key%>',
66
- id: '<%=key%>_filter_<%=modulo.downcase%>',
67
- anchor: '100%', <% if @c[0]==true and @c[1]=='mask' %>
68
- renderer: <%=@c[2]%>,<% end %>
69
- fieldLabel: '<%=key.capitalize%>'
70
- },<%end end %>
71
- {
72
- xtype: 'hidden',
73
- name: 'action',
74
- hidden: true,
75
- id: 'action_filter_<%=modulo.downcase%>',
76
- value: 'INSERIR',
77
- anchor: '100%'
78
- }
79
- ]
80
- }
81
- ],
82
- dockedItems: [
83
- {
84
- xtype: 'toolbar',
85
- dock: 'bottom',
86
- items: [
87
- {
88
- xtype: 'tbfill'
89
- },
90
- {
91
- xtype: 'button',
92
- iconCls: 'bt_cancel',
93
- action: 'resetar_filtro',
94
- text: 'Resetar'
95
- },
96
- {
97
- xtype: 'button',
98
- iconCls: 'bt_lupa',
99
- action: 'filtrar_busca',
100
- text: 'Filtrar'
101
- }
102
- ]
103
- }
104
- ]
105
- });
106
-
107
- me.callParent(arguments);
108
-
109
- }
110
-
111
- });