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   '03e956f1dca2b4d525df03cb1899cb6f' :"Merge with",
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     background : true,
41     closable : false,
42     collapsible : false,
43     height : 150,
44     modal : true,
45     resizable : false,
46     title : _this._strings['0b3e4317865feb6f0224397600b7cafc'] /* Merge Core Enum */,
47     width : 400,
48     xns : Roo,
49     '|xns' : 'Roo',
50     xtype : 'LayoutDialog',
51     listeners : {
52      show : function (_self)
53       {
54           _this.merge.focus();
55       }
56     },
57     center : {
58      titlebar : false,
59      xns : Roo,
60      '|xns' : 'Roo',
61      xtype : 'LayoutRegion'
62     },
63     buttons : [
64      {
65       text : _this._strings['ea4788705e6873b424c65e91c2846b19'] /* Cancel */,
66       xns : Roo,
67       '|xns' : 'Roo',
68       xtype : 'Button',
69       listeners : {
70        click : function() {
71             _this.form.reset();
72             _this.dialog.hide();
73         }
74       }
75      },
76      {
77       text : _this._strings['e0aa021e21dddbd6d8cecec71e9cf564'] /* OK */,
78       xns : Roo,
79       '|xns' : 'Roo',
80       xtype : 'Button',
81       listeners : {
82        click : function() 
83         {
84             if(typeof(_this.data._confirm) != 'undefined' && _this.data._confirm * 1 == 1){
85                 Roo.MessageBox.confirm(
86                     "Confirm", 
87                     "Are you sure '" + _this.data.display_name + "' Merge with " + _this.form.findField('merge_id'), 
88                     function(res) {
89                         if(res != 'yes') {
90                             return;
91                         }
92                         new Pman.Request({
93                             method : 'POST',
94                             url : baseURL + '/Roo/Core_enum',
95                             params : {
96                                 _delete  : ids.join(',')
97                             },
98                             success : function() {
99                                 _this.grid.footer.onClick('refresh');
100                             }
101                         });
102                     }
103                 );
104             }
105             _this.form.doAction('submit');
106             
107         }
108       }
109      }
110     ],
111     items  : [
112      {
113       background : true,
114       fitToFrame : true,
115       region : 'center',
116       xns : Roo,
117       '|xns' : 'Roo',
118       xtype : 'ContentPanel',
119       items  : [
120        {
121         method : 'POST',
122         style : 'margin: 5px',
123         url : baseURL + '/Roo/core_enum.php',
124         xns : Roo.form,
125         '|xns' : 'Roo.form',
126         xtype : 'Form',
127         listeners : {
128          actioncomplete : function (_self, action)
129           {
130             if (action.type == 'setdata') {
131           
132                  return;
133               }
134               if (action.type == 'load') {
135                   _this.dialog.el.unmask();
136                   return;
137               }
138               if (action.type == 'submit' ) {
139                   _this.dialog.el.unmask();
140                   _this.dialog.hide();
141           
142                   if (_this.callback) {
143                      _this.callback.call(_this, action.result.data);
144                   }
145                   _this.form.reset();
146               }
147           },
148          rendered : function (form)
149           {
150              _this.form = form;
151           }
152         },
153         items  : [
154          {
155           alwaysQuery : true,
156           displayField : 'display_name',
157           editable : true,
158           fieldLabel : _this._strings['03e956f1dca2b4d525df03cb1899cb6f'] /* Merge with */,
159           forceSelection : true,
160           hiddenName : '_merge_id',
161           listWidth : 250,
162           minChars : 2,
163           name : 'merge_display_name',
164           pageSize : 50,
165           queryParam : 'query[search]',
166           selectOnFocus : true,
167           tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{display_name}</b> </div>',
168           triggerAction : 'all',
169           valueField : 'id',
170           width : 250,
171           xns : Roo.form,
172           '|xns' : 'Roo.form',
173           xtype : 'ComboBox',
174           listeners : {
175            render : function (_self)
176             {
177                 _this.merge = this;
178             }
179           },
180           store : {
181            remoteSort : true,
182            sortInfo : { direction : 'ASC', field: 'display_name' },
183            xns : Roo.data,
184            '|xns' : 'Roo.data',
185            xtype : 'Store',
186            listeners : {
187             beforeload : function (_self, o){
188                  o.params = o.params || {};
189                  
190                  o.params.active = 1;
191                  o.params.etype = _this.data.etype;
192                  o.params['!id'] = _this.data.id;
193              }
194            },
195            proxy : {
196             method : 'GET',
197             url : baseURL + '/Roo/Core_enum.php',
198             xns : Roo.data,
199             '|xns' : 'Roo.data',
200             xtype : 'HttpProxy'
201            },
202            reader : {
203             fields : [
204                 {
205                     "name":"id",
206                     "type":"int"
207                 },
208                 {
209                     "name":"display_name",
210                     "type":"string"
211                 }
212             ],
213             id : 'id',
214             root : 'data',
215             totalProperty : 'total',
216             xns : Roo.data,
217             '|xns' : 'Roo.data',
218             xtype : 'JsonReader'
219            }
220           }
221          },
222          {
223           name : 'id',
224           xns : Roo.form,
225           '|xns' : 'Roo.form',
226           xtype : 'Hidden'
227          }
228         ]
229        }
230       ]
231      }
232     ]
233    });
234  }
235 };