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