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