Pman.Dialog.CoreAutoSavePreview.bjs
[Pman.Core] / Pman.Dialog.CoreAutoSavePreview.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.CoreAutoSavePreview = {
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 : false,
34             closable : false,
35             collapsible : false,
36             height : 500,
37             modal : true,
38             resizable : false,
39             title : "Saved Version",
40             width : 800,
41             items : [
42                 {
43                     xtype: 'GridPanel',
44                     xns: Roo,
45                     listeners : {
46                         activate : function() {
47                             _this.panel = this;
48                             if (_this.grid) {
49                             Roo.log(2);
50                                 _this.grid.footer.onClick('first');
51                             }
52                         }
53                     },
54                     background : true,
55                     fitContainer : true,
56                     fitToframe : true,
57                     region : 'west',
58                     tableName : 'Events',
59                     title : "Events",
60                     grid : {
61                         xtype: 'Grid',
62                         xns: Roo.grid,
63                         listeners : {
64                             render : function() { 
65                                 _this.grid = this; 
66                                 //_this.dialog = Pman.Dialog.FILL_IN
67                                 if (_this.panel.active) {
68                                 Roo.log('1');
69                                    this.footer.onClick('first');
70                                 }
71                             }
72                         },
73                         autoExpandColumn : 'event_when',
74                         loadMask : true,
75                         sm : {
76                             xtype: 'RowSelectionModel',
77                             xns: Roo.grid,
78                             listeners : {
79                                 afterselectionchange : function (_self)
80                                 {
81                                     
82                                     if (!this.getSelected()) {
83                                         _this.viewPanel.setContent("Nothing Selected");
84                                         return;
85                                     }
86                                     
87                                     _this.viewPanel.setContent("data");
88                                 }
89                             },
90                             singleSelect : true
91                         },
92                         footer : {
93                             xtype: 'PagingToolbar',
94                             xns: Roo,
95                             pageSize : 25,
96                             displayInfo : true,
97                             displayMsg : "Displaying Images{0} - {1} of {2}",
98                             emptyMsg : "No Images found"
99                         },
100                         dataSource : {
101                             xtype: 'Store',
102                             xns: Roo.data,
103                             listeners : {
104                                 beforeload : function (_self, o)
105                                 {
106                                     Roo.log(_this.data);
107                                     o.params = o.parmas || {};
108                                     o.params.action = 'AUTOSAVE';
109                                     
110                                 }
111                             },
112                             remoteSort : true,
113                             sortInfo : { field: 'event_when', direction: 'DESC'},
114                             reader : {
115                                 xtype: 'JsonReader',
116                                 xns: Roo.data,
117                                 totalProperty : 'total',
118                                 root : 'data',
119                                 id : 'id',
120                                 fields : [
121                                     {
122                                         'name': 'id',
123                                         'type': 'int'
124                                     },
125                                     {
126                                         'name': 'person_name',
127                                         'type': 'string'
128                                     },
129                                     {
130                                         'name': 'event_when',
131                                         'type': 'date',
132                                         'dateFormat': 'Y-m-d'
133                                     },
134                                     {
135                                         'name': 'action',
136                                         'type': 'string'
137                                     },
138                                     {
139                                         'name': 'ipaddr',
140                                         'type': 'string'
141                                     },
142                                     {
143                                         'name': 'on_id',
144                                         'type': 'int'
145                                     },
146                                     {
147                                         'name': 'on_table',
148                                         'type': 'string'
149                                     },
150                                     {
151                                         'name': 'person_id',
152                                         'type': 'int'
153                                     },
154                                     {
155                                         'name': 'remarks',
156                                         'type': 'string'
157                                     },
158                                     {
159                                         'name': 'person_id_id',
160                                         'type': 'int'
161                                     },
162                                     {
163                                         'name': 'person_id_office_id',
164                                         'type': 'int'
165                                     },
166                                     {
167                                         'name': 'person_id_name',
168                                         'type': 'string'
169                                     },
170                                     {
171                                         'name': 'person_id_phone',
172                                         'type': 'string'
173                                     },
174                                     {
175                                         'name': 'person_id_fax',
176                                         'type': 'string'
177                                     },
178                                     {
179                                         'name': 'person_id_email',
180                                         'type': 'string'
181                                     },
182                                     {
183                                         'name': 'person_id_company_id',
184                                         'type': 'int'
185                                     },
186                                     {
187                                         'name': 'person_id_role',
188                                         'type': 'string'
189                                     },
190                                     {
191                                         'name': 'person_id_active',
192                                         'type': 'int'
193                                     },
194                                     {
195                                         'name': 'person_id_remarks',
196                                         'type': 'string'
197                                     },
198                                     {
199                                         'name': 'person_id_passwd',
200                                         'type': 'string'
201                                     },
202                                     {
203                                         'name': 'person_id_owner_id',
204                                         'type': 'int'
205                                     },
206                                     {
207                                         'name': 'person_id_lang',
208                                         'type': 'string'
209                                     },
210                                     {
211                                         'name': 'person_id_no_reset_sent',
212                                         'type': 'int'
213                                     },
214                                     {
215                                         'name': 'person_id_action_type',
216                                         'type': 'string'
217                                     },
218                                     {
219                                         'name': 'person_id_project_id',
220                                         'type': 'int'
221                                     },
222                                     {
223                                         'name': 'person_id_deleted_by',
224                                         'type': 'int'
225                                     },
226                                     {
227                                         'name': 'person_id_deleted_dt',
228                                         'type': 'date'
229                                     }
230                                 ]
231                             },
232                             proxy : {
233                                 xtype: 'HttpProxy',
234                                 xns: Roo.data,
235                                 method : 'GET',
236                                 url : baseURL + '/Roo/Events.php'
237                             }
238                         },
239                         colModel : [
240                             {
241                                 xtype: 'ColumnModel',
242                                 xns: Roo.grid,
243                                 dataIndex : 'event_when',
244                                 header : 'Date',
245                                 width : 100,
246                                 renderer : function(v) { return v ? v.dateFormat('d/m/Y H:i') : ''; }
247                             }
248                         ]
249                     }
250                 },
251                 {
252                     xtype: 'GridPanel',
253                     xns: Roo,
254                     listeners : {
255                         activate : function() {
256                             _this.panel = this;
257                             if (_this.grid) {
258                                 _this.grid.footer.onClick('first');
259                             }
260                         }
261                     },
262                     background : true,
263                     fitContainer : true,
264                     fitToframe : true,
265                     region : 'west',
266                     tableName : 'Images',
267                     title : "Images",
268                     grid : {
269                         xtype: 'Grid',
270                         xns: Roo.grid,
271                         autoExpandColumn : 'filename',
272                         loadMask : true,
273                         listeners : {
274                             render : function() 
275                             {
276                                 _this.grid = this; 
277                                 //_this.dialog = Pman.Dialog.FILL_IN
278                                 if (_this.panel.active) {
279                                    this.footer.onClick('first');
280                                 }
281                             },
282                             rowdblclick : function (_self, rowIndex, e)
283                             {
284                                 if (!_this.dialog) return;
285                                 _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
286                                     _this.grid.footer.onClick('first');
287                                 }); 
288                             }
289                         },
290                         dataSource : {
291                             xtype: 'Store',
292                             xns: Roo.data,
293                             remoteSort : true,
294                             sortInfo : { field : 'filename', direction: 'ASC' },
295                             proxy : {
296                                 xtype: 'HttpProxy',
297                                 xns: Roo.data,
298                                 method : 'GET',
299                                 url : baseURL + '/Roo/Images.php'
300                             },
301                             reader : {
302                                 xtype: 'JsonReader',
303                                 xns: Roo.data,
304                                 totalProperty : 'total',
305                                 root : 'data',
306                                 id : 'id',
307                                 fields : [
308                                     {
309                                         'name': 'id',
310                                         'type': 'int'
311                                     },
312                                     {
313                                         'name': 'filename',
314                                         'type': 'string'
315                                     },
316                                     {
317                                         'name': 'ontable',
318                                         'type': 'string'
319                                     },
320                                     {
321                                         'name': 'onid',
322                                         'type': 'int'
323                                     },
324                                     {
325                                         'name': 'mimetype',
326                                         'type': 'string'
327                                     },
328                                     {
329                                         'name': 'width',
330                                         'type': 'int'
331                                     },
332                                     {
333                                         'name': 'height',
334                                         'type': 'int'
335                                     },
336                                     {
337                                         'name': 'filesize',
338                                         'type': 'int'
339                                     },
340                                     {
341                                         'name': 'displayorder',
342                                         'type': 'int'
343                                     },
344                                     {
345                                         'name': 'language',
346                                         'type': 'string'
347                                     },
348                                     {
349                                         'name': 'parent_image_id',
350                                         'type': 'int'
351                                     },
352                                     {
353                                         'name': 'created',
354                                         'type': 'date',
355                                         'dateFormat': 'Y-m-d'
356                                     },
357                                     {
358                                         'name': 'imgtype',
359                                         'type': 'string'
360                                     },
361                                     {
362                                         'name': 'linkurl',
363                                         'type': 'string'
364                                     },
365                                     {
366                                         'name': 'descript',
367                                         'type': 'string'
368                                     },
369                                     {
370                                         'name': 'title',
371                                         'type': 'string'
372                                     },
373                                     {
374                                         'name': 'parent_image_id_id',
375                                         'type': 'int'
376                                     },
377                                     {
378                                         'name': 'parent_image_id_filename',
379                                         'type': 'string'
380                                     },
381                                     {
382                                         'name': 'parent_image_id_ontable',
383                                         'type': 'string'
384                                     },
385                                     {
386                                         'name': 'parent_image_id_onid',
387                                         'type': 'int'
388                                     },
389                                     {
390                                         'name': 'parent_image_id_mimetype',
391                                         'type': 'string'
392                                     },
393                                     {
394                                         'name': 'parent_image_id_width',
395                                         'type': 'int'
396                                     },
397                                     {
398                                         'name': 'parent_image_id_height',
399                                         'type': 'int'
400                                     },
401                                     {
402                                         'name': 'parent_image_id_filesize',
403                                         'type': 'int'
404                                     },
405                                     {
406                                         'name': 'parent_image_id_displayorder',
407                                         'type': 'int'
408                                     },
409                                     {
410                                         'name': 'parent_image_id_language',
411                                         'type': 'string'
412                                     },
413                                     {
414                                         'name': 'parent_image_id_parent_image_id',
415                                         'type': 'int'
416                                     },
417                                     {
418                                         'name': 'parent_image_id_created',
419                                         'type': 'date'
420                                     },
421                                     {
422                                         'name': 'parent_image_id_imgtype',
423                                         'type': 'string'
424                                     },
425                                     {
426                                         'name': 'parent_image_id_linkurl',
427                                         'type': 'string'
428                                     },
429                                     {
430                                         'name': 'parent_image_id_descript',
431                                         'type': 'string'
432                                     },
433                                     {
434                                         'name': 'parent_image_id_title',
435                                         'type': 'string'
436                                     }
437                                 ]
438                             }
439                         },
440                         footer : {
441                             xtype: 'PagingToolbar',
442                             xns: Roo,
443                             pageSize : 25,
444                             displayInfo : true,
445                             displayMsg : "Displaying Images{0} - {1} of {2}",
446                             emptyMsg : "No Images found"
447                         },
448                         toolbar : {
449                             xtype: 'Toolbar',
450                             xns: Roo,
451                             items : [
452                                 {
453                                     xtype: 'Button',
454                                     xns: Roo.Toolbar,
455                                     text : "Add",
456                                     cls : 'x-btn-text-icon',
457                                     icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
458                                     listeners : {
459                                         click : function()
460                                         {
461                                             if (!_this.dialog) return;
462                                             _this.dialog.show( { id : 0 } , function() {
463                                                 _this.grid.footer.onClick('first');
464                                            }); 
465                                         }
466                                     }
467                                 },
468                                 {
469                                     xtype: 'Button',
470                                     xns: Roo.Toolbar,
471                                     text : "Edit",
472                                     cls : 'x-btn-text-icon',
473                                     icon : Roo.rootURL + 'images/default/tree/leaf.gif',
474                                     listeners : {
475                                         click : function()
476                                         {
477                                             var s = _this.grid.getSelectionModel().getSelections();
478                                             if (!s.length || (s.length > 1))  {
479                                                 Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
480                                                 return;
481                                             }
482                                             if (!_this.dialog) return;
483                                             _this.dialog.show(s[0].data, function() {
484                                                 _this.grid.footer.onClick('first');
485                                             }); 
486                                             
487                                         }
488                                     }
489                                 },
490                                 {
491                                     xtype: 'Button',
492                                     xns: Roo.Toolbar,
493                                     text : "Delete",
494                                     cls : 'x-btn-text-icon',
495                                     icon : rootURL + '/Pman/templates/images/trash.gif',
496                                     listeners : {
497                                         click : function()
498                                         {
499                                              Pman.genericDelete(_this, 'Images'); 
500                                         }
501                                     }
502                                 }
503                             ]
504                         },
505                         colModel : [
506                             {
507                                 xtype: 'ColumnModel',
508                                 xns: Roo.grid,
509                                 header : 'Id',
510                                 width : 75,
511                                 dataIndex : 'id',
512                                 renderer : function(v) { return String.format('{0}', v); }
513                             },
514                             {
515                                 xtype: 'ColumnModel',
516                                 xns: Roo.grid,
517                                 header : 'Filename',
518                                 width : 200,
519                                 dataIndex : 'filename',
520                                 renderer : function(v) { return String.format('{0}', v); }
521                             },
522                             {
523                                 xtype: 'ColumnModel',
524                                 xns: Roo.grid,
525                                 header : 'Ontable',
526                                 width : 200,
527                                 dataIndex : 'ontable',
528                                 renderer : function(v) { return String.format('{0}', v); }
529                             },
530                             {
531                                 xtype: 'ColumnModel',
532                                 xns: Roo.grid,
533                                 header : 'Onid',
534                                 width : 75,
535                                 dataIndex : 'onid',
536                                 renderer : function(v) { return String.format('{0}', v); }
537                             },
538                             {
539                                 xtype: 'ColumnModel',
540                                 xns: Roo.grid,
541                                 header : 'Mimetype',
542                                 width : 200,
543                                 dataIndex : 'mimetype',
544                                 renderer : function(v) { return String.format('{0}', v); }
545                             },
546                             {
547                                 xtype: 'ColumnModel',
548                                 xns: Roo.grid,
549                                 header : 'Width',
550                                 width : 75,
551                                 dataIndex : 'width',
552                                 renderer : function(v) { return String.format('{0}', v); }
553                             },
554                             {
555                                 xtype: 'ColumnModel',
556                                 xns: Roo.grid,
557                                 header : 'Height',
558                                 width : 75,
559                                 dataIndex : 'height',
560                                 renderer : function(v) { return String.format('{0}', v); }
561                             },
562                             {
563                                 xtype: 'ColumnModel',
564                                 xns: Roo.grid,
565                                 header : 'Filesize',
566                                 width : 75,
567                                 dataIndex : 'filesize',
568                                 renderer : function(v) { return String.format('{0}', v); }
569                             },
570                             {
571                                 xtype: 'ColumnModel',
572                                 xns: Roo.grid,
573                                 header : 'Displayorder',
574                                 width : 75,
575                                 dataIndex : 'displayorder',
576                                 renderer : function(v) { return String.format('{0}', v); }
577                             },
578                             {
579                                 xtype: 'ColumnModel',
580                                 xns: Roo.grid,
581                                 header : 'Language',
582                                 width : 200,
583                                 dataIndex : 'language',
584                                 renderer : function(v) { return String.format('{0}', v); }
585                             },
586                             {
587                                 xtype: 'ColumnModel',
588                                 xns: Roo.grid,
589                                 header : 'Parent image',
590                                 width : 75,
591                                 dataIndex : 'parent_image_id',
592                                 renderer : function(v) { return String.format('{0}', v); }
593                             },
594                             {
595                                 xtype: 'ColumnModel',
596                                 xns: Roo.grid,
597                                 header : 'Created',
598                                 width : 75,
599                                 dataIndex : 'created',
600                                 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
601                             },
602                             {
603                                 xtype: 'ColumnModel',
604                                 xns: Roo.grid,
605                                 header : 'Imgtype',
606                                 width : 200,
607                                 dataIndex : 'imgtype',
608                                 renderer : function(v) { return String.format('{0}', v); }
609                             },
610                             {
611                                 xtype: 'ColumnModel',
612                                 xns: Roo.grid,
613                                 header : 'Linkurl',
614                                 width : 200,
615                                 dataIndex : 'linkurl',
616                                 renderer : function(v) { return String.format('{0}', v); }
617                             },
618                             {
619                                 xtype: 'ColumnModel',
620                                 xns: Roo.grid,
621                                 header : 'Descript',
622                                 width : 200,
623                                 dataIndex : 'descript',
624                                 renderer : function(v) { return String.format('{0}', v); }
625                             },
626                             {
627                                 xtype: 'ColumnModel',
628                                 xns: Roo.grid,
629                                 header : 'Title',
630                                 width : 200,
631                                 dataIndex : 'title',
632                                 renderer : function(v) { return String.format('{0}', v); }
633                             }
634                         ]
635                     }
636                 },
637                 {
638                     xtype: 'ContentPanel',
639                     xns: Roo,
640                     listeners : {
641                         render : function (_self)
642                         {
643                             _this.viewPanel = _self;
644                         }
645                     },
646                     background : false,
647                     fitContainer : true,
648                     fitToFrame : true,
649                     region : 'center'
650                 }
651             ],
652             center : {
653                 xtype: 'LayoutRegion',
654                 xns: Roo
655             },
656             west : {
657                 xtype: 'LayoutRegion',
658                 xns: Roo,
659                 split : true,
660                 width : 200
661             },
662             buttons : [
663                 {
664                     xtype: 'Button',
665                     xns: Roo,
666                     listeners : {
667                         click : function() {
668                             _this.dialog.hide();
669                         }
670                     },
671                     text : "Cancel"
672                 },
673                 {
674                     xtype: 'Button',
675                     xns: Roo,
676                     listeners : {
677                         click : function() {
678                             _this.dialog.hide();
679                         }
680                     },
681                     text : "OK"
682                 }
683             ]
684         });
685     }
686 };