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