f66a1f5d3f8cd3054704fcc281b15272f10f781c
[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               [ 'O', "Open"],
133               [ 'C' , "Closed"],
134               [ 'A', "All"] 
135           ],
136           fields : [  'ftype', 'fname'],
137           xns : Roo.data,
138           xtype : 'SimpleStore'
139          },
140          '|xns' : 'Roo.form',
141          allowBlank : false,
142          displayField : 'fname',
143          editable : false,
144          fieldLabel : 'Status',
145          hiddenName : 'status',
146          listWidth : 200,
147          mode : 'local',
148          name : 'status',
149          triggerAction : 'all',
150          value : _this._strings['7fc56270e7a70fa81a5935b72eacbe29'],
151          valueField : 'ftype',
152          width : 150,
153          xns : Roo.form,
154          xtype : 'ComboBox',
155          listeners : {
156           render : function (_self)
157            {
158              _this.status = _self;
159            },
160           select : function (combo, record, index)
161            {
162                _this.grid.ds.load({});
163            }
164          },
165          items : [
166
167          ]
168
169         },
170         '|xns' : 'Roo.grid',
171         xns : Roo.grid,
172         xtype : 'GridEditor',
173         items : [
174
175         ]
176
177        },
178        '|xns' : 'Roo.grid',
179        dataIndex : 'title',
180        header : _this._strings['b021df6aac4654c454f46c77646e745f'],
181        renderer : function(v) { return String.format('{0}', v); },
182        width : 75,
183        xns : Roo.grid,
184        xtype : 'ColumnModel',
185        items : [
186
187        ]
188
189       },
190 {
191        editor : {
192         field : {
193          '|xns' : 'Roo.form',
194          decimalPrecision : 0,
195          xns : Roo.form,
196          xtype : 'NumberField'
197         },
198         '|xns' : 'Roo.grid',
199         xns : Roo.grid,
200         xtype : 'GridEditor',
201         items : [
202
203         ]
204
205        },
206        '|xns' : 'Roo.grid',
207        dataIndex : 'width',
208        header : _this._strings['32954654ac8fe66a1d09be19001de2d4'],
209        renderer : function(v) { return String.format('{0}', v); },
210        width : 75,
211        xns : Roo.grid,
212        xtype : 'ColumnModel',
213        items : [
214
215        ]
216
217       }
218     ],
219     listeners : {
220      cellclick : function (_self, rowIndex, columnIndex, e)
221       {
222       
223               var di = this.colModel.getDataIndex(columnIndex);
224               if (di != 'active') {
225                   return;
226               }
227                
228               var rec = _this.grid.ds.getAt(rowIndex);
229               
230               rec.set('active', rec.data.active * 1 ? 0 : 1);
231               rec.commit();
232                
233               
234       },
235      render : function() 
236       {
237           _this.grid = this; 
238           //_this.dialog = Pman.Dialog.FILL_IN
239       
240       },
241      rowdblclick : function (_self, rowIndex, e)
242       {
243           if (!_this.dialog) return;
244         
245       }
246     },
247     items : [
248
249     ]
250
251    },
252    '|xns' : 'Roo',
253    background : false,
254    fitContainer : true,
255    fitToframe : true,
256    loadData : function(data) { 
257    
258         alert("IPC:TEST:" + JSON.stringify(data,null,4));
259        var ar = [];
260        for (var k in data) { 
261            var r = data[k];
262            var has_s = typeof(r.relates_to_schema) != 'undefined'
263            ar.push([ !has_s , r.Field, r.Type,  r.Field, 100] );
264            if (!has_s) {
265                continue;
266            }
267            for (var kk in r.relates_to_schema) {         
268                var rr = r.relates_to_schema[kk];
269                if (rr.Field == r.relates_to_col) {
270                    continue;
271                }
272                ar.push([ false, r.Field + '_'+ rr.Field, rr.Type,  rr.Field, 100] );
273            }
274        }
275        
276        alert("IPC:TEST:" + JSON.stringify(ar));
277        this.grid.dataSource.loadData(ar);
278    },
279    region : 'center',
280    tableName : 'core_enum',
281    title : _this._strings['c671c787b49f50a3ace9fdc5bd597825'],
282    title : _this._strings['c671c787b49f50a3ace9fdc5bd597825'],
283    toBJS : function() { 
284    
285    // convert the selected cells into a BJS data ready to send back to the UI..
286       
287        this.table = "XXX";
288        this.firstTxtCol = "XXX";
289       
290        
291        var jreader = {};
292        var     colmodel = [];
293        this.grid.dataSource.each(function(rec) {
294            if (!rec.data.active) {
295                return;
296            }
297            
298            
299            
300            colmodel.push({
301                "xtype": "ColumnModel",
302                "header": rec.data.title,
303                "width":  rec.data.width * 1,
304                "dataIndex": rec.data.dataIndex,
305                "|renderer": !rec.data.type.match(/date/i) ? 
306                        "function(v) { return String.format('{0}', v); }" :
307                        "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }" , // special for date
308                "|xns": "Roo.grid",
309                "*prop": "cm[]"
310            });
311        });
312        
313        
314        
315    
316        alert("IPC:OUT:" + JSON.stringify({
317            '|xns' : 'Roo',
318            xtype : "GridPanel",
319            "title": this.table,
320            "fitToframe": true,
321            "fitContainer": true,
322            "tableName": this.table,
323            "background": true,
324            "region" : 'center',
325            "listeners": {
326                "|activate": "function() {\n    _this.panel = this;\n    if (_this.grid) {\n        _this.grid.footer.onClick('first');\n    }\n}"
327            },
328            "items": [
329                {
330                    "*prop": "grid",
331                    "xtype": "Grid",
332                    "autoExpandColumn": this.firstTxtCol,
333                    "loadMask": true,
334                    "listeners": {
335                        "|render": "function() \n" +
336                            "{\n" +
337                            "    _this.grid = this; \n" +
338                            "    //_this.dialog = Pman.Dialog.FILL_IN\n" +
339                            "    if (_this.panel.active) {\n" +
340                            "       this.footer.onClick('first');\n" +
341                            "    }\n" +
342                            "}",
343                        "|rowdblclick": "function (_self, rowIndex, e)\n" + 
344                            "{\n" + 
345                            "    if (!_this.dialog) return;\n" + 
346                            "    _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {\n" + 
347                            "        _this.grid.footer.onClick('first');\n" + 
348                            "    }); \n" + 
349                            "}\n"
350                    },
351                    "|xns": "Roo.grid",
352    
353                    "items": [
354                        {
355                            "*prop": "dataSource",
356                            "xtype": "Store",
357                             remoteSort : true,
358                            '|sortInfo' : "{ field : '" + this.firstTxtCol  +  "', direction: 'ASC' }", 
359                            "|xns": "Roo.data",
360                            "items": [
361                                
362                                {
363                                    "*prop": "proxy",
364                                    "xtype": "HttpProxy",
365                                    "method": "GET",
366                                    "|url": "baseURL + '/Roo/" + this.table + ".php'",
367                                    "|xns": "Roo.data"
368                                },
369                                {
370                                    '*prop' : 'reader',
371                                    'xtype' : 'JsonReader',
372                                    '|xns' : 'Roo.data',
373                                    'id' : 'id',
374                                    'root' : 'data',
375                                    'totalProperty' : 'total'
376                                }
377                            ]
378                        },
379                        {
380                            "*prop": "footer",
381                            "xtype": "PagingToolbar",
382                            "pageSize": 25,
383                            "displayInfo": true,
384                            "displayMsg": "Displaying " + this.table + "{0} - {1} of {2}",
385                            "emptyMsg": "No " + this.table + " found",
386                            "|xns": "Roo"
387                        },
388                        {
389                            "*prop": "toolbar",
390                            "xtype": "Toolbar",
391                            "|xns": "Roo",
392                            "items": [
393                                {
394                                    "text": "Add",
395                                    "xtype": "Button",
396                                    "cls": "x-btn-text-icon",
397                                    "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'",
398                                    "listeners": {
399                                        "|click": "function()\n"+
400                                            "{\n"+
401                                            "    if (!_this.dialog) return;\n" +
402                                            "    _this.dialog.show( { id : 0 } , function() {\n"+
403                                            "        _this.grid.footer.onClick('first');\n"+
404                                            "   }); \n"+
405                                            "}\n"
406                                    },
407                                    "|xns": "Roo.Toolbar"
408                                },
409                                 // fill ????
410                                {
411                                    "text": "Delete",
412                                    "cls": "x-btn-text-icon",
413                                    "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
414                                    "xtype": "Button",
415                                    "listeners": {
416                                        "|click": "function()\n"+
417                                            "{\n"+
418                                            "     Pman.genericDelete(_this, '" + this.table + "'); \n"+
419                                            "}\n"+
420                                            "        "
421                                    },
422                                    "|xns": "Roo.Toolbar"
423                                }
424                            ]
425                        }, // end toolbar
426                    ].concat( colmodel)
427                }
428            ]
429            
430            
431        }, null, 4));
432    
433    },
434    xns : Roo,
435    xtype : 'GridPanel',
436    listeners : {
437     activate : function() {
438          _this.panel = this;
439          if (_this.grid) {
440              _this.grid.footer.onClick('first');
441          }
442      }
443    },
444    items : [
445
446    ]
447
448   };  }
449 });