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                                                if (!options.params.etype.length) {
365                                                    return false;
366                                                }
367                                            }
368                                 },
369                                 items : [
370
371                                 ]
372
373                             },
374                             footer : {
375                                 '|xns' : 'Roo',
376                                 pageSize : 25,
377                                 xtype : 'PagingToolbar',
378                                 emptyMsg : "No core_enum found",
379                                 xns : Roo,
380                                 displayInfo : true,
381                                 displayMsg : "Displaying core_enum{0} - {1} of {2}",
382                                 items : [
383                                         {
384                                         '|xns' : 'Roo.Toolbar',
385                                         text : "Download",
386                                         xtype : 'Button',
387                                         xns : Roo.Toolbar,
388                                         listeners : {
389                                                 click : function (_self, e)
390                                                    {
391                                                        new Pman.Download({
392                                                            grid : _this.grid
393                                                        });
394                                                        Roo.MessageBox.alert("Downloading", "File is downloading");
395                                                    }
396                                         }
397                                     },
398                                         {
399                                         '|xns' : 'Roo.Toolbar',
400                                         text : "Upload Values",
401                                         xtype : 'Button',
402                                         xns : Roo.Toolbar,
403                                         listeners : {
404                                                 click : function (_self, e)
405                                                    {
406                                                    
407                                                      var s =     _this.egrid.getSelectionModel().getSelectedCell();
408                                                        
409                                                    
410                                                        if (!s) {
411                                                            Roo.MessageBox.alert("Error", "Select a pulldown");
412                                                        }
413                                                        
414                                                        var d = _this.egrid.dataSource.getAt(s[0]);
415                                                     
416                                                    
417                                                        var etype = d.data.name;
418                                                        
419                                                        if(!etype.length){
420                                                            Roo.MessageBox.alert('Error', 'Please select a pulldown');
421                                                            return;
422                                                        }
423                                                        
424                                                        Pman.Dialog.Image.show(
425                                                           {
426                                                                _url : baseURL+'/Admin/Import/Enum?' + Roo.urlEncode({'etype' : etype})
427                                                            
428                                                           },
429                                                           function () {
430                                                                _this.grid.footer.onClick('first');
431                                                           }
432                                                       );
433                                                    }
434                                         }
435                                     }
436                                 ]
437
438                             },
439                             toolbar : {
440                                 '|xns' : 'Roo',
441                                 xtype : 'Toolbar',
442                                 xns : Roo,
443                                 items : [
444                                         {
445                                         '|xns' : 'Roo.Toolbar',
446                                         text : "Add Value",
447                                         xtype : 'Button',
448                                         cls : 'x-btn-text-icon',
449                                         icon : baseURL + '/Pman/templates/images/search.gif',
450                                         xns : Roo.Toolbar,
451                                         listeners : {
452                                                 click : function()
453                                                    {
454                                                        
455                                                        // if we do not have a selected type... - what should we show..?
456                                                        
457                                                        
458                                                        var s =     _this.egrid.getSelectionModel().getSelectedCell();
459                                                        
460                                                    
461                                                        if (!s) {
462                                                            Roo.MessageBox.alert("Error", "Select a pulldown");
463                                                        }
464                                                        
465                                                        var d = _this.egrid.dataSource.getAt(s[0]);
466                                                     
467                                                    
468                                                        var ds = _this.grid.getDataSource();
469                                                    
470                                                        var add = ds.reader.newRow({    
471                                                                 id: 0, 
472                                                                 display_name : '', 
473                                                                 name : '', 
474                                                                 etype: d.data.name, 
475                                                                 active: 1, 
476                                                                 seqid: 0
477                                                          });
478                                                         var r = ds.data.length;
479                                                        ds.insert(r  , add);  
480                                                        _this.grid.startEditing(r, 1); // name... 
481                                                    }
482                                         }
483                                     },
484                                         {
485                                         '|xns' : 'Roo.Toolbar',
486                                         text : "Add Image",
487                                         xtype : 'Button',
488                                         cls : 'x-btn-text-icon',
489                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
490                                         xns : Roo.Toolbar,
491                                         listeners : {
492                                                 click : function()
493                                                    {
494                                                        
495                                                        // if we do not have a selected type... - what should we show..?
496                                                        var et = _this.etypeCombo.getValue();
497                                                        
498                                                        if (!et) {
499                                                            Roo.MessageBox.alert("Error", "Select a pulldown");
500                                                            return;
501                                                        }
502                                                        var sc = _this.grid.getSelectionModel().getSelectedCell();
503                                                        Roo.log(sc);
504                                                        var ds = _this.grid.ds.getAt(sc[0]);
505                                                        if (!ds) {
506                                                            Roo.MessageBox.alert("Error", "Select enum");
507                                                            return;
508                                                        }
509                                                        
510                                                        Roo.log(ds);
511                                                        Pman.Dialog.AdminEnumImages.show({onid:ds.data.id}, function(){
512                                                            _this.grid.footer.onClick('first');
513                                                        });
514                                                        
515                                                    }
516                                         }
517                                     },
518                                         {
519                                         '|xns' : 'Roo.form',
520                                         name : 'search',
521                                         xtype : 'TextField',
522                                         fieldLabel : 'Search',
523                                         xns : Roo.form
524                                     },
525                                         {
526                                         '|xns' : 'Roo.Toolbar',
527                                         xtype : 'Button',
528                                         icon : rootURL + '/web.Hydra/Pman/templates/images/search.gif',
529                                         xns : Roo.Toolbar
530                                     },
531                                         {
532                                         '|xns' : 'Roo.Toolbar',
533                                         xtype : 'Button',
534                                         xns : Roo.Toolbar,
535                                         icon : 'http://roojs.com/Pman/templates/images/edit-clear.gif'
536                                     }
537                                 ]
538
539                             },
540                             '|xns' : 'Roo.grid',
541                             autoExpandColumn : 'display_name',
542                             xtype : 'EditorGrid',
543                             loadMask : true,
544                             clicksToEdit : 1,
545                             xns : Roo.grid,
546                             colModel : [
547                                  {
548                                         '|xns' : 'Roo.grid',
549                                         xtype : 'ColumnModel',
550                                         width : 75,
551                                         header : 'Internal #',
552                                         renderer : function(v) { return String.format('{0}', v); },
553                                         xns : Roo.grid,
554                                         dataIndex : 'id'
555                                     },
556 {
557                                         '|xns' : 'Roo.grid',
558                                         xtype : 'ColumnModel',
559                                         width : 75,
560                                         header : 'Image',
561                                         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); },
562                                         xns : Roo.grid,
563                                         dataIndex : 'images_id_id'
564                                     },
565 {
566                                         editor : {
567                                             field : {
568                                                 '|xns' : 'Roo.form',
569                                                 xtype : 'TextField',
570                                                 xns : Roo.form
571                                             },
572                                             '|xns' : 'Roo.grid',
573                                             xtype : 'GridEditor',
574                                             xns : Roo.grid,
575                                             items : [
576
577                                             ]
578
579                                         },
580                                         '|xns' : 'Roo.grid',
581                                         xtype : 'ColumnModel',
582                                         header : 'Name',
583                                         width : 200,
584                                         renderer : function(v) { return String.format('{0}', v); },
585                                         xns : Roo.grid,
586                                         dataIndex : 'name',
587                                         items : [
588
589                                         ]
590
591                                     },
592 {
593                                         editor : {
594                                             field : {
595                                                 '|xns' : 'Roo.form',
596                                                 xtype : 'TextField',
597                                                 xns : Roo.form
598                                             },
599                                             '|xns' : 'Roo.grid',
600                                             xtype : 'GridEditor',
601                                             xns : Roo.grid,
602                                             items : [
603
604                                             ]
605
606                                         },
607                                         '|xns' : 'Roo.grid',
608                                         xtype : 'ColumnModel',
609                                         width : 200,
610                                         header : 'Display Name',
611                                         renderer : function(v) { return String.format('{0}', v); },
612                                         xns : Roo.grid,
613                                         dataIndex : 'display_name',
614                                         items : [
615
616                                         ]
617
618                                     },
619 {
620                                         '|xns' : 'Roo.grid',
621                                         xtype : 'ColumnModel',
622                                         width : 75,
623                                         header : 'Active',
624                                         renderer : function(v) {  
625                                             var state = v> 0 ?  '-checked' : '';
626                                         
627                                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
628                                                         
629                                          },
630                                         xns : Roo.grid,
631                                         dataIndex : 'active'
632                                     },
633 {
634                                         editor : {
635                                             field : {
636                                                 '|xns' : 'Roo.form',
637                                                 allowNegative : true,
638                                                 xtype : 'NumberField',
639                                                 allowDecimals : false,
640                                                 decimalPrecision : 0,
641                                                 xns : Roo.form
642                                             },
643                                             '|xns' : 'Roo.grid',
644                                             xtype : 'GridEditor',
645                                             xns : Roo.grid,
646                                             items : [
647
648                                             ]
649
650                                         },
651                                         '|xns' : 'Roo.grid',
652                                         xtype : 'ColumnModel',
653                                         sortable : true,
654                                         header : 'Order #',
655                                         width : 75,
656                                         renderer : function(v) { return String.format('{0}', v); },
657                                         xns : Roo.grid,
658                                         dataIndex : 'seqid',
659                                         items : [
660
661                                         ]
662
663                                     }
664                             ],
665                             listeners : {
666                                 beforeedit : function (e)
667                                    {
668                                        if(e.field == 'name' && e.record.data.is_system_enum*1 == 1){
669                                            return false;
670                                        }
671                                    },
672                                 render : function() 
673                                    {
674                                        _this.grid = this; 
675                                        //_this.dialog = Pman.Dialog.FILL_IN
676                                        if (_this.panel.active) {
677                                           this.footer.onClick('first');
678                                        }
679                                    },
680                                 cellclick : function (_self, rowIndex, columnIndex, e)
681                                    {
682                                    
683                                            var di = this.colModel.getDataIndex(columnIndex);
684                                            if (di != 'active') {
685                                                return;
686                                            }
687                                             
688                                            var rec = _this.grid.ds.getAt(rowIndex);
689                                            
690                                            rec.set('active', rec.data.active ? 0 : 1);
691                                            rec.commit();
692                                             
693                                            
694                                    },
695                                 afteredit : function (e)
696                                    {
697                                       e.record.commit();     
698                                    }
699                             },
700                             items : [
701
702                             ]
703
704                         },
705                         '|xns' : 'Roo',
706                         background : false,
707                         region : 'center',
708                         fitToframe : true,
709                         title : "Pulldown Options",
710                         xtype : 'GridPanel',
711                         xns : Roo,
712                         tableName : 'core_enum',
713                         listeners : {
714                                 activate : function() {
715                                        _this.panel = this;
716                                        if (_this.grid) {
717                                            _this.grid.footer.onClick('first');
718                                        }
719                                    }
720                         },
721                         items : [
722
723                         ]
724
725                     }
726                 ]
727
728             },
729             '|xns' : 'Roo',
730             xtype : 'NestedLayoutPanel',
731             xns : Roo,
732             region : 'center',
733             title : "Pulldown Options",
734             items : [
735
736             ]
737
738         };    }
739 });