Pman.Dialog.CoreEnumMerge.bjs
[Pman.Core] / Pman.Dialog.CoreEnumMerge.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.CoreEnumMerge = {
8
9  _strings : {
10   'bf8691517ce00a09186a05cd65863091' :"Select Item to Merge With",
11   '298a183cfe4fddedd4bd17abe8aeb685' :"Merge Pulldown Option",
12   '03e956f1dca2b4d525df03cb1899cb6f' :"Merge with",
13   '1243daf593fa297e07ab03bf06d925af' :"Searching...",
14   '68be4837f6c739877233e527a996dd00' :"Merge",
15   'ea4788705e6873b424c65e91c2846b19' :"Cancel"
16  },
17
18  dialog : false,
19  callback:  false,
20
21  show : function(data, cb)
22  {
23   if (!this.dialog) {
24    this.create();
25   }
26
27   this.callback = cb;
28   this.data = data;
29   this.dialog.show(this.data._el);
30   if (this.form) {
31    this.form.reset();
32    this.form.setValues(data);
33    this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
34   }
35
36  },
37
38  create : function()
39  {
40    var _this = this;
41    this.dialog = Roo.factory({
42     closable : false,
43     collapsible : false,
44     height : 120,
45     modal : true,
46     resizable : false,
47     title : _this._strings['298a183cfe4fddedd4bd17abe8aeb685'] /* Merge Pulldown Option */,
48     width : 400,
49     xns : Roo,
50     '|xns' : 'Roo',
51     xtype : 'LayoutDialog',
52     listeners : {
53      show : function (_self)
54       {
55           if (_this.isBuilder) {
56               _this.data = { id : 2, comptype : 'SUPPLIER' }
57           }
58       }
59     },
60     center : {
61      xns : Roo,
62      '|xns' : 'Roo',
63      xtype : 'LayoutRegion'
64     },
65     buttons : [
66      {
67       text : _this._strings['ea4788705e6873b424c65e91c2846b19'] /* Cancel */,
68       xns : Roo,
69       '|xns' : 'Roo',
70       xtype : 'Button',
71       listeners : {
72        click : function (_self, e)
73         {
74             _this.dialog.hide();
75         }
76       }
77      },
78      {
79       text : _this._strings['68be4837f6c739877233e527a996dd00'] /* Merge */,
80       xns : Roo,
81       '|xns' : 'Roo',
82       xtype : 'Button',
83       listeners : {
84        click : function (_self, e)
85         {
86             _this.dialog.el.mask("Merging");
87             _this.form.doAction("submit");
88         
89         }
90       }
91      }
92     ],
93     items  : [
94      {
95       region : 'center',
96       xns : Roo,
97       '|xns' : 'Roo',
98       xtype : 'ContentPanel',
99       items  : [
100        {
101         method : 'POST',
102         style : 'margin: 10px;',
103         url : baseURL + '/Roo/Core_enum.php',
104         xns : Roo.form,
105         '|xns' : 'Roo.form',
106         xtype : 'Form',
107         listeners : {
108          actioncomplete : function (_self, action)
109           {
110           
111              if (action.type =='submit') {
112                  
113                  _this.dialog.el.unmask();
114                  _this.dialog.hide();
115                  
116                   if (_this.callback) {
117                      _this.callback.call(_this, _this.form.getValues());
118                   }
119                   _this.form.reset();
120                   return;
121               }
122               if (action.type == 'setdata') {
123                   _this.data.table = _this.data.table || 'Companies';
124                   _this.form.findField('table').setValue(_this.data.table);
125                    var title = _this.data.title  || _this.data.comptype;
126                   _this.dialog.setTitle("Delete selected " + title + " and merge data with");
127                   _this.form.findField('merge_id').store.proxy.conn.url = baseURL + '/Roo/' + _this.data.table + '.php';
128                   _this.form.findField('merge_id').emptyText = "Select " + title;
129                   _this.form.findField('merge_id').reset();
130                  return;
131               }
132               
133           },
134          actionfailed : function (_self, action)
135           {
136               _this.dialog.el.unmask();
137               Pman.standardActionFailed(_self, action);
138           },
139          rendered : function (form)
140           {
141              _this.form = form;
142           }
143         },
144         items  : [
145          {
146           allowBlank : false,
147           alwaysQuery : true,
148           displayField : 'name',
149           emptyText : _this._strings['bf8691517ce00a09186a05cd65863091'] /* Select Item to Merge With */,
150           fieldLabel : _this._strings['03e956f1dca2b4d525df03cb1899cb6f'] /* Merge with */,
151           forceSelection : true,
152           hiddenName : '_merge_with_id',
153           listWidth : 400,
154           loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
155           minChars : 2,
156           name : '_merge_with_id_name',
157           pageSize : 20,
158           qtip : _this._strings['bf8691517ce00a09186a05cd65863091'] /* Select Item to Merge With */,
159           queryParam : 'query[name]',
160           selectOnFocus : true,
161           tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{name}</b> </div>',
162           triggerAction : 'all',
163           typeAhead : true,
164           valueField : 'id',
165           width : 250,
166           xns : Roo.form,
167           '|xns' : 'Roo.form',
168           xtype : 'ComboBox',
169           store : {
170            remoteSort : true,
171            sortInfo : { direction : 'ASC', field: 'name' },
172            xns : Roo.data,
173            '|xns' : 'Roo.data',
174            xtype : 'Store',
175            listeners : {
176             beforeload : function (_self, o){
177                  o.params = o.params || {};
178                  
179                  if (_this.data.params) {
180                      Roo.apply(o.params, _this.data.params);
181                  }
182                  
183                  o.params.comptype = _this.data.comptype;
184                  o.params['!id'] = _this.data.id;
185                  o.params['table'] = _this.data.table || 'Companies';
186                  if (_this.data.table && _this.data.table == 'Person') {
187                      o.params.company_id = _this.data.company_id;
188                  }
189                  
190                  // set more here
191              }
192            },
193            proxy : {
194             method : 'GET',
195             url : baseURL + '/Roo/Companies.php',
196             xns : Roo.data,
197             '|xns' : 'Roo.data',
198             xtype : 'HttpProxy'
199            },
200            reader : {
201             fields : [{"name":"id","type":"int"},{"name":"name","type":"string"}],
202             id : 'id',
203             root : 'data',
204             totalProperty : 'total',
205             xns : Roo.data,
206             '|xns' : 'Roo.data',
207             xtype : 'JsonReader'
208            }
209           }
210          },
211          {
212           name : 'table',
213           xns : Roo.form,
214           '|xns' : 'Roo.form',
215           xtype : 'Hidden'
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 };