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').getRawValue() + "'", 
88                     function(res) {
89                         if(res != 'yes') {
90                             return;
91                         }
92                         
93                         _this.form.doAction('submit');
94                         return;
95                     }
96                 );
97                 
98                 return;
99             }
100             _this.form.doAction('submit');
101             
102         }
103       }
104      }
105     ],
106     items  : [
107      {
108       background : true,
109       fitToFrame : true,
110       region : 'center',
111       xns : Roo,
112       '|xns' : 'Roo',
113       xtype : 'ContentPanel',
114       items  : [
115        {
116         method : 'POST',
117         style : 'margin: 5px',
118         url : baseURL + '/Roo/core_enum.php',
119         xns : Roo.form,
120         '|xns' : 'Roo.form',
121         xtype : 'Form',
122         listeners : {
123          actioncomplete : function (_self, action)
124           {
125             if (action.type == 'setdata') {
126           
127                  return;
128               }
129               if (action.type == 'load') {
130                   _this.dialog.el.unmask();
131                   return;
132               }
133               if (action.type == 'submit' ) {
134                   _this.dialog.el.unmask();
135                   _this.dialog.hide();
136           
137                   if (_this.callback) {
138                      _this.callback.call(_this, action.result.data);
139                   }
140                   _this.form.reset();
141               }
142           },
143          rendered : function (form)
144           {
145              _this.form = form;
146           }
147         },
148         items  : [
149          {
150           alwaysQuery : true,
151           displayField : 'display_name',
152           editable : true,
153           fieldLabel : _this._strings['03e956f1dca2b4d525df03cb1899cb6f'] /* Merge with */,
154           forceSelection : true,
155           hiddenName : '_merge_id',
156           listWidth : 250,
157           minChars : 2,
158           name : 'merge_display_name',
159           pageSize : 50,
160           queryParam : 'query[search]',
161           selectOnFocus : true,
162           tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{display_name}</b> </div>',
163           triggerAction : 'all',
164           valueField : 'id',
165           width : 250,
166           xns : Roo.form,
167           '|xns' : 'Roo.form',
168           xtype : 'ComboBox',
169           listeners : {
170            render : function (_self)
171             {
172                 _this.merge = this;
173             }
174           },
175           store : {
176            remoteSort : true,
177            sortInfo : { direction : 'ASC', field: 'display_name' },
178            xns : Roo.data,
179            '|xns' : 'Roo.data',
180            xtype : 'Store',
181            listeners : {
182             beforeload : function (_self, o){
183                  o.params = o.params || {};
184                  
185                  o.params.active = 1;
186                  o.params.etype = _this.data.etype;
187                  o.params['!id'] = _this.data.id;
188              }
189            },
190            proxy : {
191             method : 'GET',
192             url : baseURL + '/Roo/Core_enum.php',
193             xns : Roo.data,
194             '|xns' : 'Roo.data',
195             xtype : 'HttpProxy'
196            },
197            reader : {
198             fields : [
199                 {
200                     "name":"id",
201                     "type":"int"
202                 },
203                 {
204                     "name":"display_name",
205                     "type":"string"
206                 }
207             ],
208             id : 'id',
209             root : 'data',
210             totalProperty : 'total',
211             xns : Roo.data,
212             '|xns' : 'Roo.data',
213             xtype : 'JsonReader'
214            }
215           }
216          },
217          {
218           name : 'id',
219           xns : Roo.form,
220           '|xns' : 'Roo.form',
221           xtype : 'Hidden'
222          }
223         ]
224        }
225       ]
226      }
227     ]
228    });
229  }
230 };