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