Pman.Dialog.CoreCompanies.bjs
[Pman.Core] / Pman.Dialog.CoreCompanies.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Pman.Dialog.CoreCompanies = {
6
7     dialog : false,
8     callback:  false,
9
10     show : function(data, cb)
11     {
12         if (!this.dialog) {
13             this.create();
14         }
15
16         this.callback = cb;
17         this.data = data;
18         this.dialog.show(this.data._el);
19         if (this.form) {
20            this.form.reset();
21            this.form.setValues(data);
22            this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
23         }
24
25     },
26
27     create : function()
28     {
29         var _this = this;
30         this.dialog = Roo.factory({
31             xtype: 'LayoutDialog',
32             xns: Roo,
33             autoCreate : 'true',
34             closable : false,
35             collapsible : false,
36             draggable : false,
37             height : 400,
38             modal : true,
39             shadow : 'true',
40             title : "Edit Companies",
41             width : 750,
42             items : [
43                 {
44                     xtype: 'ContentPanel',
45                     xns: Roo,
46                     autoCreate : 'true',
47                     items : [
48                         {
49                             xtype: 'Form',
50                             xns: Roo.form,
51                             listeners : {
52                                 actionfailed : function(f, act) {
53                                     _this.dialog.el.unmask();
54                                     // error msg???
55                                     Pman.standardActionFailed(f,act);
56                                               
57                                 },
58                                 actioncomplete : function(f, act) {
59                                     _this.dialog.el.unmask();
60                                     //console.log('load completed'); 
61                                     // error messages?????
62                                     
63                                    
64                                     if (act.type == 'load') {
65                                         
66                                         _this.data = act.result.data;
67                                         var meth = _this.data.isOwner || !Pman.Login.isOwner() ? 'disable' : 'enable';
68                                      
69                                             
70                                         if (_this.form.findField('comptype')) {
71                                             _this.form.findField('comptype')[meth]();
72                                         }
73                                          
74                                        // _this.loaded();
75                                         return;
76                                     }
77                                     
78                                     
79                                     if (act.type == 'submit') { // only submitted here if we are 
80                                         _this.dialog.hide();
81                                        
82                                         if (_this.callback) {
83                                             _this.callback.call(this, act.result.data);
84                                         }
85                                         return; 
86                                     }
87                                     // unmask?? 
88                                 }
89                             },
90                             fileUpload : true,
91                             labelWidth : 150
92                         }
93                     ]
94                 }
95             ],
96             center : {
97                 xtype: 'LayoutRegion',
98                 xns: Roo,
99                 alwaysShowTabs : false,
100                 autoScroll : false,
101                 closeOnTab : true,
102                 hideTabs : true,
103                 titlebar : false
104             },
105             buttons : [
106                 {
107                     xtype: 'Button',
108                     xns: Roo,
109                     text : "Cancel"
110                 },
111                 {
112                     xtype: 'Button',
113                     xns: Roo,
114                     text : "Save"
115                 }
116             ]
117         });
118     }
119 };