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: 'TextItem',
189                                     xns: Roo.Toolbar,
190                                     text : "Pulldown Name:"
191                                 },
192                                 {
193                                     xtype: 'ComboBox',
194                                     xns: Roo.form,
195                                     listeners : {
196                                         render : function (_self)
197                                         {
198                                             _this.etypeCombo = _self;
199                                         },
200                                         select : function (combo, record, index)
201                                         {
202                                             _this.grid.footer.onClick('first');
203                                         }
204                                     },
205                                     alwaysQuery : true,
206                                     displayField : 'name',
207                                     editable : 'false',
208                                     emptyText : "Select pulldown",
209                                     fieldLabel : 'core_enum',
210                                     forceSelection : true,
211                                     listWidth : 400,
212                                     loadingText : "Searching...",
213                                     minChars : 2,
214                                     pageSize : 50,
215                                     qtip : "Select type",
216                                     queryParam : 'query[name]',
217                                     selectOnFocus : true,
218                                     tpl : '<div class="x-grid-cell-text x-btn button"><b>{display_name}</b> - {name} </div>',
219                                     triggerAction : 'all',
220                                     typeAhead : false,
221                                     valueField : 'name',
222                                     width : 300,
223                                     store : {
224                                         xtype: 'Store',
225                                         xns: Roo.data,
226                                         listeners : {
227                                             beforeload : function (_self, o){
228                                                 o.params = o.params || {};
229                                                 // set more here
230                                                 o.params['query[empty_etype]'] = 1; 
231                                             }
232                                         },
233                                         remoteSort : true,
234                                         sortInfo : { direction : 'ASC', field: 'display_name' },
235                                         proxy : {
236                                             xtype: 'HttpProxy',
237                                             xns: Roo.data,
238                                             method : 'GET',
239                                             url : baseURL + '/Roo/core_enum.php'
240                                         },
241                                         reader : {
242                                             xtype: 'JsonReader',
243                                             xns: Roo.data,
244                                             id : 'id',
245                                             root : 'data',
246                                             totalProperty : 'total',
247                                             fields : [{"name":"id","type":"int"},{"name":"etype","type":"string"}]
248                                         }
249                                     }
250                                 },
251                                 {
252                                     xtype: 'Button',
253                                     xns: Roo.Toolbar,
254                                     listeners : {
255                                         click : function()
256                                         {
257                                             
258                                             // if we do not have a selected type... - what should we show..?
259                                             var et = _this.etypeCombo.getValue();
260                                             var ds = _this.grid.getDataSource();
261                                             if (!et) {
262                                                 Roo.MessageBox.alert("Error", "Select a pulldown");
263                                                 return;
264                                             }
265                                         
266                                             var add = ds.reader.newRow({    
267                                                      id: 0, 
268                                                      display_name : '', 
269                                                      name : '', 
270                                                      etype: et, 
271                                                      active: 1, 
272                                                      seqid: 0
273                                               });
274                                              var r = ds.data.length;
275                                             ds.insert(r  , add);  
276                                             _this.grid.startEditing(r, 1); // name... 
277                                         }
278                                     },
279                                     cls : 'x-btn-text-icon',
280                                     text : "Add Value",
281                                     icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
282                                 },
283                                 {
284                                     xtype: 'Fill',
285                                     xns: Roo.Toolbar
286                                 }
287                             ]
288                         },
289                         colModel : [
290                             {
291                                 xtype: 'ColumnModel',
292                                 xns: Roo.grid,
293                                 dataIndex : 'id',
294                                 header : 'Internal #',
295                                 width : 75,
296                                 renderer : function(v) { return String.format('{0}', v); }
297                             },
298                             {
299                                 xtype: 'ColumnModel',
300                                 xns: Roo.grid,
301                                 dataIndex : 'images_id_id',
302                                 header : 'Image',
303                                 width : 75,
304                                 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); }
305                             },
306                             {
307                                 xtype: 'ColumnModel',
308                                 xns: Roo.grid,
309                                 header : 'Name',
310                                 width : 200,
311                                 dataIndex : 'name',
312                                 renderer : function(v) { return String.format('{0}', v); },
313                                 editor : {
314                                     xtype: 'GridEditor',
315                                     xns: Roo.grid,
316                                     field : {
317                                         xtype: 'TextField',
318                                         xns: Roo.form
319                                     }
320                                 }
321                             },
322                             {
323                                 xtype: 'ColumnModel',
324                                 xns: Roo.grid,
325                                 dataIndex : 'display_name',
326                                 header : 'Display Name',
327                                 width : 200,
328                                 renderer : function(v) { return String.format('{0}', v); },
329                                 editor : {
330                                     xtype: 'GridEditor',
331                                     xns: Roo.grid,
332                                     field : {
333                                         xtype: 'TextField',
334                                         xns: Roo.form
335                                     }
336                                 }
337                             },
338                             {
339                                 xtype: 'ColumnModel',
340                                 xns: Roo.grid,
341                                 dataIndex : 'active',
342                                 header : 'Active',
343                                 width : 75,
344                                 renderer : function(v) {  
345                                     var state = v> 0 ?  '-checked' : '';
346                                 
347                                     return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
348                                                 
349                                  }
350                             },
351                             {
352                                 xtype: 'ColumnModel',
353                                 xns: Roo.grid,
354                                 dataIndex : 'seqid',
355                                 header : 'Order #',
356                                 sortable : true,
357                                 width : 75,
358                                 renderer : function(v) { return String.format('{0}', v); },
359                                 editor : {
360                                     xtype: 'GridEditor',
361                                     xns: Roo.grid,
362                                     field : {
363                                         xtype: 'NumberField',
364                                         xns: Roo.form,
365                                         allowDecimals : false,
366                                         allowNegative : true,
367                                         decimalPrecision : 0
368                                     }
369                                 }
370                             }
371                         ]
372                     }
373                 }
374             ],
375             center : {
376                 xtype: 'LayoutRegion',
377                 xns: Roo
378             },
379             buttons : [
380                 {
381                     xtype: 'Button',
382                     xns: Roo,
383                     text : "OK"
384                 }
385             ]
386         });
387     }
388 };