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