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