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