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