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