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