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