Pman.Tab.AdminEnum.bjs
[Pman.Admin] / Pman.Tab.AdminEnum.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.Tab');
6
7 Pman.Tab.AdminEnum = new Roo.XComponent({
8
9  _strings : {
10   '2df80d5febcde0c10a66818488622b7c' :"Pulldown Options",
11   'd1228f5476d15142b1358ae4b5fa2454' :"Order #",
12   'fdff10eac021dfbb69e9c38204237fdc' :"Add new pulldown list",
13   '1206eb8aea05be4625371c9c12818785' :"Pulldown",
14   '801ab24683a4a8c433c6eb40c48bcd9d' :"Download",
15   '7af54708cf5a4286cf0cfa58ff5148a8' :"Internal #",
16   'be53a0541a6d36f6ecb879fa2c584b08' :"Image",
17   'b48968e1c912da07df5e8d6d246291ec' :"Display Name",
18   '510bc6e58593b2b8002c9fe0c21f3fde' :"Displaying core_enum{0} - {1} of {2}",
19   '1ba4d808fc7b27a7f60ce2ff75a8af3a' :"No core_enum found",
20   'c550aeed26e71a81a88360c1889245ab' :"Upload Values",
21   'd9ec74f5aa29ceef6bf7b45f7fec5d0f' :"Add Value",
22   'b9c49611cfda3259a2b837b39489e650' :"Add Image",
23   '4d3d769b812b6faa6b76e1a8abaece2d' :"Active",
24   '49ee3087348e8d44e1feda1917443987' :"Name",
25   '7215ee9c7d9dc229d2921a40e899ec5f' :" "
26  },
27
28   part     :  ["Admin", "Enum" ],
29   order    : '500-Pman.Tab.AdminEnum',
30   region   : 'center',
31   parent   : 'Pman.Tab.Admin',
32   name     : "Pman.Tab.AdminEnum",
33   disabled : false, 
34   permname : '', 
35   _tree : function()
36   {
37    var _this = this;
38    var MODULE = this;
39    return {
40    layout : {
41     west : {
42      '|xns' : 'Roo',
43      split : true,
44      width : 200,
45      xns : Roo,
46      xtype : 'LayoutRegion'
47     },
48     center : {
49      '|xns' : 'Roo',
50      xns : Roo,
51      xtype : 'LayoutRegion'
52     },
53     '|xns' : 'Roo',
54     xns : Roo,
55     xtype : 'BorderLayout',
56     items : [
57      {
58       grid : {
59        dataSource : {
60         proxy : {
61          '|xns' : 'Roo.data',
62          method : 'GET',
63          url : baseURL + '/Roo/core_enum.php',
64          xns : Roo.data,
65          xtype : 'HttpProxy'
66         },
67         reader : {
68          '|xns' : 'Roo.data',
69          fields : [
70              {
71                  'name': 'id',
72                  'type': 'int'
73              },
74              {
75                  'name': 'etype',
76                  'type': 'string'
77              },
78              {
79                  'name': 'name',
80                  'type': 'string'
81              },
82              {
83                  'name': 'active',
84                  'type': 'int'
85              },
86              {
87                  'name': 'seqid',
88                  'type': 'int'
89              }
90          ],
91          id : 'id',
92          root : 'data',
93          totalProperty : 'total',
94          xns : Roo.data,
95          xtype : 'JsonReader'
96         },
97         '|xns' : 'Roo.data',
98         remoteSort : true,
99         sortInfo : { field : 'etype', direction: 'ASC' },
100         xns : Roo.data,
101         xtype : 'Store',
102         listeners : {
103          beforeload : function (_self, o)
104           {
105               o.params['query[empty_etype]'] = 1; 
106             
107           },
108          update : function (_self, record, operation)
109           {
110               if (operation != Roo.data.Record.COMMIT) {
111                   return;
112               }
113               // got commit..
114               new Pman.Request({
115                   url : baseURL + '/Roo/Core_enum.php',
116                   method : 'POST',
117                   params : {
118                       id : record.data.id,
119                       etype : _this.grid.ds.getById(record.id).data.etype,
120                       name : record.data.name,
121                       active : record.data.active,
122                       seqid : record.data.seqid,
123                       display_name : record.data.display_name
124                   }, 
125                   success : function(res) {
126                       //Roo.log(data);
127                       // update the ID if it's not set..
128                       if (record.data.id * 1 < 1) {
129                           record.set('id', res.data.id);
130                       }
131                   }
132               });
133               
134           }
135         },
136         items : [
137
138         ]
139
140        },
141        sm : {
142         '|xns' : 'Roo.grid',
143         xns : Roo.grid,
144         xtype : 'CellSelectionModel',
145         listeners : {
146          selectionchange : function (_self, selection)
147           {
148               _this.grid.footer.onClick('first');
149           }
150         }
151        },
152        footer : {
153         '|xns' : 'Roo',
154         displayInfo : false,
155         displayMsg : _this._strings['7215ee9c7d9dc229d2921a40e899ec5f'],
156         emptyMsg : _this._strings['1ba4d808fc7b27a7f60ce2ff75a8af3a'],
157         pageSize : 100,
158         xns : Roo,
159         xtype : 'PagingToolbar'
160        },
161        toolbar : {
162         '|xns' : 'Roo',
163         xns : Roo,
164         xtype : 'Toolbar',
165         items : [
166          {
167           '|xns' : 'Roo.Toolbar',
168           cls : 'x-btn-text-icon',
169           icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
170           text : _this._strings['fdff10eac021dfbb69e9c38204237fdc'],
171           xns : Roo.Toolbar,
172           xtype : 'Button',
173           listeners : {
174            click : function()
175             {
176                 
177                 var data = {
178                     active:1,
179                     display_name:'',
180                     etype:'',
181                     name:''
182                 };
183                 Pman.Dialog.AdminEnumType.show(data,function(){
184                     
185                     _this.egrid.footer.onClick('first');
186                 });
187                      
188                      
189             
190             }
191           }
192          }
193         ]
194
195        },
196        '|xns' : 'Roo.grid',
197        autoExpandColumn : 'display_name',
198        clicksToEdit : 1,
199        loadMask : true,
200        xns : Roo.grid,
201        xtype : 'EditorGrid',
202        colModel : [
203          {
204           '|xns' : 'Roo.grid',
205           dataIndex : 'display_name',
206           header : _this._strings['1206eb8aea05be4625371c9c12818785'],
207           renderer : function(v,x,r) { 
208           
209           
210               return String.format('<span qtip="{1}">{0}</span>', (''+v).length ? v : r.data.name, r.data.name); 
211           },
212           width : 200,
213           xns : Roo.grid,
214           xtype : 'ColumnModel'
215          },
216 {
217           '|xns' : 'Roo.grid',
218           dataIndex : 'active',
219           header : _this._strings['4d3d769b812b6faa6b76e1a8abaece2d'],
220           renderer : function(v) {  
221               var state = v> 0 ?  '-checked' : '';
222           
223               return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
224                           
225            },
226           width : 50,
227           xns : Roo.grid,
228           xtype : 'ColumnModel'
229          }
230        ],
231        listeners : {
232         afteredit : function (e)
233          {
234             e.record.commit();     
235          },
236         beforeedit : function (e)
237          {
238              if(e.field == 'name' && e.record.data.is_system_enum*1 == 1){
239                  return false;
240              }
241          },
242         cellclick : function (_self, rowIndex, columnIndex, e)
243          {
244          
245                  var di = this.colModel.getDataIndex(columnIndex);
246                  if (di != 'active') {
247                      return;
248                  }
249                   
250                  var rec = _this.grid.ds.getAt(rowIndex);
251                  
252                  rec.set('active', rec.data.active ? 0 : 1);
253                  rec.commit();
254                   
255                  
256          },
257         celldblclick : function (_self, rowIndex, columnIndex, e)
258          {
259              var rec = _this.egrid.ds.getAt(rowIndex);
260              Pman.Dialog.AdminEnumType.show(rec.data,function(){
261                  
262                  _this.egrid.footer.onClick('first');
263              });
264          },
265         render : function() 
266          {
267              _this.egrid = this; 
268              //_this.dialog = Pman.Dialog.FILL_IN
269              if (_this.epanel.active) {
270                 this.footer.onClick('first');
271              }
272          }
273        },
274        items : [
275
276        ]
277
278       },
279       '|xns' : 'Roo',
280       background : false,
281       region : 'west',
282       tableName : 'core_enum',
283       title : _this._strings['2df80d5febcde0c10a66818488622b7c'],
284       xns : Roo,
285       xtype : 'GridPanel',
286       listeners : {
287        activate : function() {
288             _this.epanel = this;
289             //if (_this.egrid) {
290             //    _this.egrid.footer.onClick('first');
291             //}
292         }
293       },
294       items : [
295
296       ]
297
298      },
299      {
300       grid : {
301        dataSource : {
302         proxy : {
303          '|xns' : 'Roo.data',
304          method : 'GET',
305          url : baseURL + '/Roo/core_enum.php',
306          xns : Roo.data,
307          xtype : 'HttpProxy'
308         },
309         reader : {
310          '|xns' : 'Roo.data',
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          xtype : 'JsonReader'
338         },
339         '|xns' : 'Roo.data',
340         remoteSort : true,
341         sortInfo : { field : 'etype', direction: 'ASC' },
342         xns : Roo.data,
343         xtype : 'Store',
344         listeners : {
345          beforeload : function (_self, options)
346           {
347           
348               var s =     _this.egrid.getSelectionModel().getSelectedCell();
349               
350           
351               if (!s) {
352                   return false;
353               }
354               var d = _this.egrid.dataSource.getAt(s[0]);
355               
356               options.params.etype = d.data.name;
357               options.params['query[search]'] = _this.searchBox.getValue();
358               if (!options.params.etype.length) {
359                   return false;
360               }
361           },
362          update : function (_self, record, operation)
363           {
364               if (operation != Roo.data.Record.COMMIT) {
365                   return;
366               }
367               // got commit..
368               new Pman.Request({
369                   url : baseURL + '/Roo/Core_enum.php',
370                   method : 'POST',
371                   params : {
372                       id : record.data.id,
373                       etype : _this.grid.ds.getById(record.id).data.etype,
374                       name : record.data.name,
375                       active : record.data.active,
376                       seqid : record.data.seqid,
377                       display_name : record.data.display_name
378                   }, 
379                   success : function(res) {
380                       //Roo.log(data);
381                       // update the ID if it's not set..
382                       if (record.data.id * 1 < 1) {
383                           record.set('id', res.data.id);
384                       }
385                   }
386               });
387               
388           }
389         },
390         items : [
391
392         ]
393
394        },
395        footer : {
396         '|xns' : 'Roo',
397         displayInfo : true,
398         displayMsg : _this._strings['510bc6e58593b2b8002c9fe0c21f3fde'],
399         emptyMsg : _this._strings['1ba4d808fc7b27a7f60ce2ff75a8af3a'],
400         pageSize : 25,
401         xns : Roo,
402         xtype : 'PagingToolbar',
403         items : [
404          {
405           '|xns' : 'Roo.Toolbar',
406           text : _this._strings['801ab24683a4a8c433c6eb40c48bcd9d'],
407           xns : Roo.Toolbar,
408           xtype : 'Button',
409           listeners : {
410            click : function (_self, e)
411             {
412                 new Pman.Download({
413                     grid : _this.grid
414                 });
415                 Roo.MessageBox.alert("Downloading", "File is downloading");
416             }
417           }
418          },
419          {
420           '|xns' : 'Roo.Toolbar',
421           text : _this._strings['c550aeed26e71a81a88360c1889245ab'],
422           xns : Roo.Toolbar,
423           xtype : 'Button',
424           listeners : {
425            click : function (_self, e)
426             {
427             
428               var s =     _this.egrid.getSelectionModel().getSelectedCell();
429                 
430             
431                 if (!s) {
432                     Roo.MessageBox.alert("Error", "Select a pulldown");
433                 }
434                 
435                 var d = _this.egrid.dataSource.getAt(s[0]);
436              
437             
438                 var etype = d.data.name;
439                 
440                 if(!etype.length){
441                     Roo.MessageBox.alert('Error', 'Please select a pulldown');
442                     return;
443                 }
444                 
445                 Pman.Dialog.Image.show(
446                    {
447                         _url : baseURL+'/Admin/Import/Enum?' + Roo.urlEncode({'etype' : etype})
448                     
449                    },
450                    function () {
451                         _this.grid.footer.onClick('first');
452                    }
453                );
454             }
455           }
456          }
457         ]
458
459        },
460        toolbar : {
461         '|xns' : 'Roo',
462         xns : Roo,
463         xtype : 'Toolbar',
464         items : [
465          {
466           '|xns' : 'Roo.Toolbar',
467           cls : 'x-btn-text-icon',
468           icon : baseURL + '/Pman/templates/images/search.gif',
469           text : _this._strings['d9ec74f5aa29ceef6bf7b45f7fec5d0f'],
470           xns : Roo.Toolbar,
471           xtype : 'Button',
472           listeners : {
473            click : function()
474             {
475                 
476                 // if we do not have a selected type... - what should we show..?
477                 
478                 
479                 var s =     _this.egrid.getSelectionModel().getSelectedCell();
480                 
481             
482                 if (!s) {
483                     Roo.MessageBox.alert("Error", "Select a pulldown");
484                 }
485                 
486                 var d = _this.egrid.dataSource.getAt(s[0]);
487              
488             
489                 var ds = _this.grid.getDataSource();
490             
491                 var add = ds.reader.newRow({    
492                          id: 0, 
493                          display_name : '', 
494                          name : '', 
495                          etype: d.data.name, 
496                          active: 1, 
497                          seqid: 0
498                   });
499                  var r = ds.data.length;
500                 ds.insert(r  , add);  
501                 _this.grid.startEditing(r, 1); // name... 
502             }
503           }
504          },
505          {
506           '|xns' : 'Roo.Toolbar',
507           cls : 'x-btn-text-icon',
508           icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
509           text : _this._strings['b9c49611cfda3259a2b837b39489e650'],
510           xns : Roo.Toolbar,
511           xtype : 'Button',
512           listeners : {
513            click : function()
514             {
515                 
516                 // if we do not have a selected type... - what should we show..?
517                 var et = _this.etypeCombo.getValue();
518                 
519                 if (!et) {
520                     Roo.MessageBox.alert("Error", "Select a pulldown");
521                     return;
522                 }
523                 var sc = _this.grid.getSelectionModel().getSelectedCell();
524                 Roo.log(sc);
525                 var ds = _this.grid.ds.getAt(sc[0]);
526                 if (!ds) {
527                     Roo.MessageBox.alert("Error", "Select enum");
528                     return;
529                 }
530                 
531                 Roo.log(ds);
532                 Pman.Dialog.AdminEnumImages.show({onid:ds.data.id}, function(){
533                     _this.grid.footer.onClick('first');
534                 });
535                 
536             }
537           }
538          },
539          {
540           '|xns' : 'Roo.form',
541           fieldLabel : 'Search',
542           name : 'search',
543           xns : Roo.form,
544           xtype : 'TextField',
545           listeners : {
546            render : function (_self)
547             {
548                 _this.searchBox = this;
549             }
550           }
551          },
552          {
553           '|xns' : 'Roo.Toolbar',
554           cls : 'x-btn-icon',
555           icon : rootURL + '/Pman/templates/images/search.gif',
556           xns : Roo.Toolbar,
557           xtype : 'Button',
558           listeners : {
559            click : function (_self, e)
560             {
561                 _this.grid.footer.onClick('first');
562             }
563           }
564          },
565          {
566           '|xns' : 'Roo.Toolbar',
567           cls : 'x-btn-icon',
568           icon : rootURL + '/Pman/templates/images/edit-clear.gif',
569           xns : Roo.Toolbar,
570           xtype : 'Button',
571           listeners : {
572            click : function (_self, e)
573             {
574                  _this.searchBox.setValue('');
575                  _this.grid.footer.onClick('first');
576             }
577           }
578          }
579         ]
580
581        },
582        '|xns' : 'Roo.grid',
583        autoExpandColumn : 'display_name',
584        clicksToEdit : 1,
585        loadMask : true,
586        xns : Roo.grid,
587        xtype : 'EditorGrid',
588        colModel : [
589          {
590           '|xns' : 'Roo.grid',
591           dataIndex : 'id',
592           header : _this._strings['7af54708cf5a4286cf0cfa58ff5148a8'],
593           renderer : function(v,x,r) { 
594               var fmt = '{0}';
595               if (r.selected) {
596                   fmt = '<span style="color:orange;font-weight:bold;">{0}</span>';
597               }
598               return String.format(fmt, v); },
599           sortable : true,
600           width : 75,
601           xns : Roo.grid,
602           xtype : 'ColumnModel'
603          },
604 {
605           '|xns' : 'Roo.grid',
606           dataIndex : 'images_id_id',
607           header : _this._strings['be53a0541a6d36f6ecb879fa2c584b08'],
608           renderer : function(v,x,r) { return String.format('<img src="{0}/Images/Thumb/25/{1}/{2}" width="25" height="25">', baseURL, v, r.data.images_id_filename); },
609           width : 75,
610           xns : Roo.grid,
611           xtype : 'ColumnModel'
612          },
613 {
614           editor : {
615            field : {
616             '|xns' : 'Roo.form',
617             xns : Roo.form,
618             xtype : 'TextField'
619            },
620            '|xns' : 'Roo.grid',
621            xns : Roo.grid,
622            xtype : 'GridEditor',
623            items : [
624
625            ]
626
627           },
628           '|xns' : 'Roo.grid',
629           dataIndex : 'name',
630           header : _this._strings['49ee3087348e8d44e1feda1917443987'],
631           renderer : function(v) { return String.format('{0}', v); },
632           sortable : true,
633           width : 200,
634           xns : Roo.grid,
635           xtype : 'ColumnModel',
636           items : [
637
638           ]
639
640          },
641 {
642           editor : {
643            field : {
644             '|xns' : 'Roo.form',
645             xns : Roo.form,
646             xtype : 'TextField'
647            },
648            '|xns' : 'Roo.grid',
649            xns : Roo.grid,
650            xtype : 'GridEditor',
651            items : [
652
653            ]
654
655           },
656           '|xns' : 'Roo.grid',
657           dataIndex : 'display_name',
658           header : _this._strings['b48968e1c912da07df5e8d6d246291ec'],
659           renderer : function(v) { return String.format('{0}', v); },
660           sortable : true,
661           width : 200,
662           xns : Roo.grid,
663           xtype : 'ColumnModel',
664           items : [
665
666           ]
667
668          },
669 {
670           '|xns' : 'Roo.grid',
671           dataIndex : 'active',
672           header : _this._strings['4d3d769b812b6faa6b76e1a8abaece2d'],
673           renderer : function(v) {  
674               var state = v> 0 ?  '-checked' : '';
675           
676               return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
677                           
678            },
679           sortable : true,
680           width : 75,
681           xns : Roo.grid,
682           xtype : 'ColumnModel'
683          },
684 {
685           editor : {
686            field : {
687             '|xns' : 'Roo.form',
688             allowDecimals : false,
689             allowNegative : true,
690             decimalPrecision : 0,
691             xns : Roo.form,
692             xtype : 'NumberField'
693            },
694            '|xns' : 'Roo.grid',
695            xns : Roo.grid,
696            xtype : 'GridEditor',
697            items : [
698
699            ]
700
701           },
702           '|xns' : 'Roo.grid',
703           dataIndex : 'seqid',
704           header : _this._strings['d1228f5476d15142b1358ae4b5fa2454'],
705           renderer : function(v) { return String.format('{0}', v); },
706           sortable : true,
707           sortable : true,
708           width : 75,
709           xns : Roo.grid,
710           xtype : 'ColumnModel',
711           items : [
712
713           ]
714
715          }
716        ],
717        listeners : {
718         afteredit : function (e)
719          {
720             e.record.commit();     
721          },
722         beforeedit : function (e)
723          {
724              if(e.field == 'name' && e.record.data.is_system_enum*1 == 1){
725                  return false;
726              }
727          },
728         cellclick : function (_self, rowIndex, columnIndex, e)
729          {
730          
731                  var di = this.colModel.getDataIndex(columnIndex);
732                  var rec = _this.grid.ds.getAt(rowIndex);
733                      
734                  if (di == 'active') {
735                      
736                      rec.set('active', rec.data.active ? 0 : 1);
737                      rec.commit();
738                      return;
739                  }
740                  if (di == 'id' ) {
741                      rec.selected = rec.selected ? 0 : 1;
742                      
743                      rec.set('sel', rec.data.sel ? 0 : 1);
744                  }
745                   
746          
747                   
748                  
749          },
750         keypress : function (e)
751          {
752              if(e.keyCode == 13){
753                  _this.grid.footer.onClick('first');
754              }
755          },
756         render : function() 
757          {
758              _this.grid = this; 
759              //_this.dialog = Pman.Dialog.FILL_IN
760              if (_this.panel.active) {
761                 this.footer.onClick('first');
762              }
763          }
764        },
765        items : [
766
767        ]
768
769       },
770       '|xns' : 'Roo',
771       background : false,
772       fitToframe : true,
773       region : 'center',
774       tableName : 'core_enum',
775       title : _this._strings['2df80d5febcde0c10a66818488622b7c'],
776       xns : Roo,
777       xtype : 'GridPanel',
778       listeners : {
779        activate : function() {
780             _this.panel = this;
781             if (_this.grid) {
782                 _this.grid.footer.onClick('first');
783             }
784         }
785       },
786       items : [
787
788       ]
789
790      }
791     ]
792
793    },
794    '|xns' : 'Roo',
795    region : 'center',
796    title : _this._strings['2df80d5febcde0c10a66818488622b7c'],
797    xns : Roo,
798    xtype : 'NestedLayoutPanel',
799    items : [
800
801    ]
802
803   };  }
804 });