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