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