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             background : false,
34             closable : false,
35             collapsible : false,
36             height : 500,
37             modal : true,
38             resizable : false,
39             title : "Saved Version",
40             width : 800,
41             items : [
42                 {
43                     xtype: 'GridPanel',
44                     xns: Roo,
45                     listeners : {
46                         activate : function() {
47                             _this.panel = this;
48                             if (_this.grid) {
49                                 _this.grid.footer.onClick('first');
50                             }
51                         }
52                     },
53                     background : false,
54                     fitContainer : true,
55                     fitToframe : true,
56                     region : 'west',
57                     tableName : 'Images',
58                     title : "Images",
59                     grid : {
60                         xtype: 'Grid',
61                         xns: Roo.grid,
62                         listeners : {
63                             render : function() 
64                             {
65                                 _this.grid = this; 
66                                 
67                                 if (_this.panel.active) {
68                                    this.footer.onClick('first');
69                                 }
70                             },
71                             rowdblclick : function (_self, rowIndex, e)
72                             {
73                             
74                             }
75                         },
76                         autoExpandColumn : 'filename',
77                         loadMask : true,
78                         sm : {
79                             xtype: 'RowSelectionModel',
80                             xns: Roo.grid,
81                             listeners : {
82                                 afterselectionchange : function (_self)
83                                 {
84                                     var selected = this.getSelected();
85                                     
86                                     if (!selected) {
87                                         _this.viewPanel.setContent("Nothing Selected");
88                                         return;
89                                     }
90                                     Roo.log(selected);
91                                     _this.viewPanel.setContent("Data Selected");
92                                 }
93                             },
94                             singleSelect : true
95                         },
96                         dataSource : {
97                             xtype: 'Store',
98                             xns: Roo.data,
99                             listeners : {
100                                 beforeload : function (_self, o)
101                                 {
102                                     o.params = o.params || {};
103                                     
104                                     if(typeof(_this.data) == 'undefined'){
105                                         this.removeAll();
106                                         return false;
107                                     }
108                                     
109                                     o.params.action = 'AUTOSAVE';
110                                 }
111                             },
112                             remoteSort : true,
113                             sortInfo : { field : 'filename', direction: 'ASC' },
114                             proxy : {
115                                 xtype: 'HttpProxy',
116                                 xns: Roo.data,
117                                 method : 'GET',
118                                 url : baseURL + '/Roo/Images.php'
119                             },
120                             reader : {
121                                 xtype: 'JsonReader',
122                                 xns: Roo.data,
123                                 id : 'id',
124                                 root : 'data',
125                                 totalProperty : 'total',
126                                 fields : [
127                                     {
128                                         'name': 'id',
129                                         'type': 'int'
130                                     },
131                                     {
132                                         'name': 'event_when',
133                                         'type': 'string'
134                                     }
135                                 ]
136                             }
137                         },
138                         footer : {
139                             xtype: 'PagingToolbar',
140                             xns: Roo,
141                             displayInfo : false,
142                             pageSize : 25
143                         },
144                         colModel : [
145                             {
146                                 xtype: 'ColumnModel',
147                                 xns: Roo.grid,
148                                 dataIndex : 'event_when',
149                                 header : 'Date',
150                                 width : 100,
151                                 renderer : function(v) { return String.format('{0}', v ? v.format('Y-m-d H:i:s') : ''); }
152                             }
153                         ]
154                     }
155                 },
156                 {
157                     xtype: 'ContentPanel',
158                     xns: Roo,
159                     listeners : {
160                         render : function (_self)
161                         {
162                             _this.viewPanel = _self;
163                         }
164                     },
165                     background : false,
166                     fitContainer : true,
167                     fitToFrame : true,
168                     region : 'center'
169                 }
170             ],
171             center : {
172                 xtype: 'LayoutRegion',
173                 xns: Roo
174             },
175             west : {
176                 xtype: 'LayoutRegion',
177                 xns: Roo,
178                 split : true,
179                 width : 200
180             },
181             buttons : [
182                 {
183                     xtype: 'Button',
184                     xns: Roo,
185                     listeners : {
186                         click : function() {
187                             _this.dialog.hide();
188                         }
189                     },
190                     text : "Cancel"
191                 },
192                 {
193                     xtype: 'Button',
194                     xns: Roo,
195                     listeners : {
196                         click : function() {
197                             _this.dialog.hide();
198                         }
199                     },
200                     text : "OK"
201                 }
202             ]
203         });
204     }
205 };