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                       _this.form.findField('_names').setValue(_this.data.name);
137                       return;
138                   }
139                   
140                   _this.data.findField('_names').setValue(_this.data.materialList);
141                   return;
142               }
143               
144           },
145          actionfailed : function (_self, action)
146           {
147            
148               Pman.standardActionFailed(_self, action);
149           },
150          rendered : function (form)
151           {
152              _this.form = form;
153           }
154         },
155         xns : Roo.form,
156         '|xns' : 'Roo.form',
157         items  : [
158          {
159           xtype : 'TextField',
160           fieldLabel : _this._strings['8324cdec05065c4bd7d8c5effdf43edf'] /* Delete this */,
161           name : '_names',
162           readOnly : true,
163           width : 250,
164           xns : Roo.form,
165           '|xns' : 'Roo.form'
166          },
167          {
168           xtype : 'ComboBox',
169           allowBlank : false,
170           alwaysQuery : true,
171           displayField : 'name',
172           emptyText : _this._strings['bf8691517ce00a09186a05cd65863091'] /* Select Item to Merge With */,
173           fieldLabel : _this._strings['266459bee8ed1ca2e0464899e1ef0994'] /* And replace with */,
174           forceSelection : true,
175           hiddenName : '_merge_id',
176           listWidth : 400,
177           loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
178           minChars : 2,
179           name : '_merge_id_name',
180           pageSize : 20,
181           qtip : _this._strings['bf8691517ce00a09186a05cd65863091'] /* Select Item to Merge With */,
182           queryParam : 'query[search_begins]',
183           selectOnFocus : true,
184           tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{display_name}</b> {name}</div>',
185           triggerAction : 'all',
186           typeAhead : true,
187           valueField : 'id',
188           width : 250,
189           xns : Roo.form,
190           '|xns' : 'Roo.form',
191           store : {
192            xtype : 'Store',
193            remoteSort : true,
194            sortInfo : { direction : 'ASC', field: 'name' },
195            listeners : {
196             beforeload : function (_self, o){
197                  o.params = o.params || {};
198                  
199                  o.params['etype'] = _this.data.etype;
200                  
201                  o.params['!id'] = _this.form.findField('id').getValue();
202                  // set more here
203              }
204            },
205            xns : Roo.data,
206            '|xns' : 'Roo.data',
207            proxy : {
208             xtype : 'HttpProxy',
209             method : 'GET',
210             url : baseURL + '/Roo/Core_enum',
211             xns : Roo.data,
212             '|xns' : 'Roo.data'
213            },
214            reader : {
215             xtype : 'JsonReader',
216             fields : [{"name":"id","type":"int"},{"name":"name","type":"string"}],
217             id : 'id',
218             root : 'data',
219             totalProperty : 'total',
220             xns : Roo.data,
221             '|xns' : 'Roo.data'
222            }
223           }
224          },
225          {
226           xtype : 'Hidden',
227           name : 'etype',
228           xns : Roo.form,
229           '|xns' : 'Roo.form'
230          },
231          {
232           xtype : 'Hidden',
233           name : '_ids',
234           xns : Roo.form,
235           '|xns' : 'Roo.form'
236          },
237          {
238           xtype : 'Hidden',
239           name : 'id',
240           xns : Roo.form,
241           '|xns' : 'Roo.form'
242          }
243         ]
244        }
245       ]
246      }
247     ]
248    });
249  }
250 };