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