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 Roo.namespace('Pman.Dialog');
6
7 Pman.Dialog.CoreAutoSavePreview = {
8
9  _strings : {
10   '87f9f735a1d36793ceaecd4e47124b63' :"Events",
11   'ea4788705e6873b424c65e91c2846b19' :"Cancel",
12   'bd88a20b53a47f7b5704a83a15ff5506' :"Saved Version",
13   '44749712dbec183e983dcd78a7736c41' :"Date",
14   'e0aa021e21dddbd6d8cecec71e9cf564' :"OK"
15  },
16
17  dialog : false,
18  callback:  false,
19
20  show : function(data, cb)
21  {
22   if (!this.dialog) {
23    this.create();
24   }
25
26   this.callback = cb;
27   this.data = data;
28   this.dialog.show(this.data._el);
29   if (this.form) {
30    this.form.reset();
31    this.form.setValues(data);
32    this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
33   }
34
35  },
36
37  create : function()
38  {
39    var _this = this;
40    this.dialog = Roo.factory({
41     center : {
42      '|xns' : 'Roo',
43      xns : Roo,
44      xtype : 'LayoutRegion'
45     },
46     west : {
47      '|xns' : 'Roo',
48      split : true,
49      width : 200,
50      xns : Roo,
51      xtype : 'LayoutRegion'
52     },
53     '|xns' : 'Roo',
54     background : false,
55     closable : false,
56     collapsible : false,
57     height : 500,
58     modal : true,
59     resizable : false,
60     title : _this._strings['bd88a20b53a47f7b5704a83a15ff5506'],
61     width : 800,
62     xns : Roo,
63     xtype : 'LayoutDialog',
64     buttons : [
65       {
66        '|xns' : 'Roo',
67        text : _this._strings['ea4788705e6873b424c65e91c2846b19'],
68        xns : Roo,
69        xtype : 'Button',
70        listeners : {
71         click : function() {
72              _this.dialog.hide();
73          }
74        }
75       },
76 {
77        '|xns' : 'Roo',
78        text : _this._strings['e0aa021e21dddbd6d8cecec71e9cf564'],
79        xns : Roo,
80        xtype : 'Button',
81        listeners : {
82         click : function() {
83          
84              _this.dialog.hide();
85              
86              if (_this.callback && _this.source != '') {
87                  _this.callback.call(this, _this.source);
88              }
89          }
90        }
91       }
92     ],
93     listeners : {
94      show : function (_self)
95       {
96           if(typeof(_this.data) != 'undefined'){
97               _this.grid.footer.onClick('first');
98           }
99           
100       }
101     },
102     items : [
103      {
104       grid : {
105        sm : {
106         '|xns' : 'Roo.grid',
107         singleSelect : true,
108         xns : Roo.grid,
109         xtype : 'RowSelectionModel',
110         listeners : {
111          afterselectionchange : function (_self)
112           {
113               var selected = this.getSelected();
114               
115               _this.source = '';
116               
117               if(!selected){
118                  _this.viewPanel.setContent("Please select an saved version on the left"); 
119                  return;
120               }
121               
122               _this.viewPanel.load( { url : baseURL + "/Roo/Events", method : 'GET' }, {_id : selected.data.id, _retrieve_source : 1}, function(oElement, bSuccess, oResponse){
123                   
124                   var res = Roo.decode(oResponse.responseText);
125                   
126                   if(!bSuccess || !res.success){
127                       _this.viewPanel.setContent("Load data failed?!");
128                   }
129                   
130                   if(typeof(res.data) === 'string'){
131                       _this.viewPanel.setContent(res.data);
132                       return;
133                   }
134                   
135                   if(!_this.data.successFn){
136                       Roo.MessageBox.alert('Error', 'Please setup the successFn');
137                       return;
138                   }
139                   
140                   _this.source = _this.data.successFn(res);
141           
142                   _this.viewPanel.setContent(_this.source);
143                   
144               });
145           }
146         }
147        },
148        dataSource : {
149         proxy : {
150          '|xns' : 'Roo.data',
151          method : 'GET',
152          url : baseURL + '/Roo/Events.php',
153          xns : Roo.data,
154          xtype : 'HttpProxy'
155         },
156         reader : {
157          '|xns' : 'Roo.data',
158          fields : [
159              {
160                  'name': 'id',
161                  'type': 'int'
162              },
163              {
164                  'name': 'event_when',
165                  'type': 'string'
166              }
167          ],
168          id : 'id',
169          root : 'data',
170          totalProperty : 'total',
171          xns : Roo.data,
172          xtype : 'JsonReader'
173         },
174         '|xns' : 'Roo.data',
175         remoteSort : true,
176         sortInfo : { field : 'event_when', direction: 'DESC' },
177         xns : Roo.data,
178         xtype : 'Store',
179         listeners : {
180          beforeload : function (_self, o)
181           {
182               o.params = o.params || {};
183               
184               if(typeof(_this.data) == 'undefined'){
185                   this.removeAll();
186                   return false;
187               }
188           
189               var d = Roo.apply({}, _this.data);
190               delete d.successFn;
191           
192               Roo.apply(o.params, d);
193               
194           },
195          load : function (_self, records, options)
196           {
197               var sm = _this.grid.getSelectionModel();
198               if (!sm.getSelections().length) {
199                   sm.selectFirstRow();
200                   
201                   sm.fireEvent('afterselectionchange', sm);
202               }
203           }
204         },
205         items : [
206
207         ]
208
209        },
210        footer : {
211         '|xns' : 'Roo',
212         displayInfo : false,
213         pageSize : 25,
214         xns : Roo,
215         xtype : 'PagingToolbar'
216        },
217        '|xns' : 'Roo.grid',
218        autoExpandColumn : 'event_when',
219        loadMask : true,
220        xns : Roo.grid,
221        xtype : 'Grid',
222        colModel : [
223          {
224           '|xns' : 'Roo.grid',
225           dataIndex : 'event_when',
226           header : _this._strings['44749712dbec183e983dcd78a7736c41'],
227           renderer : function(v) { return String.format('{0}', v ? v.format('Y-m-d H:i:s') : ''); },
228           width : 100,
229           xns : Roo.grid,
230           xtype : 'ColumnModel'
231          },
232 {
233           '|xns' : 'Roo.grid',
234           dataIndex : 'event_when',
235           header : _this._strings['44749712dbec183e983dcd78a7736c41'],
236           renderer : function(v) { return String.format('{0}', v ? v.format('Y-m-d H:i:s') : ''); },
237           width : 100,
238           xns : Roo.grid,
239           xtype : 'ColumnModel'
240          }
241        ],
242        listeners : {
243         render : function() 
244          {
245              _this.grid = this; 
246              
247              if (_this.panel.active) {
248                 this.footer.onClick('first');
249              }
250          }
251        },
252        items : [
253
254        ]
255
256       },
257       '|xns' : 'Roo',
258       background : false,
259       fitContainer : true,
260       fitToframe : true,
261       region : 'west',
262       tableName : 'Events',
263       title : _this._strings['87f9f735a1d36793ceaecd4e47124b63'],
264       xns : Roo,
265       xtype : 'GridPanel',
266       listeners : {
267        activate : function() {
268             _this.panel = this;
269             if (_this.grid) {
270                 _this.grid.footer.onClick('first');
271             }
272         }
273       },
274       items : [
275
276       ]
277
278      },
279      {
280       '|xns' : 'Roo',
281       autoScroll : true,
282       background : false,
283       fitContainer : true,
284       fitToFrame : true,
285       region : 'center',
286       xns : Roo,
287       xtype : 'ContentPanel',
288       listeners : {
289        render : function (_self)
290         {
291             _this.viewPanel = _self;
292         }
293       }
294      }
295     ]
296
297    });
298  }
299 };