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