Pman.Dialog.AdminCoreEnum.bjs
[Pman.Admin] / Pman.Dialog.AdminCoreEnum.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.AdminCoreEnum = {
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             height : 400,
34             title : "Pulldown Options",
35             width : 950,
36             items : [
37                 {
38                     xtype: 'GridPanel',
39                     xns: Roo,
40                     listeners : {
41                         activate : function() {
42                             _this.panel = this;
43                             if (_this.grid) {
44                              //   _this.grid.footer.onClick('first');
45                             }
46                         }
47                     },
48                     background : false,
49                     fitContainer : true,
50                     fitToframe : true,
51                     region : 'center',
52                     tableName : 'core_enum',
53                     title : "Pulldown Options",
54                     grid : {
55                         xtype: 'EditorGrid',
56                         xns: Roo.grid,
57                         listeners : {
58                             render : function() 
59                             {
60                                 _this.grid = this; 
61                                 //_this.dialog = Pman.Dialog.FILL_IN
62                                 if (_this.panel.active) {
63                                //    this.footer.onClick('first');
64                                 }
65                             },
66                             afteredit : function (e)
67                             {
68                                e.record.commit();     
69                             },
70                             cellclick : function (_self, rowIndex, columnIndex, e)
71                             {
72                             
73                                     var di = this.colModel.getDataIndex(columnIndex);
74                                     if (di != 'active') {
75                                         return;
76                                     }
77                                      
78                                     var rec = _this.grid.ds.getAt(rowIndex);
79                                     
80                                     rec.set('active', rec.data.active ? 0 : 1);
81                                     rec.commit();
82                                      
83                                     
84                             },
85                             beforeedit : function (e)
86                             {
87                                 if(e.field == 'name' && e.record.data.is_system_enum*1 == 1){
88                                     return false;
89                                 }
90                             }
91                         },
92                         autoExpandColumn : 'display_name',
93                         clicksToEdit : 1,
94                         loadMask : true,
95                         dataSource : {
96                             xtype: 'Store',
97                             xns: Roo.data,
98                             listeners : {
99                                 beforeload : function (_self, options)
100                                 {
101                                     if (!_this.etypeCombo) {
102                                         return false;
103                                     }
104                                     options.params.etype = _this.etypeCombo.getValue();
105                                     if (!options.params.etype.length) {
106                                         return false;
107                                     }
108                                 },
109                                 update : function (_self, record, operation)
110                                 {
111                                     if (operation != Roo.data.Record.COMMIT) {
112                                         return;
113                                     }
114                                     // got commit..
115                                     new Pman.Request({
116                                         url : baseURL + '/Roo/Core_enum.php',
117                                         method : 'POST',
118                                         params : {
119                                             id : record.data.id,
120                                             etype : _this.etypeCombo.getValue(),
121                                             name : record.data.name,
122                                             active : record.data.active,
123                                             seqid : record.data.seqid,
124                                             display_name : record.data.display_name
125                                         }, 
126                                         success : function(res) {
127                                             //Roo.log(data);
128                                             // update the ID if it's not set..
129                                             if (record.data.id * 1 < 1) {
130                                                 record.set('id', res.data.id);
131                                             }
132                                         }
133                                     });
134                                     
135                                 }
136                             },
137                             remoteSort : true,
138                             sortInfo : { field : 'etype', direction: 'ASC' },
139                             proxy : {
140                                 xtype: 'HttpProxy',
141                                 xns: Roo.data,
142                                 method : 'GET',
143                                 url : baseURL + '/Roo/core_enum.php'
144                             },
145                             reader : {
146                                 xtype: 'JsonReader',
147                                 xns: Roo.data,
148                                 totalProperty : 'total',
149                                 root : 'data',
150                                 id : 'id',
151                                 fields : [
152                                     {
153                                         'name': 'id',
154                                         'type': 'int'
155                                     },
156                                     {
157                                         'name': 'etype',
158                                         'type': 'string'
159                                     },
160                                     {
161                                         'name': 'name',
162                                         'type': 'string'
163                                     },
164                                     {
165                                         'name': 'active',
166                                         'type': 'int'
167                                     },
168                                     {
169                                         'name': 'seqid',
170                                         'type': 'int'
171                                     }
172                                 ]
173                             }
174                         },
175                         footer : {
176                             xtype: 'PagingToolbar',
177                             xns: Roo,
178                             pageSize : 25,
179                             displayInfo : true,
180                             displayMsg : "Displaying core_enum{0} - {1} of {2}",
181                             emptyMsg : "No core_enum found"
182                         },
183                         toolbar : {
184                             xtype: 'Toolbar',
185                             xns: Roo,
186                             items : [
187                                 {
188                                     xtype: 'Button',
189                                     xns: Roo.Toolbar,
190                                     listeners : {
191                                         click : function()
192                                         {
193                                             
194                                             // if we do not have a selected type... - what should we show..?
195                                             var et = _this.etypeCombo.getValue();
196                                             var ds = _this.grid.getDataSource();
197                                             if (!et) {
198                                                 Roo.MessageBox.alert("Error", "Select a pulldown");
199                                                 return;
200                                             }
201                                         
202                                             var add = ds.reader.newRow({    
203                                                      id: 0, 
204                                                      display_name : '', 
205                                                      name : '', 
206                                                      etype: et, 
207                                                      active: 1, 
208                                                      seqid: 0
209                                               });
210                                              var r = ds.data.length;
211                                             ds.insert(r  , add);  
212                                             _this.grid.startEditing(r, 1); // name... 
213                                         }
214                                     },
215                                     cls : 'x-btn-text-icon',
216                                     text : "Add Value",
217                                     icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
218                                 },
219                                 {
220                                     xtype: 'Fill',
221                                     xns: Roo.Toolbar
222                                 }
223                             ]
224                         },
225                         colModel : [
226                             {
227                                 xtype: 'ColumnModel',
228                                 xns: Roo.grid,
229                                 dataIndex : 'id',
230                                 header : 'Internal #',
231                                 width : 75,
232                                 renderer : function(v) { return String.format('{0}', v); }
233                             },
234                             {
235                                 xtype: 'ColumnModel',
236                                 xns: Roo.grid,
237                                 dataIndex : 'images_id_id',
238                                 header : 'Image',
239                                 width : 75,
240                                 renderer : function(v,x,r) { return String.format('<img src="{0}/Images/Thumb/25/{1}/{2}" width="25" height="25">', baseURL, v, r.data.images_id_filename); }
241                             },
242                             {
243                                 xtype: 'ColumnModel',
244                                 xns: Roo.grid,
245                                 header : 'Name',
246                                 width : 200,
247                                 dataIndex : 'name',
248                                 renderer : function(v) { return String.format('{0}', v); },
249                                 editor : {
250                                     xtype: 'GridEditor',
251                                     xns: Roo.grid,
252                                     field : {
253                                         xtype: 'TextField',
254                                         xns: Roo.form
255                                     }
256                                 }
257                             },
258                             {
259                                 xtype: 'ColumnModel',
260                                 xns: Roo.grid,
261                                 dataIndex : 'display_name',
262                                 header : 'Display Name',
263                                 width : 200,
264                                 renderer : function(v) { return String.format('{0}', v); },
265                                 editor : {
266                                     xtype: 'GridEditor',
267                                     xns: Roo.grid,
268                                     field : {
269                                         xtype: 'TextField',
270                                         xns: Roo.form
271                                     }
272                                 }
273                             },
274                             {
275                                 xtype: 'ColumnModel',
276                                 xns: Roo.grid,
277                                 dataIndex : 'active',
278                                 header : 'Active',
279                                 width : 75,
280                                 renderer : function(v) {  
281                                     var state = v> 0 ?  '-checked' : '';
282                                 
283                                     return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
284                                                 
285                                  }
286                             },
287                             {
288                                 xtype: 'ColumnModel',
289                                 xns: Roo.grid,
290                                 dataIndex : 'seqid',
291                                 header : 'Order #',
292                                 sortable : true,
293                                 width : 75,
294                                 renderer : function(v) { return String.format('{0}', v); },
295                                 editor : {
296                                     xtype: 'GridEditor',
297                                     xns: Roo.grid,
298                                     field : {
299                                         xtype: 'NumberField',
300                                         xns: Roo.form,
301                                         allowDecimals : false,
302                                         allowNegative : true,
303                                         decimalPrecision : 0
304                                     }
305                                 }
306                             }
307                         ]
308                     }
309                 }
310             ],
311             center : {
312                 xtype: 'LayoutRegion',
313                 xns: Roo
314             },
315             buttons : [
316                 {
317                     xtype: 'Button',
318                     xns: Roo,
319                     text : "OK"
320                 }
321             ]
322         });
323     }
324 };