988d573eeae03fd75fcca444d75ff9ebf404e2c0
[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   'dc30ec20708ef7b0f641ef78b7880a15' :"DEBUG",
18   '32954654ac8fe66a1d09be19001de2d4' :"Width",
19   'a1fa27779242b4902f7ae3bdd5c6d508' :"Type",
20   '6e7376dca68a2386a8737944196ab491' :"Create / Edit Grid"
21  },
22
23   part     :  ["Editors", "LayoutDialog" ],
24   order    : '001-Editor.Roo.LayoutDialog',
25   region   : 'center',
26   parent   : false,
27   name     : "unnamed module",
28   disabled : false, 
29   permname : '', 
30   _tree : function()
31   {
32    var _this = this;
33    var MODULE = this;
34    return {
35    grid : {
36     ds : {
37      '|xns' : 'Roo.data',
38      data : [
39        [ 1, 'test', 'test', 110 ]
40        
41      
42      ],
43      fields : [ 'active', 'dataIndex', 'type','title', 'width', 'ftype', 'display_field' ],
44      id : 'dataindex',
45      xns : Roo.data,
46      xtype : 'SimpleStore'
47     },
48     toolbar : {
49      '|xns' : 'Roo',
50      xns : Roo,
51      xtype : 'Toolbar',
52      items : [
53       {
54        '|xns' : 'Roo.Toolbar',
55        text : _this._strings['2f616612593df62aeed112de4f03110e'],
56        xns : Roo.Toolbar,
57        xtype : 'TextItem'
58       },
59       {
60        '|xns' : 'Roo.Toolbar',
61        xns : Roo.Toolbar,
62        xtype : 'Fill'
63       },
64       {
65        '|xns' : 'Roo.Toolbar',
66        text : _this._strings['dc30ec20708ef7b0f641ef78b7880a15'],
67        xns : Roo.Toolbar,
68        xtype : 'Button',
69        listeners : {
70         click : function (_self, e)
71          {
72              var data = ""
73          }
74        }
75       }
76      ]
77
78     },
79     '|xns' : 'Roo.grid',
80     autoExpandColumn : 'title',
81     clicksToEdit : 1,
82     loadMask : true,
83     xns : Roo.grid,
84     xtype : 'EditorGrid',
85     cm : [
86       {
87        '|xns' : 'Roo.grid',
88        dataIndex : 'active',
89        header : _this._strings['0ccc2bf3fb98387c23b6ca5500244d6e'],
90        renderer : function(v) {  
91            var state = v *1 > 0 ?  '-checked' : '';
92        
93            return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
94                        
95         },
96        width : 75,
97        xns : Roo.grid,
98        xtype : 'ColumnModel'
99       },
100 {
101        '|xns' : 'Roo.grid',
102        dataIndex : 'dataIndex',
103        header : _this._strings['4ce58cbe362a5d7b156992a496d55bf3'],
104        renderer : function(v) { return String.format('{0}', v); },
105        width : 150,
106        xns : Roo.grid,
107        xtype : 'ColumnModel'
108       },
109 {
110        '|xns' : 'Roo.grid',
111        dataIndex : 'type',
112        header : _this._strings['a1fa27779242b4902f7ae3bdd5c6d508'],
113        renderer : function(v) { return String.format('{0}', v); },
114        width : 100,
115        xns : Roo.grid,
116        xtype : 'ColumnModel'
117       },
118 {
119        editor : {
120         field : {
121          '|xns' : 'Roo.form',
122          xns : Roo.form,
123          xtype : 'TextField'
124         },
125         '|xns' : 'Roo.grid',
126         xns : Roo.grid,
127         xtype : 'GridEditor',
128         items : [
129
130         ]
131
132        },
133        '|xns' : 'Roo.grid',
134        dataIndex : 'title',
135        header : _this._strings['b021df6aac4654c454f46c77646e745f'],
136        renderer : function(v) { return String.format('{0}', v); },
137        width : 120,
138        xns : Roo.grid,
139        xtype : 'ColumnModel',
140        items : [
141
142        ]
143
144       },
145 {
146        editor : {
147         field : {
148          store : {
149           '|xns' : 'Roo.data',
150           data : [ 
151               [ 'ComboBox', "ComboBox"],
152               [ 'TextField' , "TextField"],
153               [ 'NumberField', "NumberField"],
154               [ 'TextArea', "TextArea"],
155               [ 'HtmlEditor', "HtmlEditor"],
156               [ 'Hidden', "Hidden"],
157               [ 'DateField', "DateField"]    ,
158                [ 'Checkbox', "Checkbox"]    
159               // checkbox?
160           ],
161           fields : [  'ftype', 'fname'],
162           xns : Roo.data,
163           xtype : 'SimpleStore'
164          },
165          '|xns' : 'Roo.form',
166          allowBlank : false,
167          displayField : 'fname',
168          editable : false,
169          hiddenName : 'status',
170          listWidth : 200,
171          mode : 'local',
172          name : 'field_type',
173          triggerAction : 'all',
174          valueField : 'ftype',
175          width : 150,
176          xns : Roo.form,
177          xtype : 'ComboBox',
178          items : [
179
180          ]
181
182         },
183         '|xns' : 'Roo.grid',
184         xns : Roo.grid,
185         xtype : 'GridEditor',
186         items : [
187
188         ]
189
190        },
191        '|xns' : 'Roo.grid',
192        dataIndex : 'ftype',
193        header : _this._strings['189efd19c4153526994a6d7ea5f6f068'],
194        renderer : function(v) { return String.format('{0}', v); },
195        width : 120,
196        xns : Roo.grid,
197        xtype : 'ColumnModel',
198        items : [
199
200        ]
201
202       },
203 {
204        editor : {
205         field : {
206          store : {
207           '|xns' : 'Roo.data',
208           data : [ 
209               [ 'ComboBox', "ComboBox"],
210               [ 'Text' , "TextField"],
211               [ 'Number', "NumberField"],
212               [ 'TextArea', "TextArea"],
213               [ 'Html', "HtmlEntry"]
214               
215           ],
216           fields : [  'ftype', 'fname'],
217           xns : Roo.data,
218           xtype : 'SimpleStore'
219          },
220          '|xns' : 'Roo.form',
221          allowBlank : false,
222          displayField : 'fname',
223          editable : false,
224          hiddenName : 'status',
225          listWidth : 200,
226          mode : 'local',
227          name : 'combo_display',
228          triggerAction : 'all',
229          valueField : 'ftype',
230          width : 150,
231          xns : Roo.form,
232          xtype : 'ComboBox',
233          items : [
234
235          ]
236
237         },
238         '|xns' : 'Roo.grid',
239         xns : Roo.grid,
240         xtype : 'GridEditor',
241         items : [
242
243         ]
244
245        },
246        '|xns' : 'Roo.grid',
247        dataIndex : 'display_field',
248        header : _this._strings['793548e77e782c209a78ed67f255b5e2'],
249        renderer : function(v) { return String.format('{0}', v); },
250        width : 150,
251        xns : Roo.grid,
252        xtype : 'ColumnModel',
253        items : [
254
255        ]
256
257       },
258 {
259        editor : {
260         field : {
261          '|xns' : 'Roo.form',
262          decimalPrecision : 0,
263          xns : Roo.form,
264          xtype : 'NumberField'
265         },
266         '|xns' : 'Roo.grid',
267         xns : Roo.grid,
268         xtype : 'GridEditor',
269         items : [
270
271         ]
272
273        },
274        '|xns' : 'Roo.grid',
275        dataIndex : 'width',
276        header : _this._strings['32954654ac8fe66a1d09be19001de2d4'],
277        renderer : function(v) { return String.format('{0}', v); },
278        width : 75,
279        xns : Roo.grid,
280        xtype : 'ColumnModel',
281        items : [
282
283        ]
284
285       }
286     ],
287     listeners : {
288      cellclick : function (_self, rowIndex, columnIndex, e)
289       {
290       
291               var di = this.colModel.getDataIndex(columnIndex);
292               if (di != 'active') {
293                   return;
294               }
295                
296               var rec = _this.grid.ds.getAt(rowIndex);
297               
298               rec.set('active', rec.data.active * 1 ? 0 : 1);
299               rec.commit();
300                
301               
302       },
303      render : function() 
304       {
305           _this.grid = this; 
306           //_this.dialog = Pman.Dialog.FILL_IN
307       
308       },
309      rowdblclick : function (_self, rowIndex, e)
310       {
311           if (!_this.dialog) return;
312         
313       }
314     },
315     items : [
316
317     ]
318
319    },
320    '|xns' : 'Roo',
321    background : false,
322    fitContainer : true,
323    fitToframe : true,
324    loadData : function(data) { 
325    
326        alert("IPC:TEST:" + JSON.stringify(data,null,4));
327        
328        var ar = [];
329        for (var k in data) { 
330            var r = data[k];
331            var has_s = typeof(r.relates_to_schema) != 'undefined'
332            ar.push([ !has_s , r.Field, r.Type,  r.Field, 100 , 'TextField', r.Field + '_display_name'] );
333            if (!has_s) {
334                continue;
335            }
336            /*
337            for (var kk in r.relates_to_schema) {         
338                var rr = r.relates_to_schema[kk];
339                if (rr.Field == r.relates_to_col) {
340                    continue;
341                }
342                ar.push([ false, r.Field + '_'+ rr.Field, rr.Type,  rr.Field, 100] );
343            }
344            */
345        }
346        this.schema = data;
347        //alert("IPC:TEST:" + JSON.stringify(ar));
348        this.grid.dataSource.loadData(ar);
349    },
350    region : 'center',
351    tableName : 'core_enum',
352    title : _this._strings['c671c787b49f50a3ace9fdc5bd597825'],
353    title : _this._strings['c671c787b49f50a3ace9fdc5bd597825'],
354    toBJS : function() { 
355    
356    // convert the selected cells into a BJS data ready to send back to the UI..
357    
358        this.table = "XXX";
359        this.firstTxtCol = "XXX";
360       
361        var formHeight = 50;
362        
363        var jreader = {};
364        var  formElements = [];
365        this.grid.dataSource.each(function(rec) {
366            if (!rec.data.active) {
367                return;
368            }
369            
370            var el = {
371                fieldLabel : rec.data.title,
372                name : rec.data.dataIndex,
373                width : 200, //row.type == 'string' ? 200 : 75,
374                '|xns' : 'Roo.form',
375                xtype : rec.data.ftype
376            }
377             if (xtype == 'DateField') {
378                el.format = 'Y-m-d';
379                el.useIso = true;
380                el.width = 100;
381            }
382            
383            if (xtype == 'TextArea') {
384                el.height = 100;
385            }
386            
387            if (xtype == 'Hidden') {
388                delete el.fieldLabel;
389                delete el.width;
390            }
391            if (xtype == 'Combobox') {
392            
393    
394                el.queryParam  = 'query[' + combofields_name + ']';// SET WHEN USED
395                
396                el.hiddenName = rec.data.dataIndex // SET WHEN USED eg. project_id
397                el.displayField = combofields_name; // SET WHEN USED eg. project_id
398                el.name  = old.name + '_' + combofields_name; // SET WHEN USED eg. project_id_name
399                el.tpl = '<div class="x-grid-cell-text x-btn button"><b>{' + combofields_name +'}</b> </div>'; // SET WHEN USED
400              
401            
402               el.items = [
403                    {
404                            
405                        '*prop' : 'store',
406                        'xtype' : 'Store',
407                        '|xns' : 'Roo.data',
408                        'remoteSort' : true,
409                        '|sortInfo' : '{ direction : \'ASC\', field: \'id\' }',
410                        listeners : {
411                            '|beforeload' : 'function (_self, o)' +
412                            "{\n" +
413                            "    o.params = o.params || {};\n" +
414                            "    // set more here\n" +
415                            "}\n"
416                        },
417                        items : [
418                            {
419                                '*prop' : 'proxy',
420                                'xtype' : 'HttpProxy',
421                                'method' : 'GET',
422                                '|xns' : 'Roo.data',
423                                '|url' : "baseURL + '/Roo/" + reftable + ".php'",
424                            },
425                            
426                            {
427                                '*prop' : 'reader',
428                                'xtype' : 'JsonReader',
429                                '|xns' : 'Roo.data',
430                                'id' : 'id',
431                                'root' : 'data',
432                                'totalProperty' : 'total'
433    
434                                
435                            }
436                        ]
437                    }
438                ];
439            
440            }
441            
442            
443            formElements.push(el);
444            
445            formHeight += rec.data.ftype == 'TextArea' ? 100 : 30;
446            
447            
448        });
449        
450        
451        
452        
453        
454        
455         var frmCfg = 
456        {
457            '|xns' : 'Roo.form',
458            xtype : "Form",
459            listeners : {
460                "|actioncomplete" : "function(_self,action)\n"+
461                    "{\n"+
462                    "    if (action.type == 'setdata') {\n"+
463                    "       //this.load({ method: 'GET', params: { '_id' : _this.data.id }});\n"+
464                    "       return;\n"+
465                    "    }\n"+
466                    "    if (action.type == 'load') {\n"+
467                    "        return;\n"+
468                    "    }\n"+
469                    "    if (action.type =='submit') {\n"+
470                    "    \n"+
471                    "        _this.dialog.hide();\n"+
472                    "    \n"+
473                    "         if (_this.callback) {\n"+
474                    "            _this.callback.call(_this, action.result.data);\n"+
475                    "         }\n"+
476                    "         _this.form.reset();\n"+
477                    "         return;\n"+
478                    "    }\n"+
479                    "}\n",
480                
481                "|rendered" : "function (form)\n"+
482                    "{\n"+
483                    "    _this.form= form;\n"+
484                    "}\n"
485            },
486            method : "POST",
487            style : "margin:10px;",
488            "|url" : "baseURL + '/Roo/" + this.table + "'",
489            items : formElements
490        };
491        
492    
493        alert("IPC:OUT:" + JSON.stringify({
494                "closable": false,
495                "collapsible": false,
496                "height": formHeight,
497                "resizable": false,
498                "title": "Edit / Create " + this.table,
499                "width": 400,
500                "modal" : true,
501                "xtype": "LayoutDialog",
502                "|xns": "Roo",
503                "items": [
504                    {
505                        "|xns": "Roo",
506                        "xtype": "LayoutRegion",
507                        "*prop": "center"
508                    },
509                    {
510                        "region": "center",
511                        "xtype": "ContentPanel",
512                        "|xns": "Roo",
513                        "items": [
514                            frmCfg
515                        ]
516                    },
517                    
518                    {
519                        "listeners": {
520                            "click": "function (_self, e)\n{\n    _this.dialog.hide();\n}"
521                        },
522                        "*prop": "buttons[]",
523                        "text": "Cancel",
524                        "xtype": "Button",
525                        "|xns": "Roo"
526                    },
527                    {
528                        "listeners": {
529                            "click": "function (_self, e)\n{\n    // do some checks?\n     \n    \n    _this.dialog.el.mask(\"Saving\");\n    _this.form.doAction(\"submit\");\n\n}"
530                        },
531                        "*prop": "buttons[]",
532                        "text": "Save",
533                        "xtype": "Button",
534                        "|xns": "Roo"
535                    }
536                ]
537            
538            
539            
540        }, null, 4));
541    
542    },
543    xns : Roo,
544    xtype : 'GridPanel',
545    listeners : {
546     activate : function() {
547          _this.panel = this;
548          if (_this.grid) {
549              _this.grid.footer.onClick('first');
550          }
551      }
552    },
553    items : [
554
555    ]
556
557   };  }
558 });