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