resources/Editors/Editor.Roo.LayoutDialog.bjs
[app.Builder.js] / resources / Editors / Editor.Roo.LayoutDialog.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Roo.namespace('Editor.Roo');
6
7 Editor.Roo.LayoutDialog = new Roo.XComponent({
8
9  _strings : {
10   'b021df6aac4654c454f46c77646e745f' :"Label",
11   '793548e77e782c209a78ed67f255b5e2' :"Display Field",
12   '4ce58cbe362a5d7b156992a496d55bf3' :"Database Column",
13   '189efd19c4153526994a6d7ea5f6f068' :"Field Type",
14   '2f616612593df62aeed112de4f03110e' :"Edit a Grid",
15   '0ccc2bf3fb98387c23b6ca5500244d6e' :"Use ",
16   'c671c787b49f50a3ace9fdc5bd597825' :"core_enum",
17   'dc30ec20708ef7b0f641ef78b7880a15' :"DEBUG",
18   '32954654ac8fe66a1d09be19001de2d4' :"Width",
19   'a1fa27779242b4902f7ae3bdd5c6d508' :"Type",
20   '6e7376dca68a2386a8737944196ab491' :"Create / Edit Grid"
21  },
22
23   part     :  ["Editors", "LayoutDialog" ],
24   order    : '001-Editor.Roo.LayoutDialog',
25   region   : 'center',
26   parent   : false,
27   name     : "unnamed module",
28   disabled : false, 
29   permname : '', 
30   _tree : function()
31   {
32    var _this = this;
33    var MODULE = this;
34    return {
35    grid : {
36     ds : {
37      '|xns' : 'Roo.data',
38      data : [
39        [ 1, 'test', 'test', 110 ]
40        
41      
42      ],
43      fields : [ 'active', 'dataIndex', 'type','title', 'width', 'ftype', 'display_field' ],
44      id : 'dataindex',
45      xns : Roo.data,
46      xtype : 'SimpleStore'
47     },
48     toolbar : {
49      '|xns' : 'Roo',
50      xns : Roo,
51      xtype : 'Toolbar',
52      items : [
53       {
54        '|xns' : 'Roo.Toolbar',
55        text : _this._strings['2f616612593df62aeed112de4f03110e'],
56        xns : Roo.Toolbar,
57        xtype : 'TextItem'
58       },
59       {
60        '|xns' : 'Roo.Toolbar',
61        xns : Roo.Toolbar,
62        xtype : 'Fill'
63       },
64       {
65        '|xns' : 'Roo.Toolbar',
66        text : _this._strings['dc30ec20708ef7b0f641ef78b7880a15'],
67        xns : Roo.Toolbar,
68        xtype : 'Button',
69        listeners : {
70         click : function (_self, e)
71          {
72              Roo.log(_this.ftype_combo);
73              var data = {    
74                  "manage_scale_id": {
75                      "Field": "manage_scale_id",
76                      "Type": "int(11)",
77                      "Null": "NO",
78                      "Key": null,
79                      "Default": "0",
80                      "Extra": null,
81                      "relates_to_table": "core_enum",
82                      "relates_to_col": "id",
83                      "relates_to_schema": {
84                          "id": {
85                              "Field": "id",
86                              "Type": "int(11)",
87                              "Null": "NO",
88                              "Key": "PRI",
89                              "Default": null,
90                              "Extra": "auto_increment"
91                          },
92                          "etype": {
93                              "Field": "etype",
94                              "Type": "varchar(32)",
95                              "Null": "NO",
96                              "Key": null,
97                              "Default": null,
98                              "Extra": null
99                          },
100                          "name": {
101                              "Field": "name",
102                              "Type": "varchar(255)",
103                              "Null": "NO",
104                              "Key": null,
105                              "Default": null,
106                              "Extra": null
107                          },
108                          "active": {
109                              "Field": "active",
110                              "Type": "int(2)",
111                              "Null": "NO",
112                              "Key": null,
113                              "Default": "1",
114                              "Extra": null
115                          },
116                          "seqid": {
117                              "Field": "seqid",
118                              "Type": "int(11)",
119                              "Null": "NO",
120                              "Key": "MUL",
121                              "Default": "0",
122                              "Extra": null
123                          },
124                          "seqmax": {
125                              "Field": "seqmax",
126                              "Type": "int(11)",
127                              "Null": "NO",
128                              "Key": null,
129                              "Default": "0",
130                              "Extra": null
131                          },
132                          "display_name": {
133                              "Field": "display_name",
134                              "Type": "text",
135                              "Null": "NO",
136                              "Key": null,
137                              "Default": null,
138                              "Extra": null
139                          },
140                          "is_system_enum": {
141                              "Field": "is_system_enum",
142                              "Type": "int(2)",
143                              "Null": "NO",
144                              "Key": null,
145                              "Default": "0",
146                              "Extra": null
147                          }
148                      }
149                  },
150                  "person_type": {
151                      "Field": "person_type",
152                      "Type": "text",
153                      "Null": "NO",
154                      "Key": null,
155                      "Default": null,
156                      "Extra": null
157                  },
158                  "employer_name": {
159                      "Field": "employer_name",
160                      "Type": "text",
161                      "Null": "NO",
162                      "Key": null,
163                      "Default": null,
164                      "Extra": null
165                  },
166                  "birth_date": {
167                      "Field": "birth_date",
168                      "Type": "date",
169                      "Null": "NO",
170                      "Key": null,
171                      "Default": "0000-00-00",
172                      "Extra": null
173                  },
174                  "employ_start_date": {
175                      "Field": "employ_start_date",
176                      "Type": "date",
177                      "Null": "NO",
178                      "Key": null,
179                      "Default": "0000-00-00",
180                      "Extra": null
181                  },
182                  "employ_end_date": {
183                      "Field": "employ_end_date",
184                      "Type": "date",
185                      "Null": "NO",
186                      "Key": null,
187                      "Default": "0000-00-00",
188                      "Extra": null
189                  },
190                  "hide_same_employer": {
191                      "Field": "hide_same_employer",
192                      "Type": "int(4)",
193                      "Null": "NO",
194                      "Key": null,
195                      "Default": "0",
196                      "Extra": null
197                  },
198                  "salary_currency": {
199                      "Field": "salary_currency",
200                      "Type": "varchar(256)",
201                      "Null": "NO",
202                      "Key": null,
203                      "Default": null,
204                      "Extra": null
205                  },
206                  "quota_currency": {
207                      "Field": "quota_currency",
208                      "Type": "varchar(256)",
209                      "Null": "NO",
210                      "Key": null,
211                      "Default": null,
212                      "Extra": null
213                  },
214                  "created_dt": {
215                      "Field": "created_dt",
216                      "Type": "datetime",
217                      "Null": "NO",
218                      "Key": null,
219                      "Default": "0000-00-00 00:00:00",
220                      "Extra": null
221                  },
222                  "updated_dt": {
223                      "Field": "updated_dt",
224                      "Type": "datetime",
225                      "Null": "NO",
226                      "Key": null,
227                      "Default": "0000-00-00 00:00:00",
228                      "Extra": null
229                  }
230              };
231              
232              Roo.log('debuging...');
233              _this.panel.loadData(data);
234          
235          }
236        }
237       }
238      ]
239
240     },
241     '|xns' : 'Roo.grid',
242     autoExpandColumn : 'title',
243     clicksToEdit : 1,
244     loadMask : true,
245     xns : Roo.grid,
246     xtype : 'EditorGrid',
247     cm : [
248       {
249        '|xns' : 'Roo.grid',
250        dataIndex : 'active',
251        header : _this._strings['0ccc2bf3fb98387c23b6ca5500244d6e'],
252        renderer : function(v) {  
253            var state = v *1 > 0 ?  '-checked' : '';
254        
255            return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
256                        
257         },
258        width : 75,
259        xns : Roo.grid,
260        xtype : 'ColumnModel'
261       },
262 {
263        '|xns' : 'Roo.grid',
264        dataIndex : 'dataIndex',
265        header : _this._strings['4ce58cbe362a5d7b156992a496d55bf3'],
266        renderer : function(v) { return String.format('{0}', v); },
267        width : 150,
268        xns : Roo.grid,
269        xtype : 'ColumnModel'
270       },
271 {
272        '|xns' : 'Roo.grid',
273        dataIndex : 'type',
274        header : _this._strings['a1fa27779242b4902f7ae3bdd5c6d508'],
275        renderer : function(v) { return String.format('{0}', v); },
276        width : 100,
277        xns : Roo.grid,
278        xtype : 'ColumnModel'
279       },
280 {
281        editor : {
282         field : {
283          '|xns' : 'Roo.form',
284          xns : Roo.form,
285          xtype : 'TextField'
286         },
287         '|xns' : 'Roo.grid',
288         xns : Roo.grid,
289         xtype : 'GridEditor',
290         items : [
291
292         ]
293
294        },
295        '|xns' : 'Roo.grid',
296        dataIndex : 'title',
297        header : _this._strings['b021df6aac4654c454f46c77646e745f'],
298        renderer : function(v) { return String.format('{0}', v); },
299        width : 120,
300        xns : Roo.grid,
301        xtype : 'ColumnModel',
302        items : [
303
304        ]
305
306       },
307 {
308        editor : {
309         field : {
310          store : {
311           '|xns' : 'Roo.data',
312           data : [ 
313               [ 'ComboBox', "ComboBox"],
314               [ 'TextField' , "TextField"],
315               [ 'NumberField', "NumberField"],
316               [ 'TextArea', "TextArea"],
317               [ 'HtmlEditor', "HtmlEditor"],
318               [ 'Hidden', "Hidden"],
319               [ 'DateField', "DateField"],
320               [ 'Checkbox', "Checkbox"]    
321               // checkbox?
322           ],
323           fields : [  'ftype', 'fname'],
324           xns : Roo.data,
325           xtype : 'SimpleStore'
326          },
327          '|xns' : 'Roo.form',
328          allowBlank : false,
329          displayField : 'fname',
330          editable : false,
331          hiddenName : 'status',
332          listWidth : 200,
333          mode : 'local',
334          name : 'ftype',
335          triggerAction : 'all',
336          valueField : 'ftype',
337          width : 150,
338          xns : Roo.form,
339          xtype : 'ComboBox',
340          items : [
341
342          ]
343
344         },
345         '|xns' : 'Roo.grid',
346         xns : Roo.grid,
347         xtype : 'GridEditor',
348         items : [
349
350         ]
351
352        },
353        '|xns' : 'Roo.grid',
354        dataIndex : 'ftype',
355        header : _this._strings['189efd19c4153526994a6d7ea5f6f068'],
356        renderer : function(v) { return String.format('{0}', v); },
357        width : 120,
358        xns : Roo.grid,
359        xtype : 'ColumnModel',
360        items : [
361
362        ]
363
364       },
365 {
366        editor : {
367         field : {
368          store : {
369           '|xns' : 'Roo.data',
370           data : [ 
371               [ 'ComboBox', "ComboBox"],
372               [ 'Text' , "TextField"],
373               [ 'Number', "NumberField"],
374               [ 'TextArea', "TextArea"],
375               [ 'Html', "HtmlEntry"]
376               
377           ],
378           fields : [  'ftype', 'fname'],
379           xns : Roo.data,
380           xtype : 'SimpleStore'
381          },
382          '|xns' : 'Roo.form',
383          allowBlank : false,
384          displayField : 'fname',
385          editable : false,
386          hiddenName : 'status',
387          listWidth : 200,
388          mode : 'local',
389          name : 'display_field',
390          triggerAction : 'all',
391          valueField : 'ftype',
392          width : 150,
393          xns : Roo.form,
394          xtype : 'ComboBox',
395          listeners : {
396           render : function (_self)
397            {
398             Roo.log('render!!!!!!!!!!!1');
399            },
400           select : function (combo, record, index)
401            {
402                Roo.log('test!!!');
403            }
404          },
405          items : [
406
407          ]
408
409         },
410         '|xns' : 'Roo.grid',
411         xns : Roo.grid,
412         xtype : 'GridEditor',
413         items : [
414
415         ]
416
417        },
418        '|xns' : 'Roo.grid',
419        dataIndex : 'display_field',
420        header : _this._strings['793548e77e782c209a78ed67f255b5e2'],
421        renderer : function(v) { return String.format('{0}', v); },
422        width : 150,
423        xns : Roo.grid,
424        xtype : 'ColumnModel',
425        items : [
426
427        ]
428
429       },
430 {
431        editor : {
432         field : {
433          '|xns' : 'Roo.form',
434          decimalPrecision : 0,
435          xns : Roo.form,
436          xtype : 'NumberField'
437         },
438         '|xns' : 'Roo.grid',
439         xns : Roo.grid,
440         xtype : 'GridEditor',
441         items : [
442
443         ]
444
445        },
446        '|xns' : 'Roo.grid',
447        dataIndex : 'width',
448        header : _this._strings['32954654ac8fe66a1d09be19001de2d4'],
449        renderer : function(v) { return String.format('{0}', v); },
450        width : 75,
451        xns : Roo.grid,
452        xtype : 'ColumnModel',
453        items : [
454
455        ]
456
457       }
458     ],
459     listeners : {
460      cellclick : function (_self, rowIndex, columnIndex, e)
461       {
462       
463               var di = this.colModel.getDataIndex(columnIndex);
464               if (di != 'active') {
465                   return;
466               }
467                
468               var rec = _this.grid.ds.getAt(rowIndex);
469               
470               rec.set('active', rec.data.active * 1 ? 0 : 1);
471               rec.commit();
472                
473               
474       },
475      render : function() 
476       {
477           _this.grid = this; 
478           //_this.dialog = Pman.Dialog.FILL_IN
479       
480       },
481      rowdblclick : function (_self, rowIndex, e)
482       {
483           if (!_this.dialog) return;
484         
485       }
486     },
487     items : [
488
489     ]
490
491    },
492    '|xns' : 'Roo',
493    background : false,
494    fitContainer : true,
495    fitToframe : true,
496    loadData : function(data) { 
497    
498        //alert("IPC:TEST:" + JSON.stringify(data,null,4));
499    
500        var ar = [];
501        for (var k in data) { 
502            var r = data[k];
503            var has_s = typeof(r.relates_to_schema) != 'undefined'
504            ar.push([ !has_s , r.Field, r.Type,  r.Field, 100 , 'TextField', r.Field + '_display_name'] );
505            if (!has_s) {
506                continue;
507            }
508            
509            for (var kk in r.relates_to_schema) {         
510                var rr = r.relates_to_schema[kk];
511                if (rr.Field == r.relates_to_col) {
512                    continue;
513                }
514                ar.push([ false, r.Field + '_'+ rr.Field, rr.Type,  rr.Field, 100] );
515            }
516            
517        }
518        this.schema = data;
519        
520        //alert("IPC:TEST:" + JSON.stringify(ar));
521        this.grid.dataSource.loadData(ar);
522    },
523    region : 'center',
524    tableName : 'core_enum',
525    title : _this._strings['c671c787b49f50a3ace9fdc5bd597825'],
526    title : _this._strings['c671c787b49f50a3ace9fdc5bd597825'],
527    toBJS : function() { 
528    
529    // convert the selected cells into a BJS data ready to send back to the UI..
530    
531        this.table = "XXX";
532        this.firstTxtCol = "XXX";
533       
534        var formHeight = 50;
535        
536        var jreader = {};
537        var  formElements = [];
538        this.grid.dataSource.each(function(rec) {
539            if (!rec.data.active) {
540                return;
541            }
542            
543            var el = {
544                fieldLabel : rec.data.title,
545                name : rec.data.dataIndex,
546                width : 200, //row.type == 'string' ? 200 : 75,
547                '|xns' : 'Roo.form',
548                xtype : rec.data.ftype
549            }
550             if (xtype == 'DateField') {
551                el.format = 'Y-m-d';
552                el.useIso = true;
553                el.width = 100;
554            }
555            
556            if (xtype == 'TextArea') {
557                el.height = 100;
558            }
559            
560            if (xtype == 'Hidden') {
561                delete el.fieldLabel;
562                delete el.width;
563            }
564            if (xtype == 'Combobox') {
565            
566    
567                el.queryParam  = 'query[' + combofields_name + ']';// SET WHEN USED
568                
569                el.hiddenName = rec.data.dataIndex // SET WHEN USED eg. project_id
570                el.displayField = combofields_name; // SET WHEN USED eg. project_id
571                el.name  = old.name + '_' + combofields_name; // SET WHEN USED eg. project_id_name
572                el.tpl = '<div class="x-grid-cell-text x-btn button"><b>{' + combofields_name +'}</b> </div>'; // SET WHEN USED
573              
574            
575               el.items = [
576                    {
577                            
578                        '*prop' : 'store',
579                        'xtype' : 'Store',
580                        '|xns' : 'Roo.data',
581                        'remoteSort' : true,
582                        '|sortInfo' : '{ direction : \'ASC\', field: \'id\' }',
583                        listeners : {
584                            '|beforeload' : 'function (_self, o)' +
585                            "{\n" +
586                            "    o.params = o.params || {};\n" +
587                            "    // set more here\n" +
588                            "}\n"
589                        },
590                        items : [
591                            {
592                                '*prop' : 'proxy',
593                                'xtype' : 'HttpProxy',
594                                'method' : 'GET',
595                                '|xns' : 'Roo.data',
596                                '|url' : "baseURL + '/Roo/" + reftable + ".php'",
597                            },
598                            
599                            {
600                                '*prop' : 'reader',
601                                'xtype' : 'JsonReader',
602                                '|xns' : 'Roo.data',
603                                'id' : 'id',
604                                'root' : 'data',
605                                'totalProperty' : 'total'
606    
607                                
608                            }
609                        ]
610                    }
611                ];
612            
613            }
614            
615            
616            formElements.push(el);
617            
618            formHeight += rec.data.ftype == 'TextArea' ? 100 : 30;
619            
620            
621        });
622        
623        
624        
625        
626        
627        
628         var frmCfg = 
629        {
630            '|xns' : 'Roo.form',
631            xtype : "Form",
632            listeners : {
633                "|actioncomplete" : "function(_self,action)\n"+
634                    "{\n"+
635                    "    if (action.type == 'setdata') {\n"+
636                    "       //this.load({ method: 'GET', params: { '_id' : _this.data.id }});\n"+
637                    "       return;\n"+
638                    "    }\n"+
639                    "    if (action.type == 'load') {\n"+
640                    "        return;\n"+
641                    "    }\n"+
642                    "    if (action.type =='submit') {\n"+
643                    "    \n"+
644                    "        _this.dialog.hide();\n"+
645                    "    \n"+
646                    "         if (_this.callback) {\n"+
647                    "            _this.callback.call(_this, action.result.data);\n"+
648                    "         }\n"+
649                    "         _this.form.reset();\n"+
650                    "         return;\n"+
651                    "    }\n"+
652                    "}\n",
653                
654                "|rendered" : "function (form)\n"+
655                    "{\n"+
656                    "    _this.form= form;\n"+
657                    "}\n"
658            },
659            method : "POST",
660            style : "margin:10px;",
661            "|url" : "baseURL + '/Roo/" + this.table + "'",
662            items : formElements
663        };
664        
665    
666        alert("IPC:OUT:" + JSON.stringify({
667                "closable": false,
668                "collapsible": false,
669                "height": formHeight,
670                "resizable": false,
671                "title": "Edit / Create " + this.table,
672                "width": 400,
673                "modal" : true,
674                "xtype": "LayoutDialog",
675                "|xns": "Roo",
676                "items": [
677                    {
678                        "|xns": "Roo",
679                        "xtype": "LayoutRegion",
680                        "*prop": "center"
681                    },
682                    {
683                        "region": "center",
684                        "xtype": "ContentPanel",
685                        "|xns": "Roo",
686                        "items": [
687                            frmCfg
688                        ]
689                    },
690                    
691                    {
692                        "listeners": {
693                            "click": "function (_self, e)\n{\n    _this.dialog.hide();\n}"
694                        },
695                        "*prop": "buttons[]",
696                        "text": "Cancel",
697                        "xtype": "Button",
698                        "|xns": "Roo"
699                    },
700                    {
701                        "listeners": {
702                            "click": "function (_self, e)\n{\n    // do some checks?\n     \n    \n    _this.dialog.el.mask(\"Saving\");\n    _this.form.doAction(\"submit\");\n\n}"
703                        },
704                        "*prop": "buttons[]",
705                        "text": "Save",
706                        "xtype": "Button",
707                        "|xns": "Roo"
708                    }
709                ]
710            
711            
712            
713        }, null, 4));
714    
715    },
716    xns : Roo,
717    xtype : 'GridPanel',
718    listeners : {
719     activate : function() {
720          _this.panel = this;
721          if (_this.grid) {
722              _this.grid.footer.onClick('first');
723          }
724      }
725    },
726    items : [
727
728    ]
729
730   };  }
731 });