Pman.Dialog.CoreEnum.bjs
[Pman.Core] / Pman.Dialog.CoreEnum.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.CoreEnum = {
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             listeners : {
34                 show : function (_self)
35                 {
36                     
37                 }
38             },
39             background : true,
40             closable : false,
41             collapsible : false,
42             height : 100,
43             modal : true,
44             resizable : false,
45             title : "Add / Edit Core Enum",
46             width : 400,
47             items : [
48                 {
49                     xtype: 'ContentPanel',
50                     xns: Roo,
51                     background : true,
52                     fitToFrame : true,
53                     region : 'center',
54                     items : [
55                         {
56                             xtype: 'Form',
57                             xns: Roo.form,
58                             listeners : {
59                                 actioncomplete : function (_self, action)
60                                 {
61                                   if (action.type == 'setdata') {
62                                         
63                                         if(typeof(_this.data.etype == 'undefined') || !_this.data.etype.length){
64                                             Roo.MessageBox.alert('Error', 'Missing etype');
65                                             return;
66                                         }
67                                   
68                                         if(_this.data.id){
69                                             _this.dialog.el.mask("Loading");
70                                             this.load({ method: 'GET', params: { '_id' : _this.data.id }}); 
71                                         }
72                                        
73                                        return;
74                                     }
75                                     if (action.type == 'load') {
76                                         _this.dialog.el.unmask();
77                                         return;
78                                     }
79                                     if (action.type == 'submit' ) {
80                                         _this.dialog.el.unmask();
81                                         _this.dialog.hide();
82                                 
83                                         if (_this.callback) {
84                                            _this.callback.call(_this, action.result.data);
85                                         }
86                                         _this.form.reset();
87                                     }
88                                 },
89                                 rendered : function (form)
90                                 {
91                                    _this.form = form;
92                                 }
93                             },
94                             method : 'POST',
95                             style : 'margin: 5px',
96                             url : baseURL + '/Roo/core_enum.php',
97                             items : [
98                                 {
99                                     xtype: 'TextField',
100                                     xns: Roo.form,
101                                     allowBlank : false,
102                                     fieldLabel : 'Name',
103                                     name : 'name',
104                                     width : 200
105                                 },
106                                 {
107                                     xtype: 'TextField',
108                                     xns: Roo.form,
109                                     allowBlank : false,
110                                     fieldLabel : 'Industry Name',
111                                     name : 'display_name',
112                                     width : 200
113                                 },
114                                 {
115                                     xtype: 'Hidden',
116                                     xns: Roo.form,
117                                     name : 'etype'
118                                 },
119                                 {
120                                     xtype: 'Hidden',
121                                     xns: Roo.form,
122                                     name : 'active',
123                                     value : 1
124                                 },
125                                 {
126                                     xtype: 'Hidden',
127                                     xns: Roo.form,
128                                     name : 'seqid',
129                                     value : 0
130                                 },
131                                 {
132                                     xtype: 'Hidden',
133                                     xns: Roo.form,
134                                     name : 'id'
135                                 }
136                             ]
137                         }
138                     ]
139                 }
140             ],
141             center : {
142                 xtype: 'LayoutRegion',
143                 xns: Roo,
144                 titlebar : false
145             },
146             buttons : [
147                 {
148                     xtype: 'Button',
149                     xns: Roo,
150                     listeners : {
151                         click : function() {
152                             _this.form.reset();
153                             _this.dialog.hide();
154                         }
155                     },
156                     text : "Cancel"
157                 },
158                 {
159                     xtype: 'Button',
160                     xns: Roo,
161                     listeners : {
162                         click : function() {
163                         
164                             var name =     _this.form.findField('display_name').getValue();
165                             name = name.toUpperCase().replace(/[^A-Z]+/g, '');
166                             if (!name.length) {
167                                 Roo.MessageBox.alert("Error","Please fill in a valid name");
168                                 return;
169                             }
170                             _this.form.findField('name').setValue(name);
171                         
172                          
173                             _this.form.doAction('submit');
174                             
175                         }
176                     },
177                     text : "OK"
178                 }
179             ]
180         });
181     }
182 };