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