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               
264               
265           },
266          update : function (_self, record, operation)
267           {
268               if (operation != Roo.data.Record.COMMIT) {
269                   return;
270               }
271               Roo.log(record);
272           
273               if (typeof(_this.data._hide_name) != 'undefined') {
274                   record.set('name', record.data.display_name);
275               }
276               if (!record.data.name.length) {
277                   return;
278               }
279               
280               // got commit..
281               new Pman.Request({
282                   url : baseURL + '/Roo/Core_enum.php',
283                   method : 'POST',
284                   params : {
285                       id : record.data.id,
286                       etype : _this.data.etype,
287                       name :  record.data.name,
288                       active : record.data.active,
289                       seqid : record.data.seqid,
290                       display_name : record.data.display_name
291                   }, 
292                   success : function(res) {
293                       //Roo.log(data);
294                       // update the ID if it's not set..
295                       if (record.data.id * 1 < 1) {
296                           record.set('id', res.data.id);
297                       }
298                   }
299               });
300               
301           }
302         },
303         xns : Roo.data,
304         '|xns' : 'Roo.data',
305         proxy : {
306          xtype : 'HttpProxy',
307          method : 'GET',
308          url : baseURL + '/Roo/core_enum.php',
309          xns : Roo.data,
310          '|xns' : 'Roo.data'
311         },
312         reader : {
313          xtype : 'JsonReader',
314          fields : [
315              {
316                  'name': 'id',
317                  'type': 'int'
318              },
319              {
320                  'name': 'etype',
321                  'type': 'string'
322              },
323              {
324                  'name': 'name',
325                  'type': 'string'
326              },
327              {
328                  'name': 'active',
329                  'type': 'int'
330              },
331              {
332                  'name': 'seqid',
333                  'type': 'int'
334              }
335          ],
336          id : 'id',
337          root : 'data',
338          totalProperty : 'total',
339          xns : Roo.data,
340          '|xns' : 'Roo.data'
341         }
342        },
343        colModel : [
344         {
345          xtype : 'ColumnModel',
346          dataIndex : 'id',
347          header : _this._strings['7af54708cf5a4286cf0cfa58ff5148a8'] /* Internal # */,
348          renderer : function(v) { return String.format('{0}', v); },
349          width : 75,
350          xns : Roo.grid,
351          '|xns' : 'Roo.grid'
352         },
353         {
354          xtype : 'ColumnModel',
355          dataIndex : 'name',
356          header : _this._strings['49ee3087348e8d44e1feda1917443987'] /* Name */,
357          renderer : function(v) { return String.format('{0}', v); },
358          width : 200,
359          xns : Roo.grid,
360          '|xns' : 'Roo.grid',
361          editor : {
362           xtype : 'GridEditor',
363           xns : Roo.grid,
364           '|xns' : 'Roo.grid',
365           field : {
366            xtype : 'TextField',
367            xns : Roo.form,
368            '|xns' : 'Roo.form'
369           }
370          }
371         },
372         {
373          xtype : 'ColumnModel',
374          dataIndex : 'display_name',
375          header : _this._strings['b48968e1c912da07df5e8d6d246291ec'] /* Display Name */,
376          renderer : function(v) { return String.format('{0}', v); },
377          width : 200,
378          xns : Roo.grid,
379          '|xns' : 'Roo.grid',
380          editor : {
381           xtype : 'GridEditor',
382           xns : Roo.grid,
383           '|xns' : 'Roo.grid',
384           field : {
385            xtype : 'TextField',
386            xns : Roo.form,
387            '|xns' : 'Roo.form'
388           }
389          }
390         },
391         {
392          xtype : 'ColumnModel',
393          dataIndex : 'active',
394          header : _this._strings['4d3d769b812b6faa6b76e1a8abaece2d'] /* Active */,
395          renderer : function(v) {  
396              var state = v> 0 ?  '-checked' : '';
397          
398              return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
399                          
400           },
401          width : 75,
402          xns : Roo.grid,
403          '|xns' : 'Roo.grid'
404         },
405         {
406          xtype : 'ColumnModel',
407          dataIndex : 'seqid',
408          header : _this._strings['d1228f5476d15142b1358ae4b5fa2454'] /* Order # */,
409          renderer : function(v) { return String.format('{0}', v); },
410          sortable : true,
411          width : 75,
412          xns : Roo.grid,
413          '|xns' : 'Roo.grid',
414          editor : {
415           xtype : 'GridEditor',
416           xns : Roo.grid,
417           '|xns' : 'Roo.grid',
418           field : {
419            xtype : 'NumberField',
420            allowDecimals : false,
421            allowNegative : true,
422            decimalPrecision : 0,
423            xns : Roo.form,
424            '|xns' : 'Roo.form'
425           }
426          }
427         }
428        ]
429       }
430      }
431     ]
432    });
433  }
434 };