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