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