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