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