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