sync
[Pman.Builder] / Pman.Dialog.BuilderAddTable.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Pman.Dialog.BuilderAddTable = {
6
7     dialog : false,
8     callback:  false,
9
10     show : function(data, cb)
11     {
12         if (!this.dialog) {
13             this.create();
14         }
15
16         this.callback = cb;
17         this.data = data;
18         this.dialog.show(this.data._el);
19         if (this.form) {
20            this.form.reset();
21            this.form.setValues(data);
22            this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
23         }
24
25     },
26
27     create : function()
28     {
29         var _this = this;
30         this.dialog = Roo.factory({
31             xtype: 'LayoutDialog',
32             xns: Roo,
33             listeners : {
34                 show : function (_self)
35                 {
36                     _this.grid.ds.load({});
37                 }
38             },
39             closable : false,
40             collapsible : false,
41             height : 500,
42             resizable : false,
43             title : "Select columns to use",
44             width : 700,
45             items : [
46                 {
47                     xtype: 'GridPanel',
48                     xns: Roo,
49                     listeners : {
50                         activate : function() {
51                             _this.panel = this;
52                             if (_this.grid) {
53                                 _this.grid.ds.load({});
54                             }
55                         }
56                     },
57                     background : false,
58                     fitContainer : true,
59                     fitToframe : true,
60                     region : 'center',
61                     tableName : 'Images',
62                     title : "Images",
63                     grid : {
64                         xtype: 'Grid',
65                         xns: Roo.grid,
66                         listeners : {
67                             render : function() 
68                             {
69                                 _this.grid = this; 
70                                 //_this.dialog = Pman.Dialog.FILL_IN
71                                 if (_this.panel.active) {
72                                    this.ds.load({});
73                                 }
74                             },
75                             cellclick : function (_self, ri, ci , e)
76                             {
77                                if (ci > 1) {return; }
78                                
79                                 var rec = this.ds.getAt(ri);
80                                 var di = this.cm.getDataIndex(ci);
81                                 rec.set(di, (rec.data[di] * 1) ? 0 : 1);
82                                  rec.commit();
83                                  
84                                   
85                                   
86                             }
87                         },
88                         autoExpandColumn : 'desc',
89                         loadMask : true,
90                         dataSource : {
91                             xtype: 'Store',
92                             xns: Roo.data,
93                             listeners : {
94                                 beforeload : function (_self, options)
95                                 {
96                                     if (typeof(_this.data) == 'undefined') {
97                                         return false;
98                                     
99                                     }
100                                     options.params = options.params || {};
101                                     options.params.table = _this.data.table;
102                                 }
103                             },
104                             remoteSort : true,
105                             sortInfo : { field : 'filename', direction: 'ASC' },
106                             proxy : {
107                                 xtype: 'HttpProxy',
108                                 xns: Roo.data,
109                                 method : 'GET',
110                                 url : baseURL + '/Builder/ERM.php'
111                             },
112                             reader : {
113                                 xtype: 'JsonReader',
114                                 xns: Roo.data,
115                                 id : 'id',
116                                 root : 'data',
117                                 totalProperty : 'total',
118                                 fields : [
119                                     { name: 'use', type: 'int'} , 
120                                     { name: 'use_ex', type: 'int'}, 
121                                     'table', 'column', 'ctype', 'desc', 'columnshort'
122                                 ]
123                             }
124                         },
125                         toolbar : {
126                             xtype: 'Toolbar',
127                             xns: Roo,
128                             items : [
129                                 {
130                                     xtype: 'Button',
131                                     xns: Roo.Toolbar,
132                                     listeners : {
133                                         click : function()
134                                         {
135                                             
136                                         }
137                                     },
138                                     cls : 'x-btn-text-icon',
139                                     text : "Add",
140                                     icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
141                                 },
142                                 {
143                                     xtype: 'Button',
144                                     xns: Roo.Toolbar,
145                                     listeners : {
146                                         click : function()
147                                         {
148                                             // Pman.genericDelete(_this, 'Images'); 
149                                         }
150                                     },
151                                     cls : 'x-btn-text-icon',
152                                     text : "Delete",
153                                     icon : rootURL + '/Pman/templates/images/trash.gif'
154                                 }
155                             ]
156                         },
157                         colModel : [
158                             {
159                                 xtype: 'ColumnModel',
160                                 xns: Roo.grid,
161                                 dataIndex : 'use',
162                                 header : 'Use',
163                                 width : 50,
164                                 renderer : function(v) {  
165                                     var state = v> 0 ?  '-checked' : '';
166                                 
167                                     return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
168                                 }
169                             },
170                             {
171                                 xtype: 'ColumnModel',
172                                 xns: Roo.grid,
173                                 dataIndex : 'use_ex',
174                                 header : 'Display/Expand',
175                                 width : 100,
176                                 renderer : function(v) {  
177                                     var state = v> 0 ?  '-checked' : '';
178                                 
179                                     return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
180                                                 
181                                  }
182                             },
183                             {
184                                 xtype: 'ColumnModel',
185                                 xns: Roo.grid,
186                                 dataIndex : 'table',
187                                 header : 'Table',
188                                 width : 100,
189                                 renderer : function(v) { return String.format('{0}', v); }
190                             },
191                             {
192                                 xtype: 'ColumnModel',
193                                 xns: Roo.grid,
194                                 dataIndex : 'column',
195                                 header : 'Column',
196                                 width : 150,
197                                 renderer : function(v,x,r) { 
198                                     if (r.data.table == _this.data.table) {
199                                     
200                                         return String.format('{0}', v); 
201                                     }
202                                     return String.format('.....{0}', r.data.columnshort); 
203                                 }
204                             },
205                             {
206                                 xtype: 'ColumnModel',
207                                 xns: Roo.grid,
208                                 dataIndex : 'ctype',
209                                 header : 'Type',
210                                 width : 50,
211                                 renderer : function(v) {
212                                 
213                                     v = v*1;
214                                 
215                                         
216                                 
217                                         if ((v & 8) > 0 && (v & 4) > 0) return 'DATETIME';
218                                         if ((v & 8) > 0)  return 'TIME';
219                                         if ((v & 4) > 0)  return 'DATE';        
220                                         if ((v & 16) > 0)  return 'BOOL';                
221                                         if ((v & 2) > 0)  return 'STRING';                
222                                         if ((v & 1) > 0) return 'NUMBER';                
223                                         return v;
224                                 
225                                  }
226                             },
227                             {
228                                 xtype: 'ColumnModel',
229                                 xns: Roo.grid,
230                                 dataIndex : 'desc',
231                                 header : 'Description',
232                                 width : 200,
233                                 renderer : function(v) { return String.format('{0}', v); }
234                             }
235                         ]
236                     }
237                 }
238             ],
239             center : {
240                 xtype: 'LayoutRegion',
241                 xns: Roo
242             },
243             buttons : [
244                 {
245                     xtype: 'Button',
246                     xns: Roo,
247                     listeners : {
248                         click : function (_self, e)
249                         {
250                             _this.dialog.hide();
251                         }
252                     },
253                     text : "Cancel"
254                 },
255                 {
256                     xtype: 'Button',
257                     xns: Roo,
258                     listeners : {
259                         click : function (_self, e)
260                         {
261                             // do some checks?
262                              
263                             
264                             _this.dialog.el.mask("Saving");
265                             _this.form.doAction("submit");
266                         
267                         }
268                     },
269                     text : "Next"
270                 }
271             ]
272         });
273     }
274 };