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                     items : [
47                         {
48                             xtype: 'Form',
49                             xns: Roo.form,
50                             listeners : {
51                                 actionfailed : function(f, act) {
52                                     _this.dialog.el.unmask();
53                                     // error msg???
54                                     Pman.standardActionFailed(f,act);
55                                               
56                                 },
57                                 actioncomplete : function(f, act) {
58                                     _this.dialog.el.unmask();
59                                     //console.log('load completed'); 
60                                     // error messages?????
61                                     
62                                    
63                                     if (act.type == 'load') {
64                                         
65                                         _this.data = act.result.data;
66                                         var meth = _this.data.isOwner || !Pman.Login.isOwner() ? 'disable' : 'enable';
67                                      
68                                             
69                                         if (_this.form.findField('comptype')) {
70                                             _this.form.findField('comptype')[meth]();
71                                         }
72                                          
73                                        // _this.loaded();
74                                         return;
75                                     }
76                                     
77                                     
78                                     if (act.type == 'submit') { // only submitted here if we are 
79                                         _this.dialog.hide();
80                                        
81                                         if (_this.callback) {
82                                             _this.callback.call(this, act.result.data);
83                                         }
84                                         return; 
85                                     }
86                                     // unmask?? 
87                                 }
88                             },
89                             fileUpload : true,
90                             labelWidth : 150
91                         }
92                     ]
93                 }
94             ],
95             center : {
96                 xtype: 'LayoutRegion',
97                 xns: Roo,
98                 alwaysShowTabs : false,
99                 autoScroll : false,
100                 closeOnTab : true,
101                 hideTabs : true,
102                 titlebar : false
103             },
104             buttons : [
105                 {
106                     xtype: 'Button',
107                     xns: Roo,
108                     text : "Cancel"
109                 },
110                 {
111                     xtype: 'Button',
112                     xns: Roo,
113                     text : "Save"
114                 }
115             ]
116         });
117     }
118 };