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, 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 Value",
408                                         xtype : 'Button',
409                                         xns : Roo.Toolbar,
410                                         listeners : {
411                                                 click : function (_self, e)
412                                                    {
413                                                        var etype = _this.etypeCombo.getValue();
414                                                        
415                                                        if(!etype.length){
416                                                            Roo.MessageBox.alert('Error', 'Please select a pulldown');
417                                                            return;
418                                                        }
419                                                        
420                                                        Pman.Dialog.Image.show(
421                                                           {
422                                                                _url : baseURL+'/Xtuple/Import/Enum?' + Roo.urlEncode({'etype' : etype})
423                                                            
424                                                           },
425                                                           function () {
426                                                                _this.grid.footer.onClick('first');
427                                                           }
428                                                       );
429                                                    }
430                                         }
431                                     }
432                                 ]
433
434                             },
435                             toolbar : {
436                                 '|xns' : 'Roo',
437                                 xtype : 'Toolbar',
438                                 xns : Roo,
439                                 items : [
440                                         {
441                                         '|xns' : 'Roo.Toolbar',
442                                         text : "Pulldown Name:",
443                                         xtype : 'TextItem',
444                                         xns : Roo.Toolbar
445                                     },
446                                         {
447                                         '|xns' : 'Roo.Toolbar',
448                                         text : "Add Value",
449                                         xtype : 'Button',
450                                         cls : 'x-btn-text-icon',
451                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
452                                         xns : Roo.Toolbar,
453                                         listeners : {
454                                                 click : function()
455                                                    {
456                                                        
457                                                        // if we do not have a selected type... - what should we show..?
458                                                        var et = _this.etypeCombo.getValue();
459                                                        var ds = _this.grid.getDataSource();
460                                                        if (!et) {
461                                                            Roo.MessageBox.alert("Error", "Select a pulldown");
462                                                            return;
463                                                        }
464                                                    
465                                                        var add = ds.reader.newRow({    
466                                                                 id: 0, 
467                                                                 display_name : '', 
468                                                                 name : '', 
469                                                                 etype: et, 
470                                                                 active: 1, 
471                                                                 seqid: 0
472                                                          });
473                                                         var r = ds.data.length;
474                                                        ds.insert(r  , add);  
475                                                        _this.grid.startEditing(r, 1); // name... 
476                                                    }
477                                         }
478                                     },
479                                         {
480                                         '|xns' : 'Roo.Toolbar',
481                                         text : "Add Image",
482                                         xtype : 'Button',
483                                         cls : 'x-btn-text-icon',
484                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
485                                         xns : Roo.Toolbar,
486                                         listeners : {
487                                                 click : function()
488                                                    {
489                                                        
490                                                        // if we do not have a selected type... - what should we show..?
491                                                        var et = _this.etypeCombo.getValue();
492                                                        
493                                                        if (!et) {
494                                                            Roo.MessageBox.alert("Error", "Select a pulldown");
495                                                            return;
496                                                        }
497                                                        var sc = _this.grid.getSelectionModel().getSelectedCell();
498                                                        Roo.log(sc);
499                                                        var ds = _this.grid.ds.getAt(sc[0]);
500                                                        if (!ds) {
501                                                            Roo.MessageBox.alert("Error", "Select enum");
502                                                            return;
503                                                        }
504                                                        
505                                                        Roo.log(ds);
506                                                        Pman.Dialog.AdminEnumImages.show({onid:ds.data.id}, function(){
507                                                            _this.grid.footer.onClick('first');
508                                                        });
509                                                        
510                                                    }
511                                         }
512                                     },
513                                         {
514                                         '|xns' : 'Roo.Toolbar',
515                                         xtype : 'Fill',
516                                         xns : Roo.Toolbar
517                                     },
518                                         {
519                                         '|xns' : 'Roo.Toolbar',
520                                         text : "Add new pulldown list",
521                                         xtype : 'Button',
522                                         cls : 'x-btn-text-icon',
523                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
524                                         xns : Roo.Toolbar,
525                                         listeners : {
526                                                 click : function()
527                                                    {
528                                                        
529                                                        Roo.MessageBox.prompt ("Create a new Enum type",
530                                                            "Enter the name for a new enum type, " + 
531                                                            "this is only relivant if you  know how it is going to be used",
532                                                            function(btn,txt) {
533                                                                if (btn != 'ok') {
534                                                                    return; 
535                                                                }
536                                                                new Pman.Request({
537                                                                    url : baseURL + '/Roo/Core_enum.php',
538                                                                    method : 'POST',
539                                                                    params : {
540                                                                        etype : '',
541                                                                        name : txt,
542                                                                        active : 1
543                                                                    }, 
544                                                                    success : function() {
545                                                                        Roo.MessageBox.alert("Created", "You can now select it from the type list on the left");
546                                                                    }
547                                                                });
548                                                                        
549                                                                
550                                                                 
551                                                                 
552                                                            }
553                                                        ); 
554                                                             
555                                                             
556                                                    
557                                                    }
558                                         }
559                                     }
560                                 ]
561
562                             },
563                             '|xns' : 'Roo.grid',
564                             autoExpandColumn : 'display_name',
565                             xtype : 'EditorGrid',
566                             loadMask : true,
567                             clicksToEdit : 1,
568                             xns : Roo.grid,
569                             colModel : [
570                                  {
571                                         '|xns' : 'Roo.grid',
572                                         xtype : 'ColumnModel',
573                                         width : 75,
574                                         header : 'Internal #',
575                                         renderer : function(v) { return String.format('{0}', v); },
576                                         xns : Roo.grid,
577                                         dataIndex : 'id'
578                                     },
579 {
580                                         '|xns' : 'Roo.grid',
581                                         xtype : 'ColumnModel',
582                                         width : 75,
583                                         header : 'Image',
584                                         renderer : function(v,x,r) { return String.format('<img src="{0}/Images/Thumb/25/{1}/{2}" width="25" height="25">', baseURL, v, r.data.images_id_filename); },
585                                         xns : Roo.grid,
586                                         dataIndex : 'images_id_id'
587                                     },
588 {
589                                         editor : {
590                                             field : {
591                                                 '|xns' : 'Roo.form',
592                                                 xtype : 'TextField',
593                                                 xns : Roo.form
594                                             },
595                                             '|xns' : 'Roo.grid',
596                                             xtype : 'GridEditor',
597                                             xns : Roo.grid,
598                                             items : [
599
600                                             ]
601
602                                         },
603                                         '|xns' : 'Roo.grid',
604                                         xtype : 'ColumnModel',
605                                         header : 'Name',
606                                         width : 200,
607                                         renderer : function(v) { return String.format('{0}', v); },
608                                         xns : Roo.grid,
609                                         dataIndex : 'name',
610                                         items : [
611
612                                         ]
613
614                                     },
615 {
616                                         editor : {
617                                             field : {
618                                                 '|xns' : 'Roo.form',
619                                                 xtype : 'TextField',
620                                                 xns : Roo.form
621                                             },
622                                             '|xns' : 'Roo.grid',
623                                             xtype : 'GridEditor',
624                                             xns : Roo.grid,
625                                             items : [
626
627                                             ]
628
629                                         },
630                                         '|xns' : 'Roo.grid',
631                                         xtype : 'ColumnModel',
632                                         width : 200,
633                                         header : 'Display Name',
634                                         renderer : function(v) { return String.format('{0}', v); },
635                                         xns : Roo.grid,
636                                         dataIndex : 'display_name',
637                                         items : [
638
639                                         ]
640
641                                     },
642 {
643                                         '|xns' : 'Roo.grid',
644                                         xtype : 'ColumnModel',
645                                         width : 75,
646                                         header : 'Active',
647                                         renderer : function(v) {  
648                                             var state = v> 0 ?  '-checked' : '';
649                                         
650                                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
651                                                         
652                                          },
653                                         xns : Roo.grid,
654                                         dataIndex : 'active'
655                                     },
656 {
657                                         editor : {
658                                             field : {
659                                                 '|xns' : 'Roo.form',
660                                                 allowNegative : true,
661                                                 xtype : 'NumberField',
662                                                 allowDecimals : false,
663                                                 decimalPrecision : 0,
664                                                 xns : Roo.form
665                                             },
666                                             '|xns' : 'Roo.grid',
667                                             xtype : 'GridEditor',
668                                             xns : Roo.grid,
669                                             items : [
670
671                                             ]
672
673                                         },
674                                         '|xns' : 'Roo.grid',
675                                         xtype : 'ColumnModel',
676                                         sortable : true,
677                                         header : 'Order #',
678                                         width : 75,
679                                         renderer : function(v) { return String.format('{0}', v); },
680                                         xns : Roo.grid,
681                                         dataIndex : 'seqid',
682                                         items : [
683
684                                         ]
685
686                                     }
687                             ],
688                             listeners : {
689                                 beforeedit : function (e)
690                                    {
691                                        if(e.field == 'name' && e.record.data.is_system_enum*1 == 1){
692                                            return false;
693                                        }
694                                    },
695                                 render : function() 
696                                    {
697                                        _this.grid = this; 
698                                        //_this.dialog = Pman.Dialog.FILL_IN
699                                        if (_this.panel.active) {
700                                           this.footer.onClick('first');
701                                        }
702                                    },
703                                 cellclick : function (_self, rowIndex, columnIndex, e)
704                                    {
705                                    
706                                            var di = this.colModel.getDataIndex(columnIndex);
707                                            if (di != 'active') {
708                                                return;
709                                            }
710                                             
711                                            var rec = _this.grid.ds.getAt(rowIndex);
712                                            
713                                            rec.set('active', rec.data.active ? 0 : 1);
714                                            rec.commit();
715                                             
716                                            
717                                    },
718                                 afteredit : function (e)
719                                    {
720                                       e.record.commit();     
721                                    }
722                             },
723                             items : [
724
725                             ]
726
727                         },
728                         '|xns' : 'Roo',
729                         fitToframe : true,
730                         background : false,
731                         region : 'center',
732                         title : "Pulldown Options",
733                         xtype : 'GridPanel',
734                         xns : Roo,
735                         tableName : 'core_enum',
736                         listeners : {
737                                 activate : function() {
738                                        _this.panel = this;
739                                        if (_this.grid) {
740                                            _this.grid.footer.onClick('first');
741                                        }
742                                    }
743                         },
744                         items : [
745
746                         ]
747
748                     }
749                 ]
750
751             },
752             '|xns' : 'Roo',
753             xtype : 'NestedLayoutPanel',
754             xns : Roo,
755             region : 'center',
756             title : "Pulldown Options",
757             items : [
758
759             ]
760
761         };    }
762 });