fix 'Optional parameter declared before required parameter is implicitly treated'
[Pman.Cms] / Pman.Dialog.CmsCategory.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Pman.Dialog.CmsCategory = {
6
7     dialog : false,
8     callback:  false,
9
10     show : function(data, cb)
11     {
12         if (!this.dialog) {
13             this.create();
14         }
15
16         this.callback = cb;
17         this.data = data;
18         this.dialog.show(this.data._el);
19         if (this.form) {
20            this.form.reset();
21            this.form.setValues(data);
22            this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
23         }
24
25     },
26
27     create : function()
28     {
29         var _this = this;
30         this.dialog = Roo.factory({
31             xtype: 'LayoutDialog',
32             xns: Roo,
33             background : true,
34             width : 800,
35             height : 500,
36             title : "Edit Category",
37             modal : true,
38             resizable : false,
39             collapsible : false,
40             closable : false,
41             items : [
42                 {
43                     xtype: 'ContentPanel',
44                     xns: Roo,
45                     background : true,
46                     fitToFrame : true,
47                     region : 'center',
48                     items : [
49                         {
50                             xtype: 'Form',
51                             xns: Roo.form,
52                             listeners : {
53                                 actionfailed : function (_self, action)
54                                 {
55                                     _this.dialog.el.unmask();
56                                     Pman.standardActionFailed(_self, action);
57                                 },
58                                 actioncomplete : function (_self, action)
59                                 {
60                                    
61                                    if (action.type =='submit') {
62                                        
63                                        _this.dialog.el.unmask();
64                                        _this.dialog.hide();
65                                        
66                                         if (_this.callback) {
67                                            _this.callback.call(_this, _this.form.getValues());
68                                         }
69                                         _this.form.reset();
70                                         return;
71                                     }
72                                      if (action.type == 'setdata') {
73                                          if (_this.data.id) {
74                                            _this.dialog.el.mask("Loading");
75                                            this.load({ method: 'GET', params: { '_id' : _this.data.id }});
76                                             return;
77                                        }
78                                       _this.grid.getDataSource().load();
79                                        return;
80                                     }
81                                     if (action.type == 'load') {
82                                        _this.grid.getDataSource().load();
83                                         _this.dialog.el.unmask();
84                                         return;
85                                     }
86                                     
87                                   
88                                     
89                                 },
90                                 rendered : function (_self)
91                                 {
92                                     _this.form = _self;
93                                 }
94                             },
95                             method : 'POST',
96                             style : 'margin: 5px',
97                             url : baseURL + '/Roo/Category.php',
98                             items : [
99                                 {
100                                     xtype: 'TextField',
101                                     xns: Roo.form,
102                                     fieldLabel : 'Parent',
103                                     name : 'parent_id_title',
104                                     readOnly : true,
105                                     width : 450
106                                 },
107                                 {
108                                     xtype: 'NumberField',
109                                     xns: Roo.form,
110                                     decimalPrecision : 0,
111                                     fieldLabel : 'Order (1 first)',
112                                     name : 'display_order',
113                                     width : 50
114                                 },
115                                 {
116                                     xtype: 'TextField',
117                                     xns: Roo.form,
118                                     name : 'title',
119                                     fieldLabel : 'Title',
120                                     width : 450
121                                 },
122                                 {
123                                     xtype: 'ComboBox',
124                                     xns: Roo.form,
125                                     allowBlank : true,
126                                     displayField : 'name',
127                                     editable : 'false',
128                                     emptyText : "Select Type",
129                                     fieldLabel : 'Type',
130                                     forceSelection : true,
131                                     hiddenName : 'category_type_id',
132                                     listWidth : 200,
133                                     loadingText : "Searching...",
134                                     minChars : 2,
135                                     name : 'category_type_id_name',
136                                     pageSize : 20,
137                                     qtip : "Select cms_category_type",
138                                     selectOnFocus : true,
139                                     tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> </div>',
140                                     triggerAction : 'all',
141                                     typeAhead : true,
142                                     valueField : 'id',
143                                     width : 200,
144                                     store : {
145                                         xtype: 'Store',
146                                         xns: Roo.data,
147                                         remoteSort : true,
148                                         sortInfo : { direction : 'ASC', field: 'id' },
149                                         listeners : {
150                                             beforeload : function (_self, o){
151                                                 o.params = o.params || {};
152                                                 // set more here
153                                             }
154                                         },
155                                         proxy : {
156                                             xtype: 'HttpProxy',
157                                             xns: Roo.data,
158                                             method : 'GET',
159                                             url : baseURL + '/Roo/cms_category_type.php'
160                                         },
161                                         reader : {
162                                             xtype: 'JsonReader',
163                                             xns: Roo.data,
164                                             id : 'id',
165                                             root : 'data',
166                                             totalProperty : 'total',
167                                             fields : [{"name":"id","type":"int"},{"name":"name","type":"string"}]
168                                         }
169                                     }
170                                 },
171                                 {
172                                     xtype: 'Checkbox',
173                                     xns: Roo.form,
174                                     fieldLabel : 'Visible',
175                                     name : 'visible'
176                                 },
177                                 {
178                                     xtype: 'Hidden',
179                                     xns: Roo.form,
180                                     name : 'parent_id'
181                                 },
182                                 {
183                                     xtype: 'Hidden',
184                                     xns: Roo.form,
185                                     name : 'id'
186                                 }
187                             ]
188                         }
189                     ]
190                 },
191                 {
192                     xtype: 'GridPanel',
193                     xns: Roo,
194                     title : "Images",
195                     fitToframe : true,
196                     fitContainer : true,
197                     tableName : 'Images',
198                     background : false,
199                     listeners : {
200                         activate : function() {
201                             _this.panel = this;
202                             if (_this.grid) {
203                                 //_this.grid.footer.onClick('first');
204                             }
205                         }
206                     },
207                     region : 'east',
208                     grid : {
209                         xtype: 'Grid',
210                         xns: Roo.grid,
211                         autoExpandColumn : 'filename',
212                         loadMask : true,
213                         listeners : {
214                             render : function() { 
215                                 _this.grid = this; 
216                                 //_this.dialog = Pman.Dialog.FILL_IN
217                                 if (_this.panel.active) {
218                                    //this.footer.onClick('first');
219                                 }
220                             }
221                         },
222                         dataSource : {
223                             xtype: 'Store',
224                             xns: Roo.data,
225                             reader : Pman.Readers.Images,
226                             listeners : {
227                                 beforeload : function (_self, o)
228                                 {
229                                   if (!_this.data.id) {
230                                        return false;
231                                     }               
232                                     o.params = o.params || {};
233                                     o.params.onid = _this.data.id;
234                                     o.params.ontable = 'Category';
235                                 }
236                             },
237                             proxy : {
238                                 xtype: 'HttpProxy',
239                                 xns: Roo.data,
240                                 method : 'GET',
241                                 url : baseURL + '/Roo/Images.php'
242                             }
243                         },
244                         toolbar : {
245                             xtype: 'Toolbar',
246                             xns: Roo,
247                             items : [
248                                 {
249                                     xtype: 'Button',
250                                     xns: Roo,
251                                     text : "Add",
252                                     cls : 'x-btn-text-icon',
253                                     icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
254                                     listeners : {
255                                         click : function()
256                                                 {
257                                                     Pman.Dialog.Image.show( { id : 0, onid: _this.data.id, ontable: 'Category' }, function(data) {
258                                                         _this.grid.getDataSource().load();
259                                                          Pman.Dialog.CmsImage.show(data, function() {
260                                                            _this.grid.getDataSource().load();
261                                                        }); 
262                                             
263                                                         
264                                                     }); 
265                                         
266                                                 }
267                                     }
268                                 },
269                                 {
270                                     xtype: 'Button',
271                                     xns: Roo,
272                                     text : "Edit",
273                                     cls : 'x-btn-text-icon',
274                                     icon : Roo.rootURL + 'images/default/tree/leaf.gif',
275                                     listeners : {
276                                         click : function()
277                                                 {
278                                                     var s = _this.grid.getSelectionModel().getSelections();
279                                                     if (!s.length || (s.length > 1))  {
280                                                         Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
281                                                         return;
282                                                     }
283                                                     var data = _this.grid.getDataSource().getById(s[0].data.id).data;
284                                                     Pman.Dialog.CmsImage.show(data, function() {
285                                                         _this.grid.getDataSource().load();
286                                                        }); 
287                                                     
288                                                 }
289                                     }
290                                 },
291                                 {
292                                     xtype: 'Button',
293                                     xns: Roo,
294                                     text : "Delete",
295                                     cls : 'x-btn-text-icon',
296                                     icon : rootURL + '/Pman/templates/images/trash.gif',
297                                     listeners : {
298                                         click : function()
299                                                 {
300                                                 Pman.genericDelete(_this, _this.panel.tableName); 
301                                                 }
302                                     }
303                                 }
304                             ]
305                         },
306                         colModel : [
307                             {
308                                 xtype: 'ColumnModel',
309                                 xns: Roo.grid,
310                                 dataIndex : 'id',
311                                 header : '',
312                                 width : 110,
313                                 renderer : function(v,x,r) { return String.format('<img src="{0}/Images/Thumb/100/{1}/{2}">', baseURL, v, r.data.filename); }
314                             },
315                             {
316                                 xtype: 'ColumnModel',
317                                 xns: Roo.grid,
318                                 header : 'Filename',
319                                 width : 100,
320                                 dataIndex : 'filename',
321                                 renderer : function(v,x,r) { return String.format('{0}<br/><i qtip="{1}">{1}</i>', v, r.data.linkurl); }
322                             }
323                         ]
324                     }
325                 }
326             ],
327             center : {
328                 xtype: 'LayoutRegion',
329                 xns: Roo,
330                 titlebar : false
331             },
332             east : {
333                 xtype: 'LayoutRegion',
334                 xns: Roo,
335                 titlebar : false,
336                 split : 'true',
337                 fitToFrame : 'true',
338                 width : 200
339             },
340             buttons : [
341                 {
342                     xtype: 'Button',
343                     xns: Roo,
344                     text : "Cancel",
345                     listeners : {
346                         click : function() {
347                         
348                                                             _this.form.reset();
349                         
350                                                             _this.dialog.hide();
351                         
352                                                         }
353                     }
354                 },
355                 {
356                     xtype: 'Button',
357                     xns: Roo,
358                     text : "OK",
359                     listeners : {
360                         click : function() {
361                         
362                                                             _this.dialog.el.mask("Saving");
363                         
364                                                             _this.form.doAction("submit");
365                         
366                                                         }
367                     }
368                 }
369             ]
370         });
371     }
372 };