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