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        
340        var jreader = {};
341        var  colmodel = [];
342        this.grid.dataSource.each(function(rec) {
343            if (!rec.data.active) {
344                return;
345            }
346            
347            
348            
349            colmodel.push({
350                "xtype": "ColumnModel",
351                "header": rec.data.title,
352                "width":  rec.data.width * 1,
353                "dataIndex": rec.data.dataIndex,
354                "|renderer": !rec.data.type.match(/date/i) ? 
355                        "function(v) { return String.format('{0}', v); }" :
356                        "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }" , // special for date
357                "|xns": "Roo.grid",
358                "*prop": "cm[]"
359            });
360        });
361        
362         var frmCfg = 
363        {
364            '|xns' : 'Roo.form',
365            xtype : "Form",
366            listeners : {
367                "|actioncomplete" : "function(_self,action)\n"+
368                    "{\n"+
369                    "    if (action.type == 'setdata') {\n"+
370                    "       //this.load({ method: 'GET', params: { '_id' : _this.data.id }});\n"+
371                    "       return;\n"+
372                    "    }\n"+
373                    "    if (action.type == 'load') {\n"+
374                    "        return;\n"+
375                    "    }\n"+
376                    "    if (action.type =='submit') {\n"+
377                    "    \n"+
378                    "        _this.dialog.hide();\n"+
379                    "    \n"+
380                    "         if (_this.callback) {\n"+
381                    "            _this.callback.call(_this, action.result.data);\n"+
382                    "         }\n"+
383                    "         _this.form.reset();\n"+
384                    "         return;\n"+
385                    "    }\n"+
386                    "}\n",
387                
388                "|rendered" : "function (form)\n"+
389                    "{\n"+
390                    "    _this.form= form;\n"+
391                    "}\n"
392            },
393            method : "POST",
394            style : "margin:10px;",
395            "|url" : "baseURL + '/Roo/" + this.table + "'",
396            items : formElements
397        };
398        
399    
400        alert("IPC:OUT:" + JSON.stringify({
401                "closable": false,
402                "collapsible": false,
403                "height": formHeight,
404                "resizable": false,
405                "title": "Edit / Create " + this.table,
406                "width": 400,
407                "modal" : true,
408                "xtype": "LayoutDialog",
409                "|xns": "Roo",
410                "items": [
411                    {
412                        "|xns": "Roo",
413                        "xtype": "LayoutRegion",
414                        "*prop": "center"
415                    },
416                    {
417                        "region": "center",
418                        "xtype": "ContentPanel",
419                        "|xns": "Roo",
420                        "items": [
421                            frmCfg
422                        ]
423                    },
424                    
425                    {
426                        "listeners": {
427                            "click": "function (_self, e)\n{\n    _this.dialog.hide();\n}"
428                        },
429                        "*prop": "buttons[]",
430                        "text": "Cancel",
431                        "xtype": "Button",
432                        "|xns": "Roo"
433                    },
434                    {
435                        "listeners": {
436                            "click": "function (_self, e)\n{\n    // do some checks?\n     \n    \n    _this.dialog.el.mask(\"Saving\");\n    _this.form.doAction(\"submit\");\n\n}"
437                        },
438                        "*prop": "buttons[]",
439                        "text": "Save",
440                        "xtype": "Button",
441                        "|xns": "Roo"
442                    }
443                ]
444            
445            
446            
447        }, null, 4));
448    
449    },
450    xns : Roo,
451    xtype : 'GridPanel',
452    listeners : {
453     activate : function() {
454          _this.panel = this;
455          if (_this.grid) {
456              _this.grid.footer.onClick('first');
457          }
458      }
459    },
460    items : [
461
462    ]
463
464   };  }
465 });