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