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