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