Pman.Dialog.AdminGenericName.js
[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 Pman.Dialog.AdminGenericName = {
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             closable : false,
34             collapsible : false,
35             height : 120,
36             modal : true,
37             resizable : false,
38             title : "Edit",
39             width : 400,
40             items : [
41                 {
42                     xtype: 'ContentPanel',
43                     xns: Roo,
44                     region : 'center',
45                     items : [
46                         {
47                             xtype: 'Form',
48                             xns: Roo.form,
49                             listeners : {
50                                 actioncomplete : function(_self,action)
51                                 {
52                                     if (action.type == 'setdata') {
53                                        //_this.dialog.el.mask("Loading");
54                                        this.url = baseURL + '/Roo/' + _this.data._table;
55                                        _this.dialog.setTitle(_this.data._title);
56                                        this.load({ 
57                                             method: 'GET', 
58                                             params: { '_id' : _this.data.id },
59                                             url : this.url
60                                         });
61                                        return;
62                                     }
63                                     if (action.type == 'load') {
64                                         _this.dialog.el.unmask();
65                                         _this.form.findField('name').focus();
66                                         return;
67                                     }
68                                     if (action.type =='submit') {
69                                     
70                                         _this.dialog.el.unmask();
71                                         _this.dialog.hide();
72                                     
73                                          if (_this.callback) {
74                                             _this.callback.call(_this, _this.form.getValues());
75                                          }
76                                          _this.form.reset();
77                                          return;
78                                     }
79                                 },
80                                 rendered : function (form)
81                                 {
82                                     _this.form= form;
83                                 }
84                             },
85                             labelWidth : 50,
86                             method : 'POST',
87                             style : 'margin:10px;',
88                             url : baseURL + '/Roo/core_company_type.php',
89                             items : [
90                                 {
91                                     xtype: 'TextField',
92                                     xns: Roo.form,
93                                     fieldLabel : 'Name',
94                                     name : 'name',
95                                     width : 270
96                                 },
97                                 {
98                                     xtype: 'Hidden',
99                                     xns: Roo.form,
100                                     name : 'id'
101                                 }
102                             ]
103                         }
104                     ]
105                 }
106             ],
107             center : {
108                 xtype: 'LayoutRegion',
109                 xns: Roo
110             },
111             buttons : [
112                 {
113                     xtype: 'Button',
114                     xns: Roo,
115                     listeners : {
116                         click : function (_self, e)
117                         {
118                             _this.dialog.hide();
119                         }
120                     },
121                     text : "Cancel"
122                 },
123                 {
124                     xtype: 'Button',
125                     xns: Roo,
126                     listeners : {
127                         click : function (_self, e)
128                         {
129                             // do some checks?
130                              
131                              this.url = baseURL + '/Roo/' + _this.data._table;
132                             _this.dialog.el.mask("Saving");
133                             _this.form.doAction("submit");
134                         
135                         }
136                     },
137                     text : "Save"
138                 }
139             ]
140         });
141     }
142 };