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