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                                     
99                                     _this.viewPanel.load( { url : baseURL + "/Roo/Events", method : 'GET' }, {_id : selected.data.id, _retrieve_source : 1}, function(oElement, bSuccess, oResponse){
100                                         
101                                         var res = Roo.decode(oResponse.responseText);
102                                         
103                                         if(!bSuccess || !res.success){
104                                             _this.viewPanel.setContent("Load data failed?!");
105                                         }
106                                 
107                                         if(typeof(res.data) === 'string'){
108                                             _this.viewPanel.setContent(res.data);
109                                             return;
110                                         }
111                                         
112                                         _this.source = res.data.POST.source;
113                                 
114                                         _this.viewPanel.setContent(_this.source);
115                                         
116                                     });
117                                 }
118                             },
119                             singleSelect : true
120                         },
121                         dataSource : {
122                             xtype: 'Store',
123                             xns: Roo.data,
124                             listeners : {
125                                 beforeload : function (_self, o)
126                                 {
127                                     o.params = o.params || {};
128                                     
129                                     if(typeof(_this.data) == 'undefined'){
130                                         this.removeAll();
131                                         return false;
132                                     }
133                                     Roo.log(_this.data);
134                                     o.params.action = 'AUTOSAVE';
135                                 }
136                             },
137                             remoteSort : true,
138                             sortInfo : { field : 'event_when', direction: 'DESC' },
139                             proxy : {
140                                 xtype: 'HttpProxy',
141                                 xns: Roo.data,
142                                 method : 'GET',
143                                 url : baseURL + '/Roo/Events.php'
144                             },
145                             reader : {
146                                 xtype: 'JsonReader',
147                                 xns: Roo.data,
148                                 id : 'id',
149                                 root : 'data',
150                                 totalProperty : 'total',
151                                 fields : [
152                                     {
153                                         'name': 'id',
154                                         'type': 'int'
155                                     },
156                                     {
157                                         'name': 'event_when',
158                                         'type': 'string'
159                                     }
160                                 ]
161                             }
162                         },
163                         footer : {
164                             xtype: 'PagingToolbar',
165                             xns: Roo,
166                             displayInfo : false,
167                             pageSize : 25
168                         },
169                         colModel : [
170                             {
171                                 xtype: 'ColumnModel',
172                                 xns: Roo.grid,
173                                 dataIndex : 'event_when',
174                                 header : 'Date',
175                                 width : 100,
176                                 renderer : function(v) { return String.format('{0}', v ? v.format('Y-m-d H:i:s') : ''); }
177                             }
178                         ]
179                     }
180                 },
181                 {
182                     xtype: 'ContentPanel',
183                     xns: Roo,
184                     listeners : {
185                         render : function (_self)
186                         {
187                             _this.viewPanel = _self;
188                         }
189                     },
190                     autoScroll : true,
191                     background : false,
192                     fitContainer : true,
193                     fitToFrame : true,
194                     region : 'center'
195                 }
196             ],
197             center : {
198                 xtype: 'LayoutRegion',
199                 xns: Roo
200             },
201             west : {
202                 xtype: 'LayoutRegion',
203                 xns: Roo,
204                 split : true,
205                 width : 200
206             },
207             buttons : [
208                 {
209                     xtype: 'Button',
210                     xns: Roo,
211                     listeners : {
212                         click : function() {
213                             _this.dialog.hide();
214                         }
215                     },
216                     text : "Cancel"
217                 },
218                 {
219                     xtype: 'Button',
220                     xns: Roo,
221                     listeners : {
222                         click : function() {
223                         
224                             _this.dialog.hide();
225                             
226                             if (_this.callback) {
227                                 _this.callback.call(this, act.result.data);
228                             }
229                         }
230                     },
231                     text : "OK"
232                 }
233             ]
234         });
235     }
236 };