dbgenerate.js
[app.Builder.js] / dbgenerate.js
1 //<script type="text/javascript">
2
3 /**
4  * This is a hacky generator to generate element definitions for the Roo version from the database
5  * 
6  * Let's see if libgda can be used to generate our Readers for roo...
7  * 
8  * Concept - conect to database..
9  * 
10  * list tables
11  * 
12  * extra schemas..
13  * 
14  * write readers..
15  * 
16  * usage: seed generate.js
17  *
18  *
19  *
20  *
21  *Hack needed to latest GLib-2.0.gir 
22  *
23  * <record name="KeyFile" c:type="GKeyFile" disguised="1">
24         <constructor name="new" c:identifier="g_key_file_new">
25         <return-value transfer-ownership="full">
26           <type name="KeyFile" c:type="GKeyFile*"/>
27         </return-value>
28       </constructor>
29  *
30  *
31  * remove introspectable =0 from g_key_file_get_groups
32  *   and add transfer-owneership = none to return value
33  * remove introspectable =0 from g_key_file_get_keys
34  *   and add transfer-owneership = none to return value* 
35  * 
36  */
37 Gda  = imports.gi.Gda;
38 GObject = imports.gi.GObject;
39
40 GLib = imports.gi.GLib;
41
42 console = imports.console;
43 File = imports.File.File;
44 Options = imports.Options.Options;
45
46 //Gda.init();
47
48 var prov = Gda.Config.list_providers ();
49 //print(prov.dump_as_string());
50
51 var o = new Options({
52     help_description : 'Element builder for App Builder based on database schema',
53     
54     options:  [
55         { arg_long : 'DBTYPE' , arg_short : 't', description : 'Database Type (eg. MySQL or PostgreSQL ' },
56         { arg_long : 'DBNAME' , arg_short : 'd', description : 'Database Name' },
57         { arg_long : 'USERNAME' , arg_short : 'u', description : 'Username'},
58         { arg_long : 'PASSWORD' , arg_short : 'p', description : '' , arg_default :'' },
59         { arg_long : 'INI' , arg_short : 'I', description : 'Either base directory which has Pman/***/DataObjects/***.ini or location of ini file.' },
60     ]
61            
62 })
63
64
65
66 var cfg = o.parse(Seed.argv);
67 print(JSON.stringify(cfg, null,4));
68
69 var   cnc = Gda.Connection.open_from_string ("MySQL", "DB_NAME=" + cfg.DBNAME, 
70                                               "USERNAME=" + cfg.USERNAME + ';PASSWORD=' + cfg.PASSWORD,
71                                               Gda.ConnectionOptions.NONE, null);
72
73
74
75                                               
76
77  
78 Gda.DataSelect.prototype.fetchAll = function()
79 {
80     var cols = [];
81     
82     for (var i =0;i < this.get_n_columns(); i++) {
83         cols.push(this.get_column_name(i));
84     }
85     //print(JSON.stringify(cols, null,4));
86     var iter = this.create_iter();
87     var res = [];
88     //print(this.get_n_rows());
89     var _this = this;
90     for (var r = 0; r < this.get_n_rows(); r++) {
91         
92         // single clo..
93         //print("GOT ROW");
94         if (cols.length == 1) {
95             res.push(this.get_value_at(0,r).get_string());
96             continue;
97         }
98         var add = { };
99         
100         cols.forEach(function(n,i) {
101             var val = _this.get_value_at(i,r);
102             var type = GObject.type_name(val.g_type) ;
103             var vs = ['GdaBinary', 'GdaBlob' ].indexOf(type) > -1 ? val.value.to_string(1024) : val.value;
104             //print(n + " : TYPE: " + GObject.type_name(val.g_type) + " : " + vs);
105             //print (n + '=' + iter.get_value_at(i).value);
106             add[n] = vs;
107         });
108         
109         res.push(add);
110         
111     }
112     return res;
113
114 }
115
116 var map = {
117     'date' : 'date',
118     'datetime' : 'date',
119     'time' : 'string', //bogus
120     'int' : 'int',
121     'bigint' : 'int',
122     'double' : 'float',
123     'tinyint' : 'int',
124     'smallint' : 'int',
125     'decimal' : 'float',
126     'float' : 'float',
127     'char' : 'string',
128     'varchar' : 'string',
129     'text' : 'string',
130     'longtext' : 'string',
131     'tinytext' : 'string',
132     'mediumtext' : 'string',
133     'enum' : 'string',
134     'timestamp' : 'number',
135     'blob' : 'text'
136     
137 }
138
139 var ini = { }
140
141 function readIni(fn)
142 {
143     print('Read INI : ' + fn);
144     var key_file = new GLib.KeyFile.c_new();
145     if (!key_file.load_from_file (fn , GLib.KeyFileFlags.NONE )) {
146         return;
147     }
148    
149     var groups = key_file.get_groups();
150     groups.forEach(function(g) {
151         ini[g] = {}
152            print("KEY:"+g);
153         var keys = key_file.get_keys(g);
154         if (!keys) { return; }
155          keys.forEach(function(k) {
156             ini[g][k] = key_file.get_value(g,k);
157         })
158     })
159     
160 }
161 if (File.isFile(cfg.INI)) {
162     if (cfg.INI.match(/links\.ini$/)) {
163         readIni(cfg.INI);
164     } else {
165         readIni(cfg.INI.replace(/\.ini$/, ".links.ini"));
166     }
167 }
168
169
170 if (File.isDirectory(cfg.INI)) {
171         
172
173     //--- load ini files..
174     // this is very specific.
175     
176     var dirs = File.list( cfg.INI + '/Pman').filter( 
177         function(e) { 
178             if (!File.isDirectory(cfg.INI + '/Pman/' + e + '/DataObjects')) {
179                 return false;
180             }
181             return true;
182         }
183     );
184     
185      
186     dirs.forEach(function(d) {
187         // this currently misses the web.*/Pman/XXXX/DataObjects..
188         var path = cfg.INI + '/Pman/' + d + '/DataObjects';
189          
190         if (!File.isDirectory(path)) {
191             return; //skip
192         }
193         var inis = File.list(path).filter(
194             function(e) { return e.match(/\.links\.ini$/); }
195         );
196         if (!inis.length) {
197             return;
198         }
199         
200         inis.forEach(function(i) {
201             readIni(path + '/' + i); 
202             
203         })
204  
205     });
206     // look at web.XXXX/Pman/XXX/DataObjects/*.ini
207     var inis = File.list(cfg.INI).filter(
208         function(e) { return e.match(/\.links\.ini$/); }
209     )
210     
211      inis.forEach(function(i) {
212         readIni(path + '/' + i); 
213         
214     })
215     
216     
217 }
218 //print(JSON.stringify(ini, null,4));
219  //console.dump(ini);
220
221
222  //Seed.quit();
223
224 //GLib.key_file_load_from_file (key_file, String file, KeyFileFlags flags) : Boolean
225
226
227
228  
229
230 var tables = Gda.execute_select_command(cnc, "SHOW TABLES").fetchAll();
231 var readers = [];
232 tables.forEach(function(table) {
233     //print(table);
234     var schema = Gda.execute_select_command(cnc, "DESCRIBE `" + table+'`').fetchAll();
235     var reader = []; 
236     var colmodel = []; 
237     var combofields= [ { name : 'id', type: 'int' } ]; // technically the primary key..
238          
239     var form = {}
240        
241     var firstTxtCol = '';
242     
243     //print(JSON.stringify(schema, null,4));
244     
245     schema.forEach(function(e)  {
246         var type = e.Type.match(/([^(]+)\(([^\)]+)\)/);
247         var row  = { }; 
248         if (type) {
249             e.Type = type[1];
250             e.Size = type[2];
251         }
252         
253         
254         
255         row.name = e.Field;
256         
257         
258         if (typeof(map[e.Type]) == 'undefined') {
259            console.dump(e);
260            throw {
261                 name: "ArgumentError", 
262                 message: "Unknown mapping for type : " + e.Type
263             };
264         }
265         row.type = map[e.Type];
266         
267         if (row.type == 'string' && !firstTxtCol.length) {
268             firstTxtCol = row.name;
269         }
270         
271         if (row.type == 'date') {
272             row.dateFormat = 'Y-m-d';
273         }
274         reader.push(row);
275         
276         if (combofields.length == 1 && row.type == 'string') {
277             combofields.push(row);
278         }
279         
280         
281         var title = row.name.replace(/_id/, '').replace(/_/g, ' ');
282         title  = title[0].toUpperCase() + title.substring(1);
283         
284         colmodel.push({
285             "xtype": "ColumnModel",
286             "header": title,
287             "width":  row.type == 'string' ? 200 : 75,
288             "dataIndex": row.name,
289             "|renderer": row.type != 'date' ? 
290                     "function(v) { return String.format('{0}', v); }" :
291                     "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }" , // special for date
292             "|xns": "Roo.grid",
293             "*prop": "colModel[]"
294         });
295         var xtype = 'TextField';
296         if (row.type == 'number') {
297             xtype = 'NumberField';
298         }
299         if (row.type == 'date') {
300             xtype = 'DateField';
301         }
302         if (e.Type == 'text') {
303             xtype = 'TextArea';
304         }
305         if (row.name == 'id') {
306             xtype = 'Hidden';
307         } 
308         // what about booleans.. -> checkboxes..
309         
310         
311         
312         form[row.name] = {
313             fieldLabel : title,
314             name : row.name,
315             width : row.type == 'string' ? 200 : 75,
316             '|xns' : 'Roo.form',
317             xtype : xtype
318         }
319         if (xtype == 'TextArea') {
320             form[row.name].height = 100;
321         }
322         if (xtype == 'Hidden') {
323             delete form[row.name].fieldLabel;
324             delete form[row.name].width;
325         }
326         
327     });
328     
329     var combo = {
330         '|xns' : 'Roo.form',
331         xtype: 'ComboBox',
332         allowBlank : 'false',
333         editable : 'false',
334         emptyText : 'Select ' + table,
335         forceSelection : true,
336         listWidth : 400,
337         loadingText: 'Searching...',
338         minChars : 2,
339         pageSize : 20,
340         qtip: 'Select ' + table,
341         selectOnFocus: true,
342         triggerAction : 'all',
343         typeAhead: true,
344         
345         width: 300,
346         
347         
348         
349         tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> </div>', // SET WHEN USED
350         queryParam : '',// SET WHEN USED
351         fieldLabel : table,  // SET WHEN USED
352         valueField : 'id',
353         displayField : '', // SET WHEN USED eg. project_id_name
354         hiddenName : '', // SET WHEN USED eg. project_id
355         name : '', // SET WHEN USED eg. project_id_name
356         items : [
357             {
358                     
359                 '*prop' : 'store',
360                 'xtype' : 'Store',
361                 '|xns' : 'Roo.data',
362                 'remoteSort' : true,
363                 '|sortInfo' : '{ direction : \'ASC\', field: \'id\' }',
364                 listeners : {
365                     '|beforeload' : 'function (_self, o)' +
366                     "{\n" +
367                     "    o.params = o.params || {};\n" +
368                     "    // set more here\n" +
369                     "}\n"
370                 },
371                 items : [
372                     {
373                         '*prop' : 'proxy',
374                         'xtype' : 'HttpProxy',
375                         'method' : 'GET',
376                         '|xns' : 'Roo.data',
377                         '|url' : "baseURL + '/Roo/" + table + ".php'",
378                     },
379                     
380                     {
381                         '*prop' : 'reader',
382                         'xtype' : 'JsonReader',
383                         '|xns' : 'Roo.data',
384                         'id' : 'id',
385                         'root' : 'data',
386                         'totalProperty' : 'total',
387                         '|fields' : JSON.stringify(combofields)
388                         
389                     }
390                 ]
391             }
392         ]
393     }
394     
395     
396     
397     
398     //print(JSON.stringify(reader,null,4));
399     readers.push({
400         table : table ,
401         combo : combo,
402         combofields : combofields,
403         reader :  reader,
404         oreader : JSON.parse(JSON.stringify(reader)), // dupe it..
405         colmodel : colmodel,
406         firstTxtCol : firstTxtCol,
407         form : form
408     });
409     
410     //console.dump(schema );
411     
412      
413 });
414
415
416
417 // merge in the linked tables..
418 readers.forEach(function(reader) {
419     if (typeof(ini[reader.table]) == 'undefined') {
420      
421         return;
422     }
423     print("OVERLAY - " + reader.table);
424     // we have a map..
425     for (var col in ini[reader.table]) {
426         var kv = ini[reader.table][col].split(':');
427         
428         
429         var add = readers.filter(function(r) { return r.table == kv[0] })[0];
430         if (!add) {
431             continue;
432         }
433         // merge in data (eg. project_id => project_id_*****
434      
435         add.oreader.forEach(function(or) {
436             reader.reader.push({
437                 name : col + '_' + or.name,
438                 type : or.type
439             });
440         });
441         
442         // col is mapped to something..
443         var combofields = add.combofields;
444         if (add.combofields.length < 2) {
445             continue;
446         }
447         if (typeof(reader.form[col]) == 'undefined') {
448             print (JSON.stringify(reader.form, null,4));
449             print("missing linked column " + col);
450             continue;
451         }
452         
453         var combofields_name = add.combofields[1].name;
454         var old =   reader.form[col];
455         reader.form[col] = JSON.parse(JSON.stringify(add.combo)); // clone
456         reader.form[col].queryParam  = 'query[' + combofields_name + ']';// SET WHEN USED
457         reader.form[col].fieldLabel = old.fieldLabel;  // SET WHEN USED
458         reader.form[col].hiddenName = old.name; // SET WHEN USED eg. project_id
459         reader.form[col].displayField = combofields_name; // SET WHEN USED eg. project_id
460         reader.form[col].name  = old.name + '_' + combofields_name; // SET WHEN USED eg. project_id_name
461         reader.form[col].tpl = '<div class="x-grid-cell-text x-btn button"><b>{' + combofields_name +'}</b> </div>'; // SET WHEN USED
462         
463              
464     };
465     
466     
467 });
468
469 //readers.forEach(function(reader) {
470 //    delete reader.oreader;
471 //});
472
473  
474
475
476
477 //print(JSON.stringify(readers, null, 4));
478
479 readers.forEach(function(reader) {
480     
481
482     var dir = GLib.get_home_dir() + '/.Builder/Roo.data.JsonReader'; 
483     if (!File.isDirectory(dir)) {
484         print("mkdir " + dir);
485         File.mkdir(dir);
486     }
487     
488     // READERS
489     print("WRITE: " +  dir + '/' + cfg.DBNAME + '_' + reader.table + '.json');
490     
491                 
492     var jreader = {
493         '|xns' : 'Roo.data',
494         xtype : "JsonReader",
495         totalProperty : "total",
496         root : "data",
497         '*prop' : "reader",
498         id : 'id', // maybe no..
499        
500         '|fields' :  JSON.stringify(reader.reader, null,4).replace(/"/g,"'")
501     };
502     
503     File.write(
504         dir + '/' + cfg.DBNAME + '_' + reader.table + '.json',
505         JSON.stringify(jreader, null, 4)
506     )
507     
508     
509     // GRIDS
510     dir = GLib.get_home_dir() + '/.Builder/Roo.GridPanel'; 
511     if (!File.isDirectory(dir)) {
512         print("mkdir " + dir);
513         File.mkdir(dir);
514     }
515     
516
517     print("WRITE: " +  dir + '/' + cfg.DBNAME + '_' + reader.table + '.json');
518     
519     File.write(
520         dir + '/' + cfg.DBNAME + '_' + reader.table + '.json',
521             
522        
523         JSON.stringify({
524             '|xns' : 'Roo',
525             xtype : "GridPanel",
526             "title": reader.table,
527             "fitToframe": true,
528             "fitContainer": true,
529             "tableName": reader.table,
530             "background": true,
531             "region" : 'center',
532             "listeners": {
533                 "|activate": "function() {\n    _this.panel = this;\n    if (_this.grid) {\n        _this.grid.footer.onClick('first');\n    }\n}"
534             },
535             "items": [
536                 {
537                     "*prop": "grid",
538                     "xtype": "Grid",
539                     "autoExpandColumn": reader.firstTxtCol,
540                     "loadMask": true,
541                     "listeners": {
542                         "|render": "function() \n" +
543                             "{\n" +
544                             "    _this.grid = this; \n" +
545                             "    //_this.dialog = Pman.Dialog.FILL_IN\n" +
546                             "    if (_this.panel.active) {\n" +
547                             "       this.footer.onClick('first');\n" +
548                             "    }\n" +
549                             "}",
550                         "|rowdblclick": "function (_self, rowIndex, e)\n" + 
551                             "{\n" + 
552                             "    if (!_this.dialog) return;\n" + 
553                             "    _this.dialog.show( this.getDataSource().getAt(rowIndex), function() {\n" + 
554                             "        _this.grid.footer.onClick('first');\n" + 
555                             "    }); \n" + 
556                             "}\n"
557                     },
558                     "|xns": "Roo.grid",
559
560                     "items": [
561                         {
562                             "*prop": "dataSource",
563                             "xtype": "Store",
564                              remoteSort : true,
565                             '|sortInfo' : "{ field : '" + reader.firstTxtCol  +  "', direction: 'ASC' }", 
566                             "|xns": "Roo.data",
567                             "items": [
568                                 
569                                 {
570                                     "*prop": "proxy",
571                                     "xtype": "HttpProxy",
572                                     "method": "GET",
573                                     "|url": "baseURL + '/Roo/" + reader.table + ".php'",
574                                     "|xns": "Roo.data"
575                                 },
576                                 jreader
577                             ]
578                         },
579                         {
580                             "*prop": "footer",
581                             "xtype": "PagingToolbar",
582                             "pageSize": 25,
583                             "displayInfo": true,
584                             "displayMsg": "Displaying " + reader.table + "{0} - {1} of {2}",
585                             "emptyMsg": "No " + reader.table + " found",
586                             "|xns": "Roo"
587                         },
588                         {
589                             "*prop": "toolbar",
590                             "xtype": "Toolbar",
591                             "|xns": "Roo",
592                             "items": [
593                                 {
594                                     "text": "Add",
595                                     "xtype": "Button",
596                                     "cls": "x-btn-text-icon",
597                                     "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'",
598                                     "listeners": {
599                                         "|click": "function()\n"+
600                                             "{\n"+
601                                             "    if (!_this.dialog) return;\n" +
602                                             "    _this.dialog.show( { id : 0 } , function() {\n"+
603                                             "        _this.grid.footer.onClick('first');\n"+
604                                             "   }); \n"+
605                                             "}\n"
606                                     },
607                                     "|xns": "Roo.Toolbar"
608                                 },
609                                 {
610                                     "text": "Edit",
611                                     "xtype": "Button",
612                                     "cls": "x-btn-text-icon",
613                                     "|icon": "Roo.rootURL + 'images/default/tree/leaf.gif'",
614                                     "listeners": {
615                                         "|click": "function()\n"+
616                                             "{\n"+
617                                             "    var s = _this.grid.getSelectionModel().getSelections();\n"+
618                                             "    if (!s.length || (s.length > 1))  {\n"+
619                                             "        Roo.MessageBox.alert(\"Error\", s.length ? \"Select only one Row\" : \"Select a Row\");\n"+
620                                             "        return;\n"+
621                                             "    }\n"+
622                                             "    if (!_this.dialog) return;\n" +
623                                             "    _this.dialog.show(s[0].data, function() {\n"+
624                                             "        _this.grid.footer.onClick('first');\n"+
625                                             "    }); \n"+
626                                             "    \n"+
627                                             "}\n" 
628                                         
629                                     },
630                                     "|xns": "Roo.Toolbar"
631                                 },
632                                 {
633                                     "text": "Delete",
634                                     "cls": "x-btn-text-icon",
635                                     "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
636                                     "xtype": "Button",
637                                     "listeners": {
638                                         "|click": "function()\n"+
639                                             "{\n"+
640                                             "     Pman.genericDelete(_this, '" + reader.table + "'); \n"+
641                                             "}\n"+
642                                             "        "
643                                     },
644                                     "|xns": "Roo.Toolbar"
645                                 }
646                             ]
647                         }, // end toolbar
648                     ].concat( reader.colmodel)
649                 }
650             ]
651             
652             
653         }, null, 4)
654     )
655     
656     /// FORMS..
657     
658     dir = GLib.get_home_dir() + '/.Builder/Roo.form.Form'; 
659     if (!File.isDirectory(dir)) {
660         print("mkdir " + dir);
661         File.mkdir(dir);
662     }
663     var formElements = [];
664     var formHeight = 50;
665     for (var k in reader.form) {
666         if (k == 'id') { // should really do primary key testing..
667             continue;
668         }
669         formHeight += reader.form[k].xtype == 'TextArea' ? 100 : 30;
670         
671         formElements.push(reader.form[k]);
672     }
673     if (reader.form['id']) {
674         formElements.push(reader.form['id']);
675     }
676     
677
678     print("WRITE: " +  dir + '/' + cfg.DBNAME + '_' + reader.table + '.json');
679     var frmCfg = 
680     {
681         '|xns' : 'Roo.form',
682         xtype : "Form",
683         listeners : {
684             "|actioncomplete" : "function(_self,action)\n"+
685                 "{\n"+
686                 "    if (action.type == 'setdata') {\n"+
687                 "       //_this.dialog.el.mask(\"Loading\");\n"+
688                 "       //this.load({ method: 'GET', params: { '_id' : _this.data.id }});\n"+
689                 "       return;\n"+
690                 "    }\n"+
691                 "    if (action.type == 'load') {\n"+
692                 "        _this.dialog.el.unmask();\n"+
693                 "        return;\n"+
694                 "    }\n"+
695                 "    if (action.type =='submit') {\n"+
696                 "    \n"+
697                 "        _this.dialog.el.unmask();\n"+
698                 "        _this.dialog.hide();\n"+
699                 "    \n"+
700                 "         if (_this.callback) {\n"+
701                 "            _this.callback.call(_this, _this.form.getValues());\n"+
702                 "         }\n"+
703                 "         _this.form.reset();\n"+
704                 "         return;\n"+
705                 "    }\n"+
706                 "}\n",
707             
708             "|rendered" : "function (form)\n"+
709                 "{\n"+
710                 "    _this.form= form;\n"+
711                 "}\n"
712         },
713         method : "POST",
714         style : "margin:10px;",
715         "|url" : "baseURL + '/Roo/" + reader.table + ".php'",
716         items : formElements
717     };
718     
719     
720     File.write(
721         dir + '/' + cfg.DBNAME + '_' + reader.table + '.json',
722             
723        
724         JSON.stringify( frmCfg, null, 4)
725     );
726             
727             
728    
729    
730    
731      /// COMBO..
732     
733     dir = GLib.get_home_dir() + '/.Builder/Roo.form.ComboBox'; 
734     if (!File.isDirectory(dir)) {
735         print("mkdir " + dir);
736         File.mkdir(dir);
737     }
738    
739     print("WRITE: " +  dir + '/' + cfg.DBNAME + '_' + reader.table + '.json');
740     
741     File.write(
742         dir + '/' + cfg.DBNAME + '_' + reader.table + '.json',
743             
744        
745         JSON.stringify(reader.combo, null, 4)
746     );
747             
748    
749    
750    
751    
752    
753     // DIALOG.
754    
755    
756     dir = GLib.get_home_dir() + '/.Builder/Roo.LayoutDialog'; 
757     if (!File.isDirectory(dir)) {
758         print("mkdir " + dir);
759         File.mkdir(dir);
760     }
761     var formElements = [];
762     for (var k in reader.form) {
763         if (k == 'id') { // should really do primary key testing..
764             continue;
765         }
766         formElements.push(reader.form[k]);
767     }
768     formElements.push(reader.form['id']);
769
770     print("WRITE: " +  dir + '/' + cfg.DBNAME + '_' + reader.table + '.json');
771     
772     File.write(
773         dir + '/' + cfg.DBNAME + '_' + reader.table + '.json',
774             
775        
776         JSON.stringify({
777        
778             "closable": false,
779             "collapsible": false,
780             "height": formHeight,
781             "resizable": false,
782             "title": "Edit / Create " + reader.table,
783             "width": 400,
784             "xtype": "LayoutDialog",
785             "|xns": "Roo",
786             "items": [
787                 {
788                     "|xns": "Roo",
789                     "xtype": "LayoutRegion",
790                     "*prop": "center"
791                 },
792                 {
793                     "region": "center",
794                     "xtype": "ContentPanel",
795                     "|xns": "Roo",
796                     "items": [
797                         frmCfg
798                     ]
799                 },
800                 
801                 {
802                     "listeners": {
803                         "click": "function (_self, e)\n{\n    _this.dialog.hide();\n}"
804                     },
805                     "*prop": "buttons[]",
806                     "text": "Cancel",
807                     "xtype": "Button",
808                     "|xns": "Roo"
809                 },
810                 {
811                     "listeners": {
812                         "click": "function (_self, e)\n{\n    // do some checks?\n     \n    \n    _this.dialog.el.mask(\"Saving\");\n    _this.form.doAction(\"submit\");\n\n}"
813                     },
814                     "*prop": "buttons[]",
815                     "text": "Save",
816                     "xtype": "Button",
817                     "|xns": "Roo"
818                 }
819             ]
820         }, null,4)
821     );
822    
823    
824    
825 });
826
827