sync
[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 Roo.namespace('Pman.Dialog');
6
7 Pman.Dialog.AdminCoreEnum = {
8
9  _strings : {
10   '2df80d5febcde0c10a66818488622b7c' :"Pulldown Options",
11   'd1228f5476d15142b1358ae4b5fa2454' :"Order #",
12   '7af54708cf5a4286cf0cfa58ff5148a8' :"Internal #",
13   'b48968e1c912da07df5e8d6d246291ec' :"Display Name",
14   'ea4788705e6873b424c65e91c2846b19' :"Cancel",
15   '510bc6e58593b2b8002c9fe0c21f3fde' :"Displaying core_enum{0} - {1} of {2}",
16   '1ba4d808fc7b27a7f60ce2ff75a8af3a' :"No core_enum found",
17   'd9ec74f5aa29ceef6bf7b45f7fec5d0f' :"Add Value",
18   '49ee3087348e8d44e1feda1917443987' :"Name",
19   '4d3d769b812b6faa6b76e1a8abaece2d' :"Active",
20   'e0aa021e21dddbd6d8cecec71e9cf564' :"OK"
21  },
22
23  dialog : false,
24  callback:  false,
25
26  show : function(data, cb)
27  {
28   if (!this.dialog) {
29    this.create();
30   }
31
32   this.callback = cb;
33   this.data = data;
34   this.dialog.show(this.data._el);
35   if (this.form) {
36    this.form.reset();
37    this.form.setValues(data);
38    this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
39   }
40
41  },
42
43  create : function()
44  {
45    var _this = this;
46    this.dialog = Roo.factory({
47     xtype : 'LayoutDialog',
48     closable : false,
49     height : 400,
50     modal : true,
51     resizable : false,
52     title : _this._strings['2df80d5febcde0c10a66818488622b7c'] /* Pulldown Options */,
53     width : 950,
54     listeners : {
55      show : function (_self)
56       {
57           if(!isAdmin && Pman.Tab.Hopedb){
58               Roo.MessageBox.alert("Error", "Permission Denied", function(){
59                   _this.dialog.hide();
60               });
61               return;
62           }
63           var name_hidden = false;
64       
65           if (typeof(_this.data._hide_name) != 'undefined') {
66               name_hidden = true;
67           
68           }
69           
70         _this.grid.colModel.setHidden(1,name_hidden);
71           _this.grid.footer.onClick('first');
72           
73       }
74     },
75     xns : Roo,
76     '|xns' : 'Roo',
77     center : {
78      xtype : 'LayoutRegion',
79      xns : Roo,
80      '|xns' : 'Roo'
81     },
82     buttons : [
83      {
84       xtype : 'Button',
85       text : _this._strings['ea4788705e6873b424c65e91c2846b19'] /* Cancel */,
86       listeners : {
87        click : function (_self, e)
88         {
89           _this.dialog.hide();
90         }
91       },
92       xns : Roo,
93       '|xns' : 'Roo'
94      },
95      {
96       xtype : 'Button',
97       text : _this._strings['e0aa021e21dddbd6d8cecec71e9cf564'] /* OK */,
98       listeners : {
99        click : function (_self, e)
100         {
101             var sel = _this.grid.selModel.getSelectedCell();
102             if (!sel && _this.callback) {
103                 Roo.MessageBox.alert("Error", "Select an item");
104                 return;
105             }
106             
107         
108             if (_this.callback) {
109                 var rec = _this.grid.ds.getAt(sel[0]);
110                _this.callback(rec.data);
111            }
112            _this.dialog.hide();
113            
114         }
115       },
116       xns : Roo,
117       '|xns' : 'Roo'
118      }
119     ],
120     items  : [
121      {
122       xtype : 'GridPanel',
123       background : false,
124       fitContainer : true,
125       fitToframe : true,
126       region : 'center',
127       tableName : 'core_enum',
128       title : _this._strings['2df80d5febcde0c10a66818488622b7c'] /* Pulldown Options */,
129       listeners : {
130        activate : function() {
131             _this.panel = this;
132             if (_this.grid) {
133              //   _this.grid.footer.onClick('first');
134             }
135             
136         }
137       },
138       xns : Roo,
139       '|xns' : 'Roo',
140       grid : {
141        xtype : 'EditorGrid',
142        autoExpandColumn : 'display_name',
143        clicksToEdit : 1,
144        loadMask : true,
145        listeners : {
146         afteredit : function (e)
147          {
148             e.record.commit();   
149          },
150         beforeedit : function (e)
151          {
152            
153              // force fill in of name first.. (Except when it's hidden)
154              if (typeof(_this.data._hide_name) != 'undefined') { 
155                  if(e.field == 'display_name' && e.record.data.is_system_enum*1 == 1){
156                      return ;
157                  }
158           
159              }
160              
161              if(e.field == 'name' && e.record.data.is_system_enum*1 == 1){
162                  Roo.log("block name?");
163                  return false;
164              }
165          },
166         cellclick : function (_self, rowIndex, columnIndex, e)
167          {
168          
169                  var di = this.colModel.getDataIndex(columnIndex);
170                  if (di != 'active') {
171                      return;
172                  }
173                   
174                  var rec = _this.grid.ds.getAt(rowIndex);
175                  
176                  rec.set('active', rec.data.active ? 0 : 1);
177                  rec.commit();
178                   
179                  
180          },
181         render : function() 
182          {
183              _this.grid = this; 
184              //_this.dialog = Pman.Dialog.FILL_IN
185              if (_this.panel.active) {
186             //    this.footer.onClick('first');
187              }
188          }
189        },
190        xns : Roo.grid,
191        '|xns' : 'Roo.grid',
192        footer : {
193         xtype : 'PagingToolbar',
194         displayInfo : true,
195         displayMsg : _this._strings['510bc6e58593b2b8002c9fe0c21f3fde'] /* Displaying core_enum{0} - {1} of {2} */,
196         emptyMsg : _this._strings['1ba4d808fc7b27a7f60ce2ff75a8af3a'] /* No core_enum found */,
197         pageSize : 25,
198         xns : Roo,
199         '|xns' : 'Roo'
200        },
201        toolbar : {
202         xtype : 'Toolbar',
203         xns : Roo,
204         '|xns' : 'Roo',
205         items  : [
206          {
207           xtype : 'Button',
208           cls : 'x-btn-text-icon',
209           icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
210           text : _this._strings['d9ec74f5aa29ceef6bf7b45f7fec5d0f'] /* Add Value */,
211           listeners : {
212            click : function()
213             {
214                 
215                 // if we do not have a selected type... - what should we show..?
216                 var et = _this.data.etype;
217                 var ds = _this.grid.getDataSource();
218                 if (!et) {
219                     Roo.MessageBox.alert("Error", "Select a pulldown");
220                     return;
221                 }
222             
223                 var add = ds.reader.newRow({    
224                          id: 0, 
225                          display_name : '', 
226                          name : '', 
227                          etype: et, 
228                          active: 1, 
229                          seqid: 0
230                   });
231                  var r = ds.data.length;
232                 ds.insert(r  , add);  
233                 
234                 var ec = 1;
235                 if (typeof(_this.data._hide_name) != 'undefined') { 
236                     ec =2;
237                 }
238                 _this.grid.startEditing(r, ec); // name... 
239             }
240           },
241           xns : Roo.Toolbar,
242           '|xns' : 'Roo.Toolbar'
243          },
244          {
245           xtype : 'Fill',
246           xns : Roo.Toolbar,
247           '|xns' : 'Roo.Toolbar'
248          }
249         ]
250        },
251        dataSource : {
252         xtype : 'Store',
253         remoteSort : true,
254         sortInfo : { field : 'etype', direction: 'ASC' },
255         listeners : {
256          beforeload : function (_self, options)
257           {
258           
259               options.params.etype = _this.data.etype;
260               if (!options.params.etype.length) {
261                   return false;
262               }
263               
264               
265               
266               
267           },
268          update : function (_self, record, operation)
269           {
270               if (operation != Roo.data.Record.COMMIT) {
271                   return;
272               }
273               Roo.log(record);
274           
275               if (typeof(_this.data._hide_name) != 'undefined') {
276                   record.set('name', record.data.display_name);
277               }
278               if (!record.data.name.length) {
279                   return;
280               }
281               
282               // got commit..
283               new Pman.Request({
284                   url : baseURL + '/Roo/Core_enum.php',
285                   method : 'POST',
286                   params : {
287                       id : record.data.id,
288                       etype : _this.data.etype,
289                       name :  record.data.name,
290                       active : record.data.active,
291                       seqid : record.data.seqid,
292                       display_name : record.data.display_name
293                   }, 
294                   success : function(res) {
295                       //Roo.log(data);
296                       // update the ID if it's not set..
297                       if (record.data.id * 1 < 1) {
298                           record.set('id', res.data.id);
299                       }
300                   }
301               });
302               
303           }
304         },
305         xns : Roo.data,
306         '|xns' : 'Roo.data',
307         proxy : {
308          xtype : 'HttpProxy',
309          method : 'GET',
310          url : baseURL + '/Roo/core_enum.php',
311          xns : Roo.data,
312          '|xns' : 'Roo.data'
313         },
314         reader : {
315          xtype : 'JsonReader',
316          fields : [
317              {
318                  'name': 'id',
319                  'type': 'int'
320              },
321              {
322                  'name': 'etype',
323                  'type': 'string'
324              },
325              {
326                  'name': 'name',
327                  'type': 'string'
328              },
329              {
330                  'name': 'active',
331                  'type': 'int'
332              },
333              {
334                  'name': 'seqid',
335                  'type': 'int'
336              }
337          ],
338          id : 'id',
339          root : 'data',
340          totalProperty : 'total',
341          xns : Roo.data,
342          '|xns' : 'Roo.data'
343         }
344        },
345        colModel : [
346         {
347          xtype : 'ColumnModel',
348          dataIndex : 'id',
349          header : _this._strings['7af54708cf5a4286cf0cfa58ff5148a8'] /* Internal # */,
350          renderer : function(v) { return String.format('{0}', v); },
351          width : 75,
352          xns : Roo.grid,
353          '|xns' : 'Roo.grid'
354         },
355         {
356          xtype : 'ColumnModel',
357          dataIndex : 'name',
358          header : _this._strings['49ee3087348e8d44e1feda1917443987'] /* Name */,
359          renderer : function(v) { return String.format('{0}', v); },
360          width : 200,
361          xns : Roo.grid,
362          '|xns' : 'Roo.grid',
363          editor : {
364           xtype : 'GridEditor',
365           xns : Roo.grid,
366           '|xns' : 'Roo.grid',
367           field : {
368            xtype : 'TextField',
369            xns : Roo.form,
370            '|xns' : 'Roo.form'
371           }
372          }
373         },
374         {
375          xtype : 'ColumnModel',
376          dataIndex : 'display_name',
377          header : _this._strings['b48968e1c912da07df5e8d6d246291ec'] /* Display Name */,
378          renderer : function(v) { return String.format('{0}', v); },
379          width : 200,
380          xns : Roo.grid,
381          '|xns' : 'Roo.grid',
382          editor : {
383           xtype : 'GridEditor',
384           xns : Roo.grid,
385           '|xns' : 'Roo.grid',
386           field : {
387            xtype : 'TextField',
388            xns : Roo.form,
389            '|xns' : 'Roo.form'
390           }
391          }
392         },
393         {
394          xtype : 'ColumnModel',
395          dataIndex : 'active',
396          header : _this._strings['4d3d769b812b6faa6b76e1a8abaece2d'] /* Active */,
397          renderer : function(v) {  
398              var state = v> 0 ?  '-checked' : '';
399          
400              return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
401                          
402           },
403          width : 75,
404          xns : Roo.grid,
405          '|xns' : 'Roo.grid'
406         },
407         {
408          xtype : 'ColumnModel',
409          dataIndex : 'seqid',
410          header : _this._strings['d1228f5476d15142b1358ae4b5fa2454'] /* Order # */,
411          renderer : function(v) { return String.format('{0}', v); },
412          sortable : true,
413          width : 75,
414          xns : Roo.grid,
415          '|xns' : 'Roo.grid',
416          editor : {
417           xtype : 'GridEditor',
418           xns : Roo.grid,
419           '|xns' : 'Roo.grid',
420           field : {
421            xtype : 'NumberField',
422            allowDecimals : false,
423            allowNegative : true,
424            decimalPrecision : 0,
425            xns : Roo.form,
426            '|xns' : 'Roo.form'
427           }
428          }
429         }
430        ]
431       }
432      }
433     ]
434    });
435  }
436 };