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             listeners : {
34                 show : function (_self)
35                 {
36                     if(typeof(_this.data) != 'undefined'){
37                         _this.grid.footer.onClick('first');
38                     }
39                 }
40             },
41             background : false,
42             closable : false,
43             collapsible : false,
44             height : 500,
45             modal : true,
46             resizable : false,
47             title : "Saved Version",
48             width : 800,
49             items : [
50                 {
51                     xtype: 'GridPanel',
52                     xns: Roo,
53                     listeners : {
54                         activate : function() {
55                             _this.panel = this;
56                             if (_this.grid) {
57                                 _this.grid.footer.onClick('first');
58                             }
59                         }
60                     },
61                     background : false,
62                     fitContainer : true,
63                     fitToframe : true,
64                     region : 'west',
65                     tableName : 'Images',
66                     title : "Images",
67                     grid : {
68                         xtype: 'Grid',
69                         xns: Roo.grid,
70                         listeners : {
71                             render : function() 
72                             {
73                                 _this.grid = this; 
74                                 
75                                 if (_this.panel.active) {
76                                    this.footer.onClick('first');
77                                 }
78                             },
79                             rowdblclick : function (_self, rowIndex, e)
80                             {
81                             
82                             }
83                         },
84                         autoExpandColumn : 'filename',
85                         loadMask : true,
86                         sm : {
87                             xtype: 'RowSelectionModel',
88                             xns: Roo.grid,
89                             listeners : {
90                                 afterselectionchange : function (_self)
91                                 {
92                                     var selected = this.getSelected();
93                                     
94                                     if (!selected) {
95                                         _this.viewPanel.setContent("Nothing Selected");
96                                         return;
97                                     }
98                                     Roo.log(selected);
99                                     _this.viewPanel.load( { url : baseURL + "/Roo/Events", method : 'GET' }, {_id : selected.data.id, _retrieve_source : 1}, function(res){
100                                         Roo.log('res is here after load');
101                                         Roo.log(res);
102                                     
103                                     });
104                                 }
105                             },
106                             singleSelect : true
107                         },
108                         dataSource : {
109                             xtype: 'Store',
110                             xns: Roo.data,
111                             listeners : {
112                                 beforeload : function (_self, o)
113                                 {
114                                     o.params = o.params || {};
115                                     
116                                     if(typeof(_this.data) == 'undefined'){
117                                         this.removeAll();
118                                         return false;
119                                     }
120                                     Roo.log(_this.data);
121                                     o.params.action = 'AUTOSAVE';
122                                 }
123                             },
124                             remoteSort : true,
125                             sortInfo : { field : 'event_when', direction: 'DESC' },
126                             proxy : {
127                                 xtype: 'HttpProxy',
128                                 xns: Roo.data,
129                                 method : 'GET',
130                                 url : baseURL + '/Roo/Events.php'
131                             },
132                             reader : {
133                                 xtype: 'JsonReader',
134                                 xns: Roo.data,
135                                 id : 'id',
136                                 root : 'data',
137                                 totalProperty : 'total',
138                                 fields : [
139                                     {
140                                         'name': 'id',
141                                         'type': 'int'
142                                     },
143                                     {
144                                         'name': 'event_when',
145                                         'type': 'string'
146                                     }
147                                 ]
148                             }
149                         },
150                         footer : {
151                             xtype: 'PagingToolbar',
152                             xns: Roo,
153                             displayInfo : false,
154                             pageSize : 25
155                         },
156                         colModel : [
157                             {
158                                 xtype: 'ColumnModel',
159                                 xns: Roo.grid,
160                                 dataIndex : 'event_when',
161                                 header : 'Date',
162                                 width : 100,
163                                 renderer : function(v) { return String.format('{0}', v ? v.format('Y-m-d H:i:s') : ''); }
164                             }
165                         ]
166                     }
167                 },
168                 {
169                     xtype: 'ContentPanel',
170                     xns: Roo,
171                     listeners : {
172                         render : function (_self)
173                         {
174                             _this.viewPanel = _self;
175                         }
176                     },
177                     autoScroll : true,
178                     background : false,
179                     fitContainer : true,
180                     fitToFrame : true,
181                     region : 'center'
182                 }
183             ],
184             center : {
185                 xtype: 'LayoutRegion',
186                 xns: Roo
187             },
188             west : {
189                 xtype: 'LayoutRegion',
190                 xns: Roo,
191                 split : true,
192                 width : 200
193             },
194             buttons : [
195                 {
196                     xtype: 'Button',
197                     xns: Roo,
198                     listeners : {
199                         click : function() {
200                             _this.dialog.hide();
201                         }
202                     },
203                     text : "Cancel"
204                 },
205                 {
206                     xtype: 'Button',
207                     xns: Roo,
208                     listeners : {
209                         click : function() {
210                             _this.dialog.hide();
211                         }
212                     },
213                     text : "OK"
214                 }
215             ]
216         });
217     }
218 };