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   '32954654ac8fe66a1d09be19001de2d4' :"Width",
18   'a1fa27779242b4902f7ae3bdd5c6d508' :"Type",
19   '6e7376dca68a2386a8737944196ab491' :"Create / Edit Grid"
20  },
21
22   part     :  ["Editors", "LayoutDialog" ],
23   order    : '001-Editor.Roo.LayoutDialog',
24   region   : 'center',
25   parent   : false,
26   name     : "unnamed module",
27   disabled : false, 
28   permname : '', 
29   _tree : function()
30   {
31    var _this = this;
32    var MODULE = this;
33    return {
34    grid : {
35     ds : {
36      '|xns' : 'Roo.data',
37      data : [
38        [ 1, 'test', 'test', 110 ]
39        
40      
41      ],
42      fields : [ 'active', 'dataIndex', 'type','title', 'width' ],
43      id : 'dataindex',
44      xns : Roo.data,
45      xtype : 'SimpleStore'
46     },
47     toolbar : {
48      '|xns' : 'Roo',
49      xns : Roo,
50      xtype : 'Toolbar',
51      items : [
52       {
53        '|xns' : 'Roo.Toolbar',
54        text : _this._strings['2f616612593df62aeed112de4f03110e'],
55        xns : Roo.Toolbar,
56        xtype : 'TextItem'
57       }
58      ]
59
60     },
61     '|xns' : 'Roo.grid',
62     autoExpandColumn : 'title',
63     clicksToEdit : 1,
64     loadMask : true,
65     xns : Roo.grid,
66     xtype : 'EditorGrid',
67     cm : [
68       {
69        '|xns' : 'Roo.grid',
70        dataIndex : 'active',
71        header : _this._strings['0ccc2bf3fb98387c23b6ca5500244d6e'],
72        renderer : function(v) {  
73            var state = v *1 > 0 ?  '-checked' : '';
74        
75            return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
76                        
77         },
78        width : 75,
79        xns : Roo.grid,
80        xtype : 'ColumnModel'
81       },
82 {
83        '|xns' : 'Roo.grid',
84        dataIndex : 'dataIndex',
85        header : _this._strings['4ce58cbe362a5d7b156992a496d55bf3'],
86        renderer : function(v) { return String.format('{0}', v); },
87        width : 150,
88        xns : Roo.grid,
89        xtype : 'ColumnModel'
90       },
91 {
92        '|xns' : 'Roo.grid',
93        dataIndex : 'type',
94        header : _this._strings['a1fa27779242b4902f7ae3bdd5c6d508'],
95        renderer : function(v) { return String.format('{0}', v); },
96        width : 100,
97        xns : Roo.grid,
98        xtype : 'ColumnModel'
99       },
100 {
101        editor : {
102         field : {
103          '|xns' : 'Roo.form',
104          xns : Roo.form,
105          xtype : 'TextField'
106         },
107         '|xns' : 'Roo.grid',
108         xns : Roo.grid,
109         xtype : 'GridEditor',
110         items : [
111
112         ]
113
114        },
115        '|xns' : 'Roo.grid',
116        dataIndex : 'title',
117        header : _this._strings['b021df6aac4654c454f46c77646e745f'],
118        renderer : function(v) { return String.format('{0}', v); },
119        width : 75,
120        xns : Roo.grid,
121        xtype : 'ColumnModel',
122        items : [
123
124        ]
125
126       },
127 {
128        editor : {
129         field : {
130          store : {
131           '|xns' : 'Roo.data',
132           data : [ 
133               [ 'ComboBox', "ComboBox"],
134               [ 'Text' , "TextField"],
135               [ 'Number', "NumberField"],
136               [ 'TextArea', "TextArea"],
137               [ 'Html', "HtmlEntry"]
138               
139           ],
140           fields : [  'ftype', 'fname'],
141           xns : Roo.data,
142           xtype : 'SimpleStore'
143          },
144          '|xns' : 'Roo.form',
145          allowBlank : false,
146          displayField : 'fname',
147          editable : false,
148          hiddenName : 'status',
149          listWidth : 200,
150          mode : 'local',
151          name : 'status',
152          triggerAction : 'all',
153          valueField : 'ftype',
154          width : 150,
155          xns : Roo.form,
156          xtype : 'ComboBox',
157          items : [
158
159          ]
160
161         },
162         '|xns' : 'Roo.grid',
163         xns : Roo.grid,
164         xtype : 'GridEditor',
165         items : [
166
167         ]
168
169        },
170        '|xns' : 'Roo.grid',
171        dataIndex : 'ftype',
172        header : _this._strings['189efd19c4153526994a6d7ea5f6f068'],
173        renderer : function(v) { return String.format('{0}', v); },
174        width : 75,
175        xns : Roo.grid,
176        xtype : 'ColumnModel',
177        items : [
178
179        ]
180
181       },
182 {
183        editor : {
184         field : {
185          store : {
186           '|xns' : 'Roo.data',
187           data : [ 
188               [ 'ComboBox', "ComboBox"],
189               [ 'Text' , "TextField"],
190               [ 'Number', "NumberField"],
191               [ 'TextArea', "TextArea"],
192               [ 'Html', "HtmlEntry"]
193               
194           ],
195           fields : [  'ftype', 'fname'],
196           xns : Roo.data,
197           xtype : 'SimpleStore'
198          },
199          '|xns' : 'Roo.form',
200          allowBlank : false,
201          displayField : 'fname',
202          editable : false,
203          hiddenName : 'status',
204          listWidth : 200,
205          mode : 'local',
206          name : 'status',
207          triggerAction : 'all',
208          valueField : 'ftype',
209          width : 150,
210          xns : Roo.form,
211          xtype : 'ComboBox',
212          items : [
213
214          ]
215
216         },
217         '|xns' : 'Roo.grid',
218         xns : Roo.grid,
219         xtype : 'GridEditor',
220         items : [
221
222         ]
223
224        },
225        '|xns' : 'Roo.grid',
226        dataIndex : 'ftype',
227        header : _this._strings['793548e77e782c209a78ed67f255b5e2'],
228        renderer : function(v) { return String.format('{0}', v); },
229        width : 75,
230        xns : Roo.grid,
231        xtype : 'ColumnModel',
232        items : [
233
234        ]
235
236       },
237 {
238        editor : {
239         field : {
240          '|xns' : 'Roo.form',
241          decimalPrecision : 0,
242          xns : Roo.form,
243          xtype : 'NumberField'
244         },
245         '|xns' : 'Roo.grid',
246         xns : Roo.grid,
247         xtype : 'GridEditor',
248         items : [
249
250         ]
251
252        },
253        '|xns' : 'Roo.grid',
254        dataIndex : 'width',
255        header : _this._strings['32954654ac8fe66a1d09be19001de2d4'],
256        renderer : function(v) { return String.format('{0}', v); },
257        width : 75,
258        xns : Roo.grid,
259        xtype : 'ColumnModel',
260        items : [
261
262        ]
263
264       }
265     ],
266     listeners : {
267      cellclick : function (_self, rowIndex, columnIndex, e)
268       {
269       
270               var di = this.colModel.getDataIndex(columnIndex);
271               if (di != 'active') {
272                   return;
273               }
274                
275               var rec = _this.grid.ds.getAt(rowIndex);
276               
277               rec.set('active', rec.data.active * 1 ? 0 : 1);
278               rec.commit();
279                
280               
281       },
282      render : function() 
283       {
284           _this.grid = this; 
285           //_this.dialog = Pman.Dialog.FILL_IN
286       
287       },
288      rowdblclick : function (_self, rowIndex, e)
289       {
290           if (!_this.dialog) return;
291         
292       }
293     },
294     items : [
295
296     ]
297
298    },
299    '|xns' : 'Roo',
300    background : false,
301    fitContainer : true,
302    fitToframe : true,
303    loadData : function(data) { 
304    
305         alert("IPC:TEST:" + JSON.stringify(data,null,4));
306        var ar = [];
307        for (var k in data) { 
308            var r = data[k];
309            var has_s = typeof(r.relates_to_schema) != 'undefined'
310            ar.push([ !has_s , r.Field, r.Type,  r.Field, 100] );
311            if (!has_s) {
312                continue;
313            }
314            for (var kk in r.relates_to_schema) {         
315                var rr = r.relates_to_schema[kk];
316                if (rr.Field == r.relates_to_col) {
317                    continue;
318                }
319                ar.push([ false, r.Field + '_'+ rr.Field, rr.Type,  rr.Field, 100] );
320            }
321        }
322        
323        alert("IPC:TEST:" + JSON.stringify(ar));
324        this.grid.dataSource.loadData(ar);
325    },
326    region : 'center',
327    tableName : 'core_enum',
328    title : _this._strings['c671c787b49f50a3ace9fdc5bd597825'],
329    title : _this._strings['c671c787b49f50a3ace9fdc5bd597825'],
330    toBJS : function() { 
331    
332    // convert the selected cells into a BJS data ready to send back to the UI..
333       
334        this.table = "XXX";
335        this.firstTxtCol = "XXX";
336       
337        
338        var jreader = {};
339        var     colmodel = [];
340        this.grid.dataSource.each(function(rec) {
341            if (!rec.data.active) {
342                return;
343            }
344            
345            
346            
347            colmodel.push({
348                "xtype": "ColumnModel",
349                "header": rec.data.title,
350                "width":  rec.data.width * 1,
351                "dataIndex": rec.data.dataIndex,
352                "|renderer": !rec.data.type.match(/date/i) ? 
353                        "function(v) { return String.format('{0}', v); }" :
354                        "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }" , // special for date
355                "|xns": "Roo.grid",
356                "*prop": "cm[]"
357            });
358        });
359        
360        
361        
362    
363        alert("IPC:OUT:" + JSON.stringify({
364            '|xns' : 'Roo',
365            xtype : "GridPanel",
366            "title": this.table,
367            "fitToframe": true,
368            "fitContainer": true,
369            "tableName": this.table,
370            "background": true,
371            "region" : 'center',
372            "listeners": {
373                "|activate": "function() {\n    _this.panel = this;\n    if (_this.grid) {\n        _this.grid.footer.onClick('first');\n    }\n}"
374            },
375            "items": [
376                {
377                    "*prop": "grid",
378                    "xtype": "Grid",
379                    "autoExpandColumn": this.firstTxtCol,
380                    "loadMask": true,
381                    "listeners": {
382                        "|render": "function() \n" +
383                            "{\n" +
384                            "    _this.grid = this; \n" +
385                            "    //_this.dialog = Pman.Dialog.FILL_IN\n" +
386                            "    if (_this.panel.active) {\n" +
387                            "       this.footer.onClick('first');\n" +
388                            "    }\n" +
389                            "}",
390                        "|rowdblclick": "function (_self, rowIndex, e)\n" + 
391                            "{\n" + 
392                            "    if (!_this.dialog) return;\n" + 
393                            "    _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {\n" + 
394                            "        _this.grid.footer.onClick('first');\n" + 
395                            "    }); \n" + 
396                            "}\n"
397                    },
398                    "|xns": "Roo.grid",
399    
400                    "items": [
401                        {
402                            "*prop": "dataSource",
403                            "xtype": "Store",
404                             remoteSort : true,
405                            '|sortInfo' : "{ field : '" + this.firstTxtCol  +  "', direction: 'ASC' }", 
406                            "|xns": "Roo.data",
407                            "items": [
408                                
409                                {
410                                    "*prop": "proxy",
411                                    "xtype": "HttpProxy",
412                                    "method": "GET",
413                                    "|url": "baseURL + '/Roo/" + this.table + ".php'",
414                                    "|xns": "Roo.data"
415                                },
416                                {
417                                    '*prop' : 'reader',
418                                    'xtype' : 'JsonReader',
419                                    '|xns' : 'Roo.data',
420                                    'id' : 'id',
421                                    'root' : 'data',
422                                    'totalProperty' : 'total'
423                                }
424                            ]
425                        },
426                        {
427                            "*prop": "footer",
428                            "xtype": "PagingToolbar",
429                            "pageSize": 25,
430                            "displayInfo": true,
431                            "displayMsg": "Displaying " + this.table + "{0} - {1} of {2}",
432                            "emptyMsg": "No " + this.table + " found",
433                            "|xns": "Roo"
434                        },
435                        {
436                            "*prop": "toolbar",
437                            "xtype": "Toolbar",
438                            "|xns": "Roo",
439                            "items": [
440                                {
441                                    "text": "Add",
442                                    "xtype": "Button",
443                                    "cls": "x-btn-text-icon",
444                                    "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'",
445                                    "listeners": {
446                                        "|click": "function()\n"+
447                                            "{\n"+
448                                            "    if (!_this.dialog) return;\n" +
449                                            "    _this.dialog.show( { id : 0 } , function() {\n"+
450                                            "        _this.grid.footer.onClick('first');\n"+
451                                            "   }); \n"+
452                                            "}\n"
453                                    },
454                                    "|xns": "Roo.Toolbar"
455                                },
456                                 // fill ????
457                                {
458                                    "text": "Delete",
459                                    "cls": "x-btn-text-icon",
460                                    "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
461                                    "xtype": "Button",
462                                    "listeners": {
463                                        "|click": "function()\n"+
464                                            "{\n"+
465                                            "     Pman.genericDelete(_this, '" + this.table + "'); \n"+
466                                            "}\n"+
467                                            "        "
468                                    },
469                                    "|xns": "Roo.Toolbar"
470                                }
471                            ]
472                        }, // end toolbar
473                    ].concat( colmodel)
474                }
475            ]
476            
477            
478        }, null, 4));
479    
480    },
481    xns : Roo,
482    xtype : 'GridPanel',
483    listeners : {
484     activate : function() {
485          _this.panel = this;
486          if (_this.grid) {
487              _this.grid.footer.onClick('first');
488          }
489      }
490    },
491    items : [
492
493    ]
494
495   };  }
496 });