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