Pman.Dialog.AdminEnumMerge.bjs
[Pman.Admin] / Pman.Dialog.AdminEnumMerge.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.AdminEnumMerge = {
8
9  _strings : {
10   '0b3e4317865feb6f0224397600b7cafc' :"Merge 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['0b3e4317865feb6f0224397600b7cafc'],
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     items : [
94      {
95       '|xns' : 'Roo',
96       background : true,
97       fitToFrame : true,
98       region : 'center',
99       xns : Roo,
100       xtype : 'ContentPanel',
101       items : [
102        {
103         '|xns' : 'Roo.form',
104         method : 'POST',
105         style : 'margin: 5px',
106         url : baseURL + '/Roo/core_enum.php',
107         xns : Roo.form,
108         xtype : 'Form',
109         listeners : {
110          actioncomplete : function (_self, action)
111           {
112             if (action.type == 'setdata') {
113           
114                   if((typeof(_this.data.etype) == 'undefined') || !_this.data.etype.length){
115                       Roo.MessageBox.alert('Error', 'Missing etype');
116                       _this.dialog.hide();
117                       return;
118                   }
119                   
120                   if(typeof(_this.data.title) != 'undefined' && _this.data.title.length){
121                       _this.dialog.setTitle(_this.data.title);
122                   }
123             
124                   if(_this.data.id){
125                       _this.dialog.el.mask("Loading");
126                       this.load({ method: 'GET', params: { '_id' : _this.data.id }}); 
127                   }
128                  
129                  return;
130               }
131               if (action.type == 'load') {
132                   _this.dialog.el.unmask();
133                   return;
134               }
135               if (action.type == 'submit' ) {
136                   _this.dialog.el.unmask();
137                   _this.dialog.hide();
138           
139                   if (_this.callback) {
140                      _this.callback.call(_this, action.result.data);
141                   }
142                   _this.form.reset();
143               }
144           },
145          rendered : function (form)
146           {
147              _this.form = form;
148           }
149         },
150         items : [
151          {
152           '|xns' : 'Roo.form',
153           actionMode : 'fieldEl',
154           allowBlank : false,
155           fieldLabel : 'Name',
156           hidden : true,
157           name : 'name',
158           width : 200,
159           xns : Roo.form,
160           xtype : 'TextField'
161          },
162          {
163           '|xns' : 'Roo.form',
164           allowBlank : false,
165           fieldLabel : 'Display Name',
166           name : 'display_name',
167           width : 200,
168           xns : Roo.form,
169           xtype : 'TextField',
170           listeners : {
171            keyup : function (_self, e)
172             {
173                 _this.form.findField('name').setValue(this.getValue().replace(/[^a-z0-9]/ig, '').toUpperCase());
174                 
175             }
176           }
177          },
178          {
179           '|xns' : 'Roo.form',
180           actionMode : 'fieldEl',
181           checked : true,
182           fieldLabel : 'Active',
183           hidden : true,
184           inputValue : 1,
185           name : 'active',
186           value : 1,
187           valueOff : 0,
188           xns : Roo.form,
189           xtype : 'Checkbox'
190          },
191          {
192           '|xns' : 'Roo.form',
193           name : 'etype',
194           xns : Roo.form,
195           xtype : 'Hidden'
196          },
197          {
198           '|xns' : 'Roo.form',
199           name : 'seqid',
200           value : 0,
201           xns : Roo.form,
202           xtype : 'Hidden'
203          },
204          {
205           '|xns' : 'Roo.form',
206           name : 'id',
207           xns : Roo.form,
208           xtype : 'Hidden'
209          }
210         ]
211
212        }
213       ]
214
215      }
216     ]
217
218    });
219  }
220 };