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