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