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