fix 'Optional parameter declared before required parameter is implicitly treated...
[Pman.Cms] / Pman.Dialog.CmsPage.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.CmsPage = {
8
9     dialog : false,
10     callback:  false,
11
12     show : function(data, cb)
13     {
14         if (!this.dialog) {
15             this.create();
16         }
17
18         this.callback = cb;
19         this.data = data;
20         this.dialog.show(this.data._el);
21         if (this.form) {
22            this.form.reset();
23            this.form.setValues(data);
24            this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
25         }
26
27     },
28
29     create : function()
30     {
31         var _this = this;
32         this.dialog = Roo.factory({
33             center : {
34                 '|xns' : 'Roo',
35                 xtype : 'LayoutRegion',
36                 xns : Roo,
37                 titlebar : false
38             },
39             east : {
40                 '|xns' : 'Roo',
41                 fitToFrame : true,
42                 xtype : 'LayoutRegion',
43                 width : 200,
44                 xns : Roo,
45                 titlebar : false
46             },
47             '|xns' : 'Roo',
48             modal : true,
49             collapsible : false,
50             background : true,
51             title : "Edit Page",
52             xtype : 'LayoutDialog',
53             width : 850,
54             xns : Roo,
55             closable : false,
56             resizable : false,
57             height : 600,
58             buttons : [
59                  {
60                         '|xns' : 'Roo',
61                         text : "Cancel",
62                         xtype : 'Button',
63                         xns : Roo,
64                         listeners : {
65                                 click : function() {
66                                    
67                                                                        _this.form.reset();
68                                    
69                                                                        _this.dialog.hide();
70                                    
71                                                                    }
72                         }
73                     },
74 {
75                         '|xns' : 'Roo',
76                         text : "OK",
77                         xtype : 'Button',
78                         xns : Roo,
79                         listeners : {
80                                 click : function() {
81                                    
82                                                                        _this.dialog.el.mask("Saving");
83                                     _this.form.findField('contents').syncValue();
84                                                                        _this.form.doAction("submit");
85                                    
86                                                                    }
87                         }
88                     }
89             ],
90             items : [
91                 {
92                     '|xns' : 'Roo',
93                     autoScroll : true,
94                     region : 'center',
95                     fitToFrame : true,
96                     xtype : 'ContentPanel',
97                     xns : Roo,
98                     items : [
99                         {
100                             '|xns' : 'Roo.form',
101                             url : baseURL + '/Roo/Page.php',
102                             xtype : 'Form',
103                             method : 'POST',
104                             style : 'margin: 5px',
105                             xns : Roo.form,
106                             listeners : {
107                                 actionfailed : function (_self, action)
108                                    {
109                                        _this.dialog.el.unmask();
110                                        Pman.standardActionFailed(_self, action);
111                                    },
112                                 actioncomplete : function (_self, action)
113                                    {
114                                    
115                                       if (action.type =='submit') {
116                                           
117                                           _this.dialog.el.unmask();
118                                           _this.dialog.hide();
119                                           
120                                            if (_this.callback) {
121                                               _this.callback.call(_this, _this.form.getValues());
122                                            }
123                                            _this.form.reset();
124                                            return;
125                                        }
126                                        if (action.type == 'setdata') {    
127                                              _this.loaded = false;
128                                              
129                                      //      _this.dialog.getLayout().showPanel(0);
130                                        //   _this.form.addForm(_this.form1);
131                                              if ( _this.data.id) {
132                                                    _this.dialog.el.mask("Loading");
133                                                    this.load({ method: 'GET', params: { '_id' : _this.data.id }});
134                                               } else {
135                                                    _this.loaded = true;
136                                                    //disable image upload!
137                                                  _this.form.findField('publish_status').setValue(-1);
138                                              }
139                                    
140                                           return;
141                                          
142                                        }
143                                        
144                                        if (action.type == 'load') {
145                                            _this.dialog.el.unmask();
146                                           _this.grid.getDataSource().load();
147                                            return;
148                                        }
149                                    },
150                                 rendered : function (_self)
151                                    {
152                                        _this.form = _self;
153                                    }
154                             },
155                             items : [
156                                 {
157                                     '|xns' : 'Roo.form',
158                                     fieldLabel : 'Page link',
159                                     xtype : 'TextField',
160                                     width : 200,
161                                     xns : Roo.form,
162                                     name : 'page_link'
163                                 },
164                                 {
165                                     store : {
166                                         proxy : {
167                                             '|xns' : 'Roo.data',
168                                             url : baseURL + '/Roo/Page.php',
169                                             xtype : 'HttpProxy',
170                                             method : 'GET',
171                                             xns : Roo.data
172                                         },
173                                         reader : {
174                                             '|xns' : 'Roo.data',
175                                             id : 'id',
176                                             root : 'data',
177                                             xtype : 'JsonReader',
178                                             fields : [
179                                              { name: 'id', type: 'int' },
180                                              'title',
181                                              'page_link' 
182                                             ],
183                                             xns : Roo.data,
184                                             totalProperty : 'total'
185                                         },
186                                         '|xns' : 'Roo.data',
187                                         xtype : 'Store',
188                                         remoteSort : true,
189                                         sortInfo : { field: 'page_link', direction: 'ASC' },
190                                         xns : Roo.data,
191                                         items : [
192
193                                         ]
194
195                                     },
196                                     '|xns' : 'Roo.form',
197                                     listWidth : 400,
198                                     triggerAction : 'all',
199                                     fieldLabel : 'Parent page',
200                                     forceSelection : true,
201                                     selectOnFocus : true,
202                                     pageSize : 20,
203                                     displayField : 'page_link',
204                                     emptyText : "Select Parent",
205                                     hiddenName : 'parent_id',
206                                     minChars : 2,
207                                     valueField : 'id',
208                                     xtype : 'ComboBox',
209                                     allowBlank : true,
210                                     typeAhead : true,
211                                     editable : false,
212                                     width : 400,
213                                     xns : Roo.form,
214                                     name : 'parent_id_page_link',
215                                     qtip : "Select Category ",
216                                     tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{title}</b><br/><i>{page_link}</i> </div>',
217                                     loadingText : "Searching...",
218                                     items : [
219
220                                     ]
221
222                                 },
223                                 {
224                                     '|xns' : 'Roo.form',
225                                     xtype : 'Row',
226                                     xns : Roo.form,
227                                     items : [
228                                         {
229                                             '|xns' : 'Roo.form',
230                                             fieldLabel : 'Date to Publish',
231                                             format : 'Y-m-d',
232                                             xtype : 'DateField',
233                                             width : 200,
234                                             xns : Roo.form,
235                                             name : 'published'
236                                         },
237                                         {
238                                             '|xns' : 'Roo.form',
239                                             fieldLabel : 'Replaces',
240                                             xtype : 'TextField',
241                                             width : 75,
242                                             xns : Roo.form,
243                                             name : 'replaces_id'
244                                         }
245                                     ]
246
247                                 },
248                                 {
249                                     '|xns' : 'Roo.form',
250                                     hideLabels : true,
251                                     xtype : 'Row',
252                                     labelWidth : 0,
253                                     width : 520,
254                                     xns : Roo.form,
255                                     items : [
256                                         {
257                                             '|xns' : 'Roo.form',
258                                             xtype : 'Checkbox',
259                                             width : 100,
260                                             boxLabel : 'Visible',
261                                             xns : Roo.form,
262                                             name : 'visible'
263                                         },
264                                         {
265                                             '|xns' : 'Roo.form',
266                                             xtype : 'Checkbox',
267                                             width : 150,
268                                             boxLabel : 'Display in RSS',
269                                             xns : Roo.form,
270                                             name : 'in_rss'
271                                         },
272                                         {
273                                             '|xns' : 'Roo.form',
274                                             inputValue : 1,
275                                             xtype : 'Checkbox',
276                                             boxLabel : 'Extended Vis.?',
277                                             width : 140,
278                                             xns : Roo.form,
279                                             name : 'has_extended'
280                                         }
281                                     ]
282
283                                 },
284                                 {
285                                     '|xns' : 'Roo.form',
286                                     fieldLabel : 'Title',
287                                     xtype : 'TextField',
288                                     width : 390,
289                                     xns : Roo.form,
290                                     name : 'title'
291                                 },
292                                 {
293                                     '|xns' : 'Roo.form',
294                                     labelAlign : 'top',
295                                     xtype : 'Column',
296                                     width : 570,
297                                     xns : Roo.form,
298                                     items : [
299                                         {
300                                             '|xns' : 'Roo.form',
301                                             fieldLabel : 'Contents',
302                                             xtype : 'HtmlEditor',
303                                             width : 550,
304                                             xns : Roo.form,
305                                             resizable : 's',
306                                             name : 'contents',
307                                             height : 200
308                                         }
309                                     ]
310
311                                 },
312                                 {
313                                     '|xns' : 'Roo.form',
314                                     labelAlign : 'top',
315                                     xtype : 'Column',
316                                     width : 570,
317                                     xns : Roo.form,
318                                     items : [
319                                         {
320                                             '|xns' : 'Roo.form',
321                                             fieldLabel : 'Extended Contents',
322                                             xtype : 'HtmlEditor',
323                                             width : 550,
324                                             xns : Roo.form,
325                                             resizable : 's',
326                                             name : 'extended',
327                                             height : 200
328                                         }
329                                     ]
330
331                                 },
332                                 {
333                                     '|xns' : 'Roo.form',
334                                     xtype : 'Hidden',
335                                     xns : Roo.form,
336                                     name : 'id'
337                                 }
338                             ]
339
340                         }
341                     ]
342
343                 },
344                 {
345                     grid : {
346                         dataSource : {
347                             reader : {
348                                 '|xns' : 'Roo.data',
349                                 id : 'id',
350                                 root : 'data',
351                                 xtype : 'JsonReader',
352                                 xns : Roo.data,
353                                 fields : [
354                                     {
355                                         'name': 'id',
356                                         'type': 'int'
357                                     },
358                                     {
359                                         'name': 'filename',
360                                         'type': 'string'
361                                     },
362                                     {
363                                         'name': 'ontable',
364                                         'type': 'string'
365                                     },
366                                     {
367                                         'name': 'onid',
368                                         'type': 'int'
369                                     },
370                                     {
371                                         'name': 'mimetype',
372                                         'type': 'string'
373                                     },
374                                     {
375                                         'name': 'width',
376                                         'type': 'int'
377                                     },
378                                     {
379                                         'name': 'height',
380                                         'type': 'int'
381                                     },
382                                     {
383                                         'name': 'filesize',
384                                         'type': 'int'
385                                     },
386                                     {
387                                         'name': 'displayorder',
388                                         'type': 'int'
389                                     },
390                                     {
391                                         'name': 'language',
392                                         'type': 'string'
393                                     },
394                                     {
395                                         'name': 'parent_image_id',
396                                         'type': 'int'
397                                     },
398                                     {
399                                         'name': 'created',
400                                         'type': 'date',
401                                         'dateFormat': 'Y-m-d'
402                                     },
403                                     {
404                                         'name': 'imgtype',
405                                         'type': 'string'
406                                     },
407                                     {
408                                         'name': 'linkurl',
409                                         'type': 'string'
410                                     },
411                                     {
412                                         'name': 'descript',
413                                         'type': 'string'
414                                     },
415                                     {
416                                         'name': 'title',
417                                         'type': 'string'
418                                     },
419                                     {
420                                         'name': 'parent_image_id_id',
421                                         'type': 'int'
422                                     },
423                                     {
424                                         'name': 'parent_image_id_filename',
425                                         'type': 'string'
426                                     },
427                                     {
428                                         'name': 'parent_image_id_ontable',
429                                         'type': 'string'
430                                     },
431                                     {
432                                         'name': 'parent_image_id_onid',
433                                         'type': 'int'
434                                     },
435                                     {
436                                         'name': 'parent_image_id_mimetype',
437                                         'type': 'string'
438                                     },
439                                     {
440                                         'name': 'parent_image_id_width',
441                                         'type': 'int'
442                                     },
443                                     {
444                                         'name': 'parent_image_id_height',
445                                         'type': 'int'
446                                     },
447                                     {
448                                         'name': 'parent_image_id_filesize',
449                                         'type': 'int'
450                                     },
451                                     {
452                                         'name': 'parent_image_id_displayorder',
453                                         'type': 'int'
454                                     },
455                                     {
456                                         'name': 'parent_image_id_language',
457                                         'type': 'string'
458                                     },
459                                     {
460                                         'name': 'parent_image_id_parent_image_id',
461                                         'type': 'int'
462                                     },
463                                     {
464                                         'name': 'parent_image_id_created',
465                                         'type': 'date'
466                                     },
467                                     {
468                                         'name': 'parent_image_id_imgtype',
469                                         'type': 'string'
470                                     },
471                                     {
472                                         'name': 'parent_image_id_linkurl',
473                                         'type': 'string'
474                                     },
475                                     {
476                                         'name': 'parent_image_id_descript',
477                                         'type': 'string'
478                                     },
479                                     {
480                                         'name': 'parent_image_id_title',
481                                         'type': 'string'
482                                     }
483                                 ],
484                                 totalProperty : 'total'
485                             },
486                             proxy : {
487                                 '|xns' : 'Roo.data',
488                                 url : baseURL + '/Roo/Images.php',
489                                 method : 'GET',
490                                 xtype : 'HttpProxy',
491                                 xns : Roo.data
492                             },
493                             '|xns' : 'Roo.data',
494                             xtype : 'Store',
495                             xns : Roo.data,
496                             listeners : {
497                                 beforeload : function (_self, o)
498                                    {
499                                        if (!_this.data.id) {
500                                           return false;
501                                        } 
502                                        o.params = o.params || {};              
503                                        o.params.onid = _this.data.id;
504                                        o.params.ontable = 'Page';
505                                    }
506                             },
507                             items : [
508
509                             ]
510
511                         },
512                         toolbar : {
513                             '|xns' : 'Roo',
514                             xtype : 'Toolbar',
515                             xns : Roo,
516                             items : [
517                                 {
518                                     '|xns' : 'Roo',
519                                     text : "Add",
520                                     xtype : 'Button',
521                                     cls : 'x-btn-text-icon',
522                                     icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
523                                     xns : Roo,
524                                     listeners : {
525                                         click : function()
526                                            {
527                                                Pman.Dialog.Image.show( { id : 0, onid: _this.data.id, ontable: 'Page' }, function() {
528                                                    _this.grid.getDataSource().load();
529                                                }); 
530                                            
531                                            }
532                                     }
533                                 },
534                                 {
535                                     '|xns' : 'Roo',
536                                     text : "Delete",
537                                     xtype : 'Button',
538                                     cls : 'x-btn-text-icon',
539                                     icon : rootURL + '/Pman/templates/images/trash.gif',
540                                     xns : Roo,
541                                     listeners : {
542                                         click : function()
543                                                    {
544                                                    Pman.genericDelete(_this, _this.panel.tableName); 
545                                                    }
546                                     }
547                                 }
548                             ]
549
550                         },
551                         '|xns' : 'Roo.grid',
552                         autoExpandColumn : 'filename',
553                         xtype : 'Grid',
554                         loadMask : true,
555                         xns : Roo.grid,
556                         colModel : [
557                                  {
558                                         '|xns' : 'Roo.grid',
559                                         xtype : 'ColumnModel',
560                                         sortable : false,
561                                         width : 50,
562                                         header : '',
563                                         renderer : function(v,x,r) { return String.format('<img src="{0}/Images/Thumb/100/{1}/{2}">', baseURL, v, r.data.filename); },
564                                         xns : Roo.grid,
565                                         dataIndex : 'id'
566                                     },
567 {
568                                         '|xns' : 'Roo.grid',
569                                         xtype : 'ColumnModel',
570                                         width : 100,
571                                         header : 'Filename',
572                                         renderer : function(v) { return String.format('{0}', v); },
573                                         xns : Roo.grid,
574                                         dataIndex : 'filename'
575                                     }
576                         ],
577                         listeners : {
578                                 rowdblclick : function (_self, rowIndex, e)
579                                    {
580                                        var rd = _this.grid.getDataSource().getAt(rowIndex);
581                                        var id = rd.data.id;
582                                        var url = String.format('{0}/Images/{1}/{2}', baseURL, rd.data.id, rd.data.filename);
583                                        _this.form.findField('contents').execCmd('insertimage', url);
584                                    
585                                    },
586                                 render : function() { 
587                                        _this.grid = this; 
588                                        //_this.dialog = Pman.Dialog.FILL_IN
589                                        if (_this.panel.active) {
590                                           //this.footer.onClick('first');
591                                        }
592                                    }
593                         },
594                         items : [
595
596                         ]
597
598                     },
599                     '|xns' : 'Roo',
600                     fitToframe : true,
601                     background : false,
602                     region : 'east',
603                     xtype : 'GridPanel',
604                     title : "Images",
605                     fitContainer : true,
606                     xns : Roo,
607                     tableName : 'Images',
608                     listeners : {
609                         activate : function() {
610                                _this.panel = this;
611                                if (_this.grid) {
612                                    _this.grid.footer.onClick('first');
613                                }
614                            }
615                     },
616                     items : [
617
618                     ]
619
620                 }
621             ]
622
623         });
624     }
625 };