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            /*
315            for (var kk in r.relates_to_schema) {         
316                var rr = r.relates_to_schema[kk];
317                if (rr.Field == r.relates_to_col) {
318                    continue;
319                }
320                ar.push([ false, r.Field + '_'+ rr.Field, rr.Type,  rr.Field, 100] );
321            }
322            */
323        }
324        this.schema = data;
325        alert("IPC:TEST:" + JSON.stringify(ar));
326        this.grid.dataSource.loadData(ar);
327    },
328    region : 'center',
329    tableName : 'core_enum',
330    title : _this._strings['c671c787b49f50a3ace9fdc5bd597825'],
331    title : _this._strings['c671c787b49f50a3ace9fdc5bd597825'],
332    toBJS : function() { 
333    
334    // convert the selected cells into a BJS data ready to send back to the UI..
335       
336        this.table = "XXX";
337        this.firstTxtCol = "XXX";
338       
339        var formHeight = 50;
340        
341        var jreader = {};
342        var  formElements = [];
343        this.grid.dataSource.each(function(rec) {
344            if (!rec.data.active) {
345                return;
346            }
347            
348            var el = {
349                fieldLabel : rec.data.title,
350                name : rec.data.dataIndex,
351                width : 200, //row.type == 'string' ? 200 : 75,
352                '|xns' : 'Roo.form',
353                xtype : rec.data.ftype
354            }
355            
356            formElements.push(el);
357            
358            formHeight += rec.data.ftype == 'TextArea' ? 100 : 30;
359            
360            
361        });
362        
363        
364        
365        
366        
367        
368         var frmCfg = 
369        {
370            '|xns' : 'Roo.form',
371            xtype : "Form",
372            listeners : {
373                "|actioncomplete" : "function(_self,action)\n"+
374                    "{\n"+
375                    "    if (action.type == 'setdata') {\n"+
376                    "       //this.load({ method: 'GET', params: { '_id' : _this.data.id }});\n"+
377                    "       return;\n"+
378                    "    }\n"+
379                    "    if (action.type == 'load') {\n"+
380                    "        return;\n"+
381                    "    }\n"+
382                    "    if (action.type =='submit') {\n"+
383                    "    \n"+
384                    "        _this.dialog.hide();\n"+
385                    "    \n"+
386                    "         if (_this.callback) {\n"+
387                    "            _this.callback.call(_this, action.result.data);\n"+
388                    "         }\n"+
389                    "         _this.form.reset();\n"+
390                    "         return;\n"+
391                    "    }\n"+
392                    "}\n",
393                
394                "|rendered" : "function (form)\n"+
395                    "{\n"+
396                    "    _this.form= form;\n"+
397                    "}\n"
398            },
399            method : "POST",
400            style : "margin:10px;",
401            "|url" : "baseURL + '/Roo/" + this.table + "'",
402            items : formElements
403        };
404        
405    
406        alert("IPC:OUT:" + JSON.stringify({
407                "closable": false,
408                "collapsible": false,
409                "height": formHeight,
410                "resizable": false,
411                "title": "Edit / Create " + this.table,
412                "width": 400,
413                "modal" : true,
414                "xtype": "LayoutDialog",
415                "|xns": "Roo",
416                "items": [
417                    {
418                        "|xns": "Roo",
419                        "xtype": "LayoutRegion",
420                        "*prop": "center"
421                    },
422                    {
423                        "region": "center",
424                        "xtype": "ContentPanel",
425                        "|xns": "Roo",
426                        "items": [
427                            frmCfg
428                        ]
429                    },
430                    
431                    {
432                        "listeners": {
433                            "click": "function (_self, e)\n{\n    _this.dialog.hide();\n}"
434                        },
435                        "*prop": "buttons[]",
436                        "text": "Cancel",
437                        "xtype": "Button",
438                        "|xns": "Roo"
439                    },
440                    {
441                        "listeners": {
442                            "click": "function (_self, e)\n{\n    // do some checks?\n     \n    \n    _this.dialog.el.mask(\"Saving\");\n    _this.form.doAction(\"submit\");\n\n}"
443                        },
444                        "*prop": "buttons[]",
445                        "text": "Save",
446                        "xtype": "Button",
447                        "|xns": "Roo"
448                    }
449                ]
450            
451            
452            
453        }, null, 4));
454    
455    },
456    xns : Roo,
457    xtype : 'GridPanel',
458    listeners : {
459     activate : function() {
460          _this.panel = this;
461          if (_this.grid) {
462              _this.grid.footer.onClick('first');
463          }
464      }
465    },
466    items : [
467
468    ]
469
470   };  }
471 });