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