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                                         return;
66                                     }
67                                     if (action.type =='submit') {
68                                     
69                                         _this.dialog.el.unmask();
70                                         _this.dialog.hide();
71                                     
72                                          if (_this.callback) {
73                                             _this.callback.call(_this, _this.form.getValues());
74                                          }
75                                          _this.form.reset();
76                                          return;
77                                     }
78                                 },
79                                 rendered : function (form)
80                                 {
81                                     _this.form= form;
82                                 }
83                             },
84                             method : 'POST',
85                             style : 'margin:10px;',
86                             url : baseURL + '/Roo/core_company_type.php',
87                             labelWidth : 0,
88                             items : [
89                                 {
90                                     xtype: 'TextField',
91                                     xns: Roo.form,
92                                     fieldLabel : 'Name',
93                                     name : 'name',
94                                     width : 230
95                                 },
96                                 {
97                                     xtype: 'Hidden',
98                                     xns: Roo.form,
99                                     name : 'id'
100                                 }
101                             ]
102                         }
103                     ]
104                 }
105             ],
106             center : {
107                 xtype: 'LayoutRegion',
108                 xns: Roo
109             },
110             buttons : [
111                 {
112                     xtype: 'Button',
113                     xns: Roo,
114                     listeners : {
115                         click : function (_self, e)
116                         {
117                             _this.dialog.hide();
118                         }
119                     },
120                     text : "Cancel"
121                 },
122                 {
123                     xtype: 'Button',
124                     xns: Roo,
125                     listeners : {
126                         click : function (_self, e)
127                         {
128                             // do some checks?
129                              
130                              this.url = baseURL + '/Roo/' + _this.data._table;
131                             _this.dialog.el.mask("Saving");
132                             _this.form.doAction("submit");
133                         
134                         }
135                     },
136                     text : "Save"
137                 }
138             ]
139         });
140     }
141 };