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 Roo.namespace('Pman.Dialog');
6
7 Pman.Dialog.CoreEnum = {
8
9  _strings : {
10   '518ad9ed87d3ca17e223a91604b464d5' :"Add / Edit Core Enum",
11   'cfcd208495d565ef66e7dff9f98764da' :"0",
12   'ea4788705e6873b424c65e91c2846b19' :"Cancel",
13   'e0aa021e21dddbd6d8cecec71e9cf564' :"OK"
14  },
15
16  dialog : false,
17  callback:  false,
18
19  show : function(data, cb)
20  {
21   if (!this.dialog) {
22    this.create();
23   }
24
25   this.callback = cb;
26   this.data = data;
27   this.dialog.show(this.data._el);
28   if (this.form) {
29    this.form.reset();
30    this.form.setValues(data);
31    this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
32   }
33
34  },
35
36  create : function()
37  {
38    var _this = this;
39    this.dialog = Roo.factory({
40     center : {
41      '|xns' : 'Roo',
42      titlebar : false,
43      xns : Roo,
44      xtype : 'LayoutRegion'
45     },
46     '|xns' : 'Roo',
47     background : true,
48     closable : false,
49     collapsible : false,
50     height : 150,
51     modal : true,
52     resizable : false,
53     title : _this._strings['518ad9ed87d3ca17e223a91604b464d5'],
54     width : 400,
55     xns : Roo,
56     xtype : 'LayoutDialog',
57     buttons : [
58       {
59        '|xns' : 'Roo',
60        text : _this._strings['ea4788705e6873b424c65e91c2846b19'],
61        xns : Roo,
62        xtype : 'Button',
63        listeners : {
64         click : function() {
65              _this.form.reset();
66              _this.dialog.hide();
67          }
68        }
69       },
70 {
71        '|xns' : 'Roo',
72        text : _this._strings['e0aa021e21dddbd6d8cecec71e9cf564'],
73        xns : Roo,
74        xtype : 'Button',
75        listeners : {
76         click : function() {
77          
78              var name =     _this.form.findField('name').getValue();
79              name = name.toUpperCase().replace(/[^A-Z]+/g, '');
80              if (!name.length) {
81                  Roo.MessageBox.alert("Error","Please fill in a valid name");
82                  return;
83              }
84              _this.form.findField('name').setValue(name);
85           
86              _this.form.doAction('submit');
87              
88          }
89        }
90       }
91     ],
92     listeners : {
93      show : function (_self)
94       {
95           
96       }
97     },
98     items : [
99      {
100       '|xns' : 'Roo',
101       background : true,
102       fitToFrame : true,
103       region : 'center',
104       xns : Roo,
105       xtype : 'ContentPanel',
106       items : [
107        {
108         '|xns' : 'Roo.form',
109         method : 'POST',
110         style : 'margin: 5px',
111         url : baseURL + '/Roo/core_enum.php',
112         xns : Roo.form,
113         xtype : 'Form',
114         listeners : {
115          actioncomplete : function (_self, action)
116           {
117             if (action.type == 'setdata') {
118           
119                   if((typeof(_this.data.etype) == 'undefined') || !_this.data.etype.length){
120                       Roo.MessageBox.alert('Error', 'Missing etype');
121                       _this.dialog.hide();
122                       return;
123                   }
124             
125                   if(_this.data.id){
126                       _this.dialog.el.mask("Loading");
127                       this.load({ method: 'GET', params: { '_id' : _this.data.id }}); 
128                   }
129                  
130                  return;
131               }
132               if (action.type == 'load') {
133                   _this.dialog.el.unmask();
134                   return;
135               }
136               if (action.type == 'submit' ) {
137                   _this.dialog.el.unmask();
138                   _this.dialog.hide();
139           
140                   if (_this.callback) {
141                      _this.callback.call(_this, action.result.data);
142                   }
143                   _this.form.reset();
144               }
145           },
146          rendered : function (form)
147           {
148              _this.form = form;
149           }
150         },
151         items : [
152          {
153           '|xns' : 'Roo.form',
154           actionMode : 'fieldEl',
155           allowBlank : false,
156           fieldLabel : 'Name',
157           hidden : true,
158           name : 'name',
159           width : 200,
160           xns : Roo.form,
161           xtype : 'TextField'
162          },
163          {
164           '|xns' : 'Roo.form',
165           allowBlank : false,
166           fieldLabel : 'Display Name',
167           name : 'display_name',
168           width : 200,
169           xns : Roo.form,
170           xtype : 'TextField',
171           listeners : {
172            keyup : function (_self, e)
173             {
174                 _this.form.findField('name').setValue(this.getValue().replace(/[^a-z0-9]/ig, '').toUpperCase());
175                 
176             }
177           }
178          },
179          {
180           '|xns' : 'Roo.form',
181           fieldLabel : 'Active',
182           inputValue : 1,
183           name : 'active',
184           value : 0,
185           valueOff : 0,
186           xns : Roo.form,
187           xtype : 'Checkbox'
188          },
189          {
190           '|xns' : 'Roo.form',
191           name : 'etype',
192           xns : Roo.form,
193           xtype : 'Hidden'
194          },
195          {
196           '|xns' : 'Roo.form',
197           name : 'seqid',
198           value : 0,
199           xns : Roo.form,
200           xtype : 'Hidden'
201          },
202          {
203           '|xns' : 'Roo.form',
204           name : 'id',
205           xns : Roo.form,
206           xtype : 'Hidden'
207          }
208         ]
209
210        }
211       ]
212
213      }
214     ]
215
216    });
217  }
218 };