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