sync
[Pman.Admin] / Pman.Dialog.AdminGenericName.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.Dialog');
6
7 Pman.Dialog.AdminGenericName = {
8
9     dialog : false,
10     callback:  false,
11
12     show : function(data, cb)
13     {
14         if (!this.dialog) {
15             this.create();
16         }
17
18         this.callback = cb;
19         this.data = data;
20         this.dialog.show(this.data._el);
21         if (this.form) {
22            this.form.reset();
23            this.form.setValues(data);
24            this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
25         }
26
27     },
28
29     create : function()
30     {
31         var _this = this;
32         this.dialog = Roo.factory({
33             center : {
34                 '|xns' : 'Roo',
35                 xtype : 'LayoutRegion',
36                 xns : Roo
37             },
38             '|xns' : 'Roo',
39             modal : true,
40             collapsible : false,
41             title : "Edit",
42             xtype : 'LayoutDialog',
43             width : 400,
44             xns : Roo,
45             closable : false,
46             resizable : false,
47             height : 120,
48             buttons : [
49                  {
50                         '|xns' : 'Roo',
51                         text : "Cancel",
52                         xtype : 'Button',
53                         xns : Roo,
54                         listeners : {
55                                 click : function (_self, e)
56                                    {
57                                        _this.dialog.hide();
58                                    }
59                         }
60                     },
61 {
62                         '|xns' : 'Roo',
63                         text : "Save",
64                         xtype : 'Button',
65                         xns : Roo,
66                         listeners : {
67                                 click : function (_self, e)
68                                    {
69                                        // do some checks?
70                                         
71                                         this.url = baseURL + '/Roo/' + _this.data._table;
72                                        _this.dialog.el.mask("Saving");
73                                        _this.form.doAction("submit");
74                                    
75                                    }
76                         }
77                     }
78             ],
79             items : [
80                 {
81                     '|xns' : 'Roo',
82                     region : 'center',
83                     xtype : 'ContentPanel',
84                     xns : Roo,
85                     items : [
86                         {
87                             '|xns' : 'Roo.form',
88                             url : baseURL + '/Roo/core_company_type.php',
89                             style : 'margin:10px;',
90                             method : 'POST',
91                             xtype : 'Form',
92                             labelWidth : 50,
93                             xns : Roo.form,
94                             listeners : {
95                                 actioncomplete : function(_self,action)
96                                    {
97                                        if (action.type == 'setdata') {
98                                           //_this.dialog.el.mask("Loading");
99                                           this.url = baseURL + '/Roo/' + _this.data._table;
100                                           _this.dialog.setTitle(_this.data._title);
101                                           this.load({ 
102                                                method: 'GET', 
103                                                params: { '_id' : _this.data.id },
104                                                url : this.url
105                                            });
106                                           return;
107                                        }
108                                        if (action.type == 'load') {
109                                            _this.dialog.el.unmask();
110                                            _this.form.findField('name').focus();
111                                            return;
112                                        }
113                                        if (action.type =='submit') {
114                                        
115                                            _this.dialog.el.unmask();
116                                            _this.dialog.hide();
117                                        
118                                             if (_this.callback) {
119                                                _this.callback.call(_this, _this.form.getValues());
120                                             }
121                                             _this.form.reset();
122                                             return;
123                                        }
124                                    },
125                                 rendered : function (form)
126                                    {
127                                        _this.form= form;
128                                    }
129                             },
130                             items : [
131                                 {
132                                     '|xns' : 'Roo.form',
133                                     fieldLabel : 'Name',
134                                     xtype : 'TextField',
135                                     width : 270,
136                                     xns : Roo.form,
137                                     name : 'name',
138                                     listeners : {
139                                         specialkey : function (_self, e)
140                                            {
141                                                if (e.getKey() == 13) {
142                                                     _this.dialog.el.mask("Saving");
143                                                     _this.form.doAction("submit");
144                                                }
145                                            }
146                                     }
147                                 },
148                                 {
149                                     '|xns' : 'Roo.form',
150                                     xtype : 'Hidden',
151                                     xns : Roo.form,
152                                     name : 'id'
153                                 }
154                             ]
155
156                         }
157                     ]
158
159                 }
160             ]
161
162         });
163     }
164 };