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.etypeCombo.getValue(),
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                                                        Roo.MessageBox.prompt ("Create a new Enum type",
158                                                            "Enter the name for a new enum type, " + 
159                                                            "this is only relivant if you  know how it is going to be used",
160                                                            function(btn,txt) {
161                                                                if (btn != 'ok') {
162                                                                    return; 
163                                                                }
164                                                                new Pman.Request({
165                                                                    url : baseURL + '/Roo/Core_enum.php',
166                                                                    method : 'POST',
167                                                                    params : {
168                                                                        etype : '',
169                                                                        name : txt,
170                                                                        active : 1
171                                                                    }, 
172                                                                    success : function() {
173                                                                        Roo.MessageBox.alert("Created", "You can now select it from the type list on the left");
174                                                                    }
175                                                                });
176                                                                        
177                                                                
178                                                                 
179                                                                 
180                                                            }
181                                                        ); 
182                                                             
183                                                             
184                                                    
185                                                    }
186                                         }
187                                     }
188                                 ]
189
190                             },
191                             '|xns' : 'Roo.grid',
192                             autoExpandColumn : 'display_name',
193                             xtype : 'EditorGrid',
194                             loadMask : true,
195                             clicksToEdit : 1,
196                             xns : Roo.grid,
197                             colModel : [
198                                  {
199                                         '|xns' : 'Roo.grid',
200                                         xtype : 'ColumnModel',
201                                         header : 'Pulldown',
202                                         width : 200,
203                                         renderer : function(v,x,r) { 
204                                         
205                                         
206                                             return String.format('<span qtip="{1}">{0}</span>', (''+v).length ? v : r.data.name, r.data.name); 
207                                         },
208                                         xns : Roo.grid,
209                                         dataIndex : 'display_name'
210                                     },
211 {
212                                         '|xns' : 'Roo.grid',
213                                         xtype : 'ColumnModel',
214                                         header : 'Active',
215                                         width : 50,
216                                         renderer : function(v) {  
217                                             var state = v> 0 ?  '-checked' : '';
218                                         
219                                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
220                                                         
221                                          },
222                                         xns : Roo.grid,
223                                         dataIndex : 'active'
224                                     }
225                             ],
226                             listeners : {
227                                 beforeedit : function (e)
228                                    {
229                                        if(e.field == 'name' && e.record.data.is_system_enum*1 == 1){
230                                            return false;
231                                        }
232                                    },
233                                 cellclick : function (_self, rowIndex, columnIndex, e)
234                                    {
235                                    
236                                            var di = this.colModel.getDataIndex(columnIndex);
237                                            if (di != 'active') {
238                                                return;
239                                            }
240                                             
241                                            var rec = _this.grid.ds.getAt(rowIndex);
242                                            
243                                            rec.set('active', rec.data.active ? 0 : 1);
244                                            rec.commit();
245                                             
246                                            
247                                    },
248                                 render : function() 
249                                    {
250                                        _this.egrid = this; 
251                                        //_this.dialog = Pman.Dialog.FILL_IN
252                                        if (_this.epanel.active) {
253                                           this.footer.onClick('first');
254                                        }
255                                    },
256                                 afteredit : function (e)
257                                    {
258                                       e.record.commit();     
259                                    }
260                             },
261                             items : [
262
263                             ]
264
265                         },
266                         '|xns' : 'Roo',
267                         background : false,
268                         region : 'west',
269                         title : "Pulldown Options",
270                         xtype : 'GridPanel',
271                         xns : Roo,
272                         tableName : 'core_enum',
273                         listeners : {
274                                 activate : function() {
275                                        _this.epanel = this;
276                                        if (_this.egrid) {
277                                            _this.egrid.footer.onClick('first');
278                                        }
279                                    }
280                         },
281                         items : [
282
283                         ]
284
285                     },
286                         {
287                         grid : {
288                             dataSource : {
289                                 proxy : {
290                                     '|xns' : 'Roo.data',
291                                     url : baseURL + '/Roo/core_enum.php',
292                                     method : 'GET',
293                                     xtype : 'HttpProxy',
294                                     xns : Roo.data
295                                 },
296                                 reader : {
297                                     '|xns' : 'Roo.data',
298                                     id : 'id',
299                                     root : 'data',
300                                     xtype : 'JsonReader',
301                                     xns : Roo.data,
302                                     fields : [
303                                         {
304                                             'name': 'id',
305                                             'type': 'int'
306                                         },
307                                         {
308                                             'name': 'etype',
309                                             'type': 'string'
310                                         },
311                                         {
312                                             'name': 'name',
313                                             'type': 'string'
314                                         },
315                                         {
316                                             'name': 'active',
317                                             'type': 'int'
318                                         },
319                                         {
320                                             'name': 'seqid',
321                                             'type': 'int'
322                                         }
323                                     ],
324                                     totalProperty : 'total'
325                                 },
326                                 '|xns' : 'Roo.data',
327                                 xtype : 'Store',
328                                 remoteSort : true,
329                                 sortInfo : { field : 'etype', direction: 'ASC' },
330                                 xns : Roo.data,
331                                 listeners : {
332                                         update : function (_self, record, operation)
333                                            {
334                                                if (operation != Roo.data.Record.COMMIT) {
335                                                    return;
336                                                }
337                                                // got commit..
338                                                new Pman.Request({
339                                                    url : baseURL + '/Roo/Core_enum.php',
340                                                    method : 'POST',
341                                                    params : {
342                                                        id : record.data.id,
343                                                        etype : _this.etypeCombo.getValue(),
344                                                        name : record.data.name,
345                                                        active : record.data.active,
346                                                        seqid : record.data.seqid,
347                                                        display_name : record.data.display_name
348                                                    }, 
349                                                    success : function(res) {
350                                                        //Roo.log(data);
351                                                        // update the ID if it's not set..
352                                                        if (record.data.id * 1 < 1) {
353                                                            record.set('id', res.data.id);
354                                                        }
355                                                    }
356                                                });
357                                                
358                                            },
359                                         beforeload : function (_self, options)
360                                            {
361                                            
362                                                var s =     _this.egrid.getSelectionModel().getSelectedCell();
363                                                
364                                            
365                                                if (!s) {
366                                                    return false;
367                                                }
368                                                var d = _this.egrid.dataSource.getAt(s[0]);
369                                                
370                                                options.params.etype = d.data.name;
371                                                if (!options.params.etype.length) {
372                                                    return false;
373                                                }
374                                            }
375                                 },
376                                 items : [
377
378                                 ]
379
380                             },
381                             footer : {
382                                 '|xns' : 'Roo',
383                                 pageSize : 25,
384                                 xtype : 'PagingToolbar',
385                                 emptyMsg : "No core_enum found",
386                                 xns : Roo,
387                                 displayInfo : true,
388                                 displayMsg : "Displaying core_enum{0} - {1} of {2}",
389                                 items : [
390                                         {
391                                         '|xns' : 'Roo.Toolbar',
392                                         text : "Download",
393                                         xtype : 'Button',
394                                         xns : Roo.Toolbar,
395                                         listeners : {
396                                                 click : function (_self, e)
397                                                    {
398                                                        new Pman.Download({
399                                                            grid : _this.grid
400                                                        });
401                                                        Roo.MessageBox.alert("Downloading", "File is downloading");
402                                                    }
403                                         }
404                                     },
405                                         {
406                                         '|xns' : 'Roo.Toolbar',
407                                         text : "Upload Values",
408                                         xtype : 'Button',
409                                         xns : Roo.Toolbar,
410                                         listeners : {
411                                                 click : function (_self, e)
412                                                    {
413                                                    
414                                                      var s =     _this.egrid.getSelectionModel().getSelectedCell();
415                                                        
416                                                    
417                                                        if (!s) {
418                                                            Roo.MessageBox.alert("Error", "Select a pulldown");
419                                                        }
420                                                        
421                                                        var d = _this.egrid.dataSource.getAt(s[0]);
422                                                     
423                                                    
424                                                        var etype = d.data.name;
425                                                        
426                                                        if(!etype.length){
427                                                            Roo.MessageBox.alert('Error', 'Please select a pulldown');
428                                                            return;
429                                                        }
430                                                        
431                                                        Pman.Dialog.Image.show(
432                                                           {
433                                                                _url : baseURL+'/Admin/Import/Enum?' + Roo.urlEncode({'etype' : etype})
434                                                            
435                                                           },
436                                                           function () {
437                                                                _this.grid.footer.onClick('first');
438                                                           }
439                                                       );
440                                                    }
441                                         }
442                                     }
443                                 ]
444
445                             },
446                             toolbar : {
447                                 '|xns' : 'Roo',
448                                 xtype : 'Toolbar',
449                                 xns : Roo,
450                                 items : [
451                                         {
452                                         '|xns' : 'Roo.Toolbar',
453                                         text : "Add Value",
454                                         xtype : 'Button',
455                                         cls : 'x-btn-text-icon',
456                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
457                                         xns : Roo.Toolbar,
458                                         listeners : {
459                                                 click : function()
460                                                    {
461                                                        
462                                                        // if we do not have a selected type... - what should we show..?
463                                                        
464                                                        
465                                                        var s =     _this.egrid.getSelectionModel().getSelectedCell();
466                                                        
467                                                    
468                                                        if (!s) {
469                                                            Roo.MessageBox.alert("Error", "Select a pulldown");
470                                                        }
471                                                        
472                                                        var d = _this.egrid.dataSource.getAt(s[0]);
473                                                     
474                                                    
475                                                        var ds = _this.grid.getDataSource();
476                                                    
477                                                        var add = ds.reader.newRow({    
478                                                                 id: 0, 
479                                                                 display_name : '', 
480                                                                 name : '', 
481                                                                 etype: d.data.name, 
482                                                                 active: 1, 
483                                                                 seqid: 0
484                                                          });
485                                                         var r = ds.data.length;
486                                                        ds.insert(r  , add);  
487                                                        _this.grid.startEditing(r, 1); // name... 
488                                                    }
489                                         }
490                                     },
491                                         {
492                                         '|xns' : 'Roo.Toolbar',
493                                         text : "Add Image",
494                                         xtype : 'Button',
495                                         cls : 'x-btn-text-icon',
496                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
497                                         xns : Roo.Toolbar,
498                                         listeners : {
499                                                 click : function()
500                                                    {
501                                                        
502                                                        // if we do not have a selected type... - what should we show..?
503                                                        var et = _this.etypeCombo.getValue();
504                                                        
505                                                        if (!et) {
506                                                            Roo.MessageBox.alert("Error", "Select a pulldown");
507                                                            return;
508                                                        }
509                                                        var sc = _this.grid.getSelectionModel().getSelectedCell();
510                                                        Roo.log(sc);
511                                                        var ds = _this.grid.ds.getAt(sc[0]);
512                                                        if (!ds) {
513                                                            Roo.MessageBox.alert("Error", "Select enum");
514                                                            return;
515                                                        }
516                                                        
517                                                        Roo.log(ds);
518                                                        Pman.Dialog.AdminEnumImages.show({onid:ds.data.id}, function(){
519                                                            _this.grid.footer.onClick('first');
520                                                        });
521                                                        
522                                                    }
523                                         }
524                                     }
525                                 ]
526
527                             },
528                             '|xns' : 'Roo.grid',
529                             autoExpandColumn : 'display_name',
530                             xtype : 'EditorGrid',
531                             loadMask : true,
532                             clicksToEdit : 1,
533                             xns : Roo.grid,
534                             colModel : [
535                                  {
536                                         '|xns' : 'Roo.grid',
537                                         xtype : 'ColumnModel',
538                                         width : 75,
539                                         header : 'Internal #',
540                                         renderer : function(v) { return String.format('{0}', v); },
541                                         xns : Roo.grid,
542                                         dataIndex : 'id'
543                                     },
544 {
545                                         '|xns' : 'Roo.grid',
546                                         xtype : 'ColumnModel',
547                                         width : 75,
548                                         header : 'Image',
549                                         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); },
550                                         xns : Roo.grid,
551                                         dataIndex : 'images_id_id'
552                                     },
553 {
554                                         editor : {
555                                             field : {
556                                                 '|xns' : 'Roo.form',
557                                                 xtype : 'TextField',
558                                                 xns : Roo.form
559                                             },
560                                             '|xns' : 'Roo.grid',
561                                             xtype : 'GridEditor',
562                                             xns : Roo.grid,
563                                             items : [
564
565                                             ]
566
567                                         },
568                                         '|xns' : 'Roo.grid',
569                                         xtype : 'ColumnModel',
570                                         header : 'Name',
571                                         width : 200,
572                                         renderer : function(v) { return String.format('{0}', v); },
573                                         xns : Roo.grid,
574                                         dataIndex : 'name',
575                                         items : [
576
577                                         ]
578
579                                     },
580 {
581                                         editor : {
582                                             field : {
583                                                 '|xns' : 'Roo.form',
584                                                 xtype : 'TextField',
585                                                 xns : Roo.form
586                                             },
587                                             '|xns' : 'Roo.grid',
588                                             xtype : 'GridEditor',
589                                             xns : Roo.grid,
590                                             items : [
591
592                                             ]
593
594                                         },
595                                         '|xns' : 'Roo.grid',
596                                         xtype : 'ColumnModel',
597                                         width : 200,
598                                         header : 'Display Name',
599                                         renderer : function(v) { return String.format('{0}', v); },
600                                         xns : Roo.grid,
601                                         dataIndex : 'display_name',
602                                         items : [
603
604                                         ]
605
606                                     },
607 {
608                                         '|xns' : 'Roo.grid',
609                                         xtype : 'ColumnModel',
610                                         width : 75,
611                                         header : 'Active',
612                                         renderer : function(v) {  
613                                             var state = v> 0 ?  '-checked' : '';
614                                         
615                                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
616                                                         
617                                          },
618                                         xns : Roo.grid,
619                                         dataIndex : 'active'
620                                     },
621 {
622                                         editor : {
623                                             field : {
624                                                 '|xns' : 'Roo.form',
625                                                 allowNegative : true,
626                                                 xtype : 'NumberField',
627                                                 allowDecimals : false,
628                                                 decimalPrecision : 0,
629                                                 xns : Roo.form
630                                             },
631                                             '|xns' : 'Roo.grid',
632                                             xtype : 'GridEditor',
633                                             xns : Roo.grid,
634                                             items : [
635
636                                             ]
637
638                                         },
639                                         '|xns' : 'Roo.grid',
640                                         xtype : 'ColumnModel',
641                                         sortable : true,
642                                         header : 'Order #',
643                                         width : 75,
644                                         renderer : function(v) { return String.format('{0}', v); },
645                                         xns : Roo.grid,
646                                         dataIndex : 'seqid',
647                                         items : [
648
649                                         ]
650
651                                     }
652                             ],
653                             listeners : {
654                                 beforeedit : function (e)
655                                    {
656                                        if(e.field == 'name' && e.record.data.is_system_enum*1 == 1){
657                                            return false;
658                                        }
659                                    },
660                                 render : function() 
661                                    {
662                                        _this.grid = this; 
663                                        //_this.dialog = Pman.Dialog.FILL_IN
664                                        if (_this.panel.active) {
665                                           this.footer.onClick('first');
666                                        }
667                                    },
668                                 cellclick : function (_self, rowIndex, columnIndex, e)
669                                    {
670                                    
671                                            var di = this.colModel.getDataIndex(columnIndex);
672                                            if (di != 'active') {
673                                                return;
674                                            }
675                                             
676                                            var rec = _this.grid.ds.getAt(rowIndex);
677                                            
678                                            rec.set('active', rec.data.active ? 0 : 1);
679                                            rec.commit();
680                                             
681                                            
682                                    },
683                                 afteredit : function (e)
684                                    {
685                                       e.record.commit();     
686                                    }
687                             },
688                             items : [
689
690                             ]
691
692                         },
693                         '|xns' : 'Roo',
694                         background : false,
695                         region : 'center',
696                         fitToframe : true,
697                         title : "Pulldown Options",
698                         xtype : 'GridPanel',
699                         xns : Roo,
700                         tableName : 'core_enum',
701                         listeners : {
702                                 activate : function() {
703                                        _this.panel = this;
704                                        if (_this.grid) {
705                                            _this.grid.footer.onClick('first');
706                                        }
707                                    }
708                         },
709                         items : [
710
711                         ]
712
713                     }
714                 ]
715
716             },
717             '|xns' : 'Roo',
718             xtype : 'NestedLayoutPanel',
719             xns : Roo,
720             region : 'center',
721             title : "Pulldown Options",
722             items : [
723
724             ]
725
726         };    }
727 });