Pman.Tab.CmsAggregate.bjs
[Pman.Cms] / Pman.Tab.CmsAggregate.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5
6
7 // register the module first
8 Pman.on('beforeload', function()
9 {
10     Pman.register({
11         part :  ["Cms","Aggregate"],
12         modKey : '850-Pman.Tab.CmsAggregate',
13         module : Pman.Tab.CmsAggregate,
14         region : 'center',
15         parent : Pman.Tab.Cms,
16         name : "Pman.Tab.CmsAggregate",
17         disabled : false, 
18         permname: '' 
19     });
20 });
21
22 Pman.Tab.CmsAggregate = new Roo.util.Observable({
23
24     panel : false,
25     disabled : false,
26     parentLayout:  false,
27
28     add : function(parentLayout, region)
29     {
30
31         var _this = this;
32         this.parentLayout = parentLayout;
33
34         this.panel = parentLayout.addxtype({
35             xtype: 'NestedLayoutPanel',
36             xns: Roo,
37             region : 'center',
38             title : "RSS Feed Aggregator",
39             layout : {
40                 xtype: 'BorderLayout',
41                 xns: Roo,
42                 items : [
43                     {
44                         xtype: 'GridPanel',
45                         xns: Roo,
46                         listeners : {
47                             activate : function() {
48                                 _this.panel = this;
49                                 if (_this.grid) {
50                                     _this.grid.footer.onClick('first');
51                                 }
52                             }
53                         },
54                         background : true,
55                         fitContainer : true,
56                         fitToframe : true,
57                         region : 'center',
58                         tableName : 'cms_rssaggr',
59                         title : "RSS Feed Aggregator",
60                         grid : {
61                             xtype: 'Grid',
62                             xns: Roo.grid,
63                             listeners : {
64                                 render : function() 
65                                 {
66                                     _this.grid = this; 
67                                     //_this.dialog = Pman.Dialog.FILL_IN
68                                     if (_this.panel.active) {
69                                        this.footer.onClick('first');
70                                     }
71                                 },
72                                 cellclick : function (_self, rowIndex, colIndex, e)
73                                 {
74                                 
75                                     if (colIndex != 0) {
76                                         return;
77                                     }
78                                     var d = this.ds.getAt(rowIndex);
79                                     var s =    d.data.is_displayed ? 0 : 1;
80                                     d.set('is_displayed', s);
81                                     new Pman.Request({
82                                         url : baseURL + '/Roo/cms_rssaggr',
83                                         method : 'POST',
84                                         params : {
85                                             id : d.data.id,
86                                             is_displayed : s
87                                         },
88                                         success : function( ) {
89                                         
90                                         } 
91                                         // should error on failure.
92                                     });
93                                      
94                                 
95                                 },
96                                 rowclick : function (_self, rowIndex, e)
97                                 {
98                                     _this.cpanel.setContent(
99                                     
100                                         String.format('<div style="margin:10px">{0}</div>',
101                                         _this.grid.ds.getAt(rowIndex).data.body)
102                                     );
103                                 }
104                             },
105                             autoExpandColumn : 'headline',
106                             loadMask : true,
107                             dataSource : {
108                                 xtype: 'Store',
109                                 xns: Roo.data,
110                                 remoteSort : true,
111                                 sortInfo : { field : 'published_dt', direction: 'DESC' },
112                                 proxy : {
113                                     xtype: 'HttpProxy',
114                                     xns: Roo.data,
115                                     method : 'GET',
116                                     url : baseURL + '/Roo/cms_rssaggr.php'
117                                 },
118                                 reader : {
119                                     xtype: 'JsonReader',
120                                     xns: Roo.data,
121                                     totalProperty : 'total',
122                                     root : 'data',
123                                     id : 'id',
124                                     fields : [
125                                         {
126                                             'name': 'id',
127                                             'type': 'int'
128                                         },
129                                         {
130                                             'name': 'extid',
131                                             'type': 'string'
132                                         },
133                                         {
134                                             'name': 'published_dt',
135                                             'type': 'date',
136                                             'dateFormat': 'Y-m-d'
137                                         },
138                                         {
139                                             'name': 'headline',
140                                             'type': 'string'
141                                         },
142                                         {
143                                             'name': 'body',
144                                             'type': 'string'
145                                         },
146                                         {
147                                             'name': 'src_id',
148                                             'type': 'int'
149                                         }
150                                     ]
151                                 }
152                             },
153                             footer : {
154                                 xtype: 'PagingToolbar',
155                                 xns: Roo,
156                                 pageSize : 25,
157                                 displayInfo : true,
158                                 displayMsg : "Displaying cms_rssaggr{0} - {1} of {2}",
159                                 emptyMsg : "No cms_rssaggr found"
160                             },
161                             toolbar : {
162                                 xtype: 'Toolbar',
163                                 xns: Roo,
164                                 items : [
165                                     {
166                                         xtype: 'Button',
167                                         xns: Roo.Toolbar,
168                                         listeners : {
169                                             click : function (_self, e)
170                                             {
171                                                 Roo.MessageBox.alert("Downloading", 
172                                                     "Updating feed, wait till this message disapears, or press OK to let it carry on in the background"
173                                                 );
174                                                 
175                                                 
176                                                 new Pman.Request({
177                                                     url : baseURL + '/Roo/cms_rssaggr',
178                                                     method : 'GET',
179                                                     params : {
180                                                         _pullfeed : 1
181                                                     },
182                                                     success : function() {
183                                                         Roo.MessageBox.hide();
184                                                         _this.grid.footer.onClick('first');
185                                                     }
186                                                 });
187                                             }
188                                         },
189                                         text : "Update from Feed"
190                                     },
191                                     {
192                                         xtype: 'Fill',
193                                         xns: Roo.Toolbar
194                                     },
195                                     {
196                                         xtype: 'Button',
197                                         xns: Roo.Toolbar,
198                                         text : "Add",
199                                         cls : 'x-btn-text-icon',
200                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
201                                         listeners : {
202                                             click : function()
203                                             {
204                                                 if (!_this.dialog) return;
205                                                 _this.dialog.show( { id : 0 } , function() {
206                                                     _this.grid.footer.onClick('first');
207                                                }); 
208                                             }
209                                         }
210                                     },
211                                     {
212                                         xtype: 'Button',
213                                         xns: Roo.Toolbar,
214                                         text : "Edit",
215                                         cls : 'x-btn-text-icon',
216                                         icon : Roo.rootURL + 'images/default/tree/leaf.gif',
217                                         listeners : {
218                                             click : function()
219                                             {
220                                                 var s = _this.grid.getSelectionModel().getSelections();
221                                                 if (!s.length || (s.length > 1))  {
222                                                     Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
223                                                     return;
224                                                 }
225                                                 if (!_this.dialog) return;
226                                                 _this.dialog.show(s[0].data, function() {
227                                                     _this.grid.footer.onClick('first');
228                                                 }); 
229                                                 
230                                             }
231                                         }
232                                     },
233                                     {
234                                         xtype: 'Button',
235                                         xns: Roo.Toolbar,
236                                         text : "Delete",
237                                         cls : 'x-btn-text-icon',
238                                         icon : rootURL + '/Pman/templates/images/trash.gif',
239                                         listeners : {
240                                             click : function()
241                                             {
242                                                  Pman.genericDelete(_this, 'cms_rssaggr'); 
243                                             }
244                                         }
245                                     }
246                                 ]
247                             },
248                             colModel : [
249                                 {
250                                     xtype: 'ColumnModel',
251                                     xns: Roo.grid,
252                                     dataIndex : 'is_displayed',
253                                     header : 'Displayed',
254                                     width : 75,
255                                     renderer : function(v) {  
256                                         var state = v> 0 ?  '-checked' : '';
257                                     
258                                         return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
259                                                     
260                                      }
261                                 },
262                                 {
263                                     xtype: 'ColumnModel',
264                                     xns: Roo.grid,
265                                     dataIndex : 'published_dt',
266                                     header : 'Published',
267                                     width : 75,
268                                     renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
269                                 },
270                                 {
271                                     xtype: 'ColumnModel',
272                                     xns: Roo.grid,
273                                     header : 'Headline',
274                                     width : 200,
275                                     dataIndex : 'headline',
276                                     renderer : function(v) { return String.format('{0}', v); }
277                                 },
278                                 {
279                                     xtype: 'ColumnModel',
280                                     xns: Roo.grid,
281                                     header : 'Headline',
282                                     width : 200,
283                                     dataIndex : 'headline',
284                                     renderer : function(v) { return String.format('{0}', v); }
285                                 }
286                             ]
287                         }
288                     },
289                     {
290                         xtype: 'ContentPanel',
291                         xns: Roo,
292                         listeners : {
293                             render : function (_self)
294                             {
295                                 _this.cpanel = _self;
296                             }
297                         },
298                         region : 'south'
299                     }
300                 ],
301                 center : {
302                     xtype: 'LayoutRegion',
303                     xns: Roo
304                 },
305                 south : {
306                     xtype: 'LayoutRegion',
307                     xns: Roo,
308                     height : 150
309                 }
310             }
311         });
312         this.layout = this.panel.layout;
313
314     }
315 });