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                                     listeners : {
97                                         specialkey : function (_self, e)
98                                         {
99                                         
100                                         }
101                                     }
102                                 },
103                                 {
104                                     xtype: 'Hidden',
105                                     xns: Roo.form,
106                                     name : 'id'
107                                 }
108                             ]
109                         }
110                     ]
111                 }
112             ],
113             center : {
114                 xtype: 'LayoutRegion',
115                 xns: Roo
116             },
117             buttons : [
118                 {
119                     xtype: 'Button',
120                     xns: Roo,
121                     listeners : {
122                         click : function (_self, e)
123                         {
124                             _this.dialog.hide();
125                         }
126                     },
127                     text : "Cancel"
128                 },
129                 {
130                     xtype: 'Button',
131                     xns: Roo,
132                     listeners : {
133                         click : function (_self, e)
134                         {
135                             // do some checks?
136                              
137                              this.url = baseURL + '/Roo/' + _this.data._table;
138                             _this.dialog.el.mask("Saving");
139                             _this.form.doAction("submit");
140                         
141                         }
142                     },
143                     text : "Save"
144                 }
145             ]
146         });
147     }
148 };