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