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 : 'id'
112                                 }
113                             ]
114                         }
115                     ]
116                 }
117             ],
118             center : {
119                 xtype: 'LayoutRegion',
120                 xns: Roo,
121                 titlebar : false
122             },
123             buttons : [
124                 {
125                     xtype: 'Button',
126                     xns: Roo,
127                     listeners : {
128                         click : function() {
129                             _this.form.reset();
130                             _this.dialog.hide();
131                         }
132                     },
133                     text : "Cancel"
134                 },
135                 {
136                     xtype: 'Button',
137                     xns: Roo,
138                     listeners : {
139                         click : function() {
140                         
141                             var name =     _this.form.findField('display_name').getValue();
142                             name = name.toUpperCase().replace(/[^A-Z]+/g, '');
143                             if (!name.length) {
144                                 Roo.MessageBox.alert("Error","Please fill in a valid name");
145                                 return;
146                             }
147                             _this.form.findField('name').setValue(name);
148                         
149                          
150                             _this.form.doAction('submit');
151                             
152                         }
153                     },
154                     text : "OK"
155                 }
156             ]
157         });
158     }
159 };