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