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 : 150,
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                                             _this.dialog.hide();
66                                             return;
67                                         }
68                                   
69                                         if(_this.data.id){
70                                             _this.dialog.el.mask("Loading");
71                                             this.load({ method: 'GET', params: { '_id' : _this.data.id }}); 
72                                         }
73                                        
74                                        return;
75                                     }
76                                     if (action.type == 'load') {
77                                         _this.dialog.el.unmask();
78                                         return;
79                                     }
80                                     if (action.type == 'submit' ) {
81                                         _this.dialog.el.unmask();
82                                         _this.dialog.hide();
83                                 
84                                         if (_this.callback) {
85                                            _this.callback.call(_this, action.result.data);
86                                         }
87                                         _this.form.reset();
88                                     }
89                                 },
90                                 rendered : function (form)
91                                 {
92                                    _this.form = form;
93                                 }
94                             },
95                             method : 'POST',
96                             style : 'margin: 5px',
97                             url : baseURL + '/Roo/core_enum.php',
98                             items : [
99                                 {
100                                     xtype: 'TextField',
101                                     xns: Roo.form,
102                                     allowBlank : false,
103                                     fieldLabel : 'Name',
104                                     name : 'name',
105                                     width : 200
106                                 },
107                                 {
108                                     xtype: 'TextField',
109                                     xns: Roo.form,
110                                     allowBlank : false,
111                                     fieldLabel : 'Industry Name',
112                                     name : 'display_name',
113                                     width : 200
114                                 },
115                                 {
116                                     xtype: 'Hidden',
117                                     xns: Roo.form,
118                                     name : 'etype'
119                                 },
120                                 {
121                                     xtype: 'Hidden',
122                                     xns: Roo.form,
123                                     name : 'active',
124                                     value : 1
125                                 },
126                                 {
127                                     xtype: 'Hidden',
128                                     xns: Roo.form,
129                                     name : 'seqid',
130                                     value : 0
131                                 },
132                                 {
133                                     xtype: 'Hidden',
134                                     xns: Roo.form,
135                                     name : 'id'
136                                 }
137                             ]
138                         }
139                     ]
140                 }
141             ],
142             center : {
143                 xtype: 'LayoutRegion',
144                 xns: Roo,
145                 titlebar : false
146             },
147             buttons : [
148                 {
149                     xtype: 'Button',
150                     xns: Roo,
151                     listeners : {
152                         click : function() {
153                             _this.form.reset();
154                             _this.dialog.hide();
155                         }
156                     },
157                     text : "Cancel"
158                 },
159                 {
160                     xtype: 'Button',
161                     xns: Roo,
162                     listeners : {
163                         click : function() {
164                         
165                             var name =     _this.form.findField('display_name').getValue();
166                             name = name.toUpperCase().replace(/[^A-Z]+/g, '');
167                             if (!name.length) {
168                                 Roo.MessageBox.alert("Error","Please fill in a valid name");
169                                 return;
170                             }
171                             _this.form.findField('name').setValue(name);
172                         
173                          
174                             _this.form.doAction('submit');
175                             
176                         }
177                     },
178                     text : "OK"
179                 }
180             ]
181         });
182     }
183 };