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