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