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: 'GridPanel',
36             xns: Roo,
37             listeners : {
38                 activate : function() {
39                     _this.panel = this;
40                     if (_this.grid) {
41                         _this.grid.footer.onClick('first');
42                     }
43                 }
44             },
45             background : true,
46             fitContainer : true,
47             fitToframe : true,
48             region : 'center',
49             tableName : 'cms_rssaggr',
50             title : "RSS Feed Aggregator",
51             grid : {
52                 xtype: 'Grid',
53                 xns: Roo.grid,
54                 listeners : {
55                     render : function() 
56                     {
57                         _this.grid = this; 
58                         //_this.dialog = Pman.Dialog.FILL_IN
59                         if (_this.panel.active) {
60                            this.footer.onClick('first');
61                         }
62                     },
63                     cellclick : function (_self, rowIndex, colIndex, e)
64                     {
65                     
66                         if (colIndex != 0) {
67                             return;
68                         }
69                         var d = this.ds.getAt(rowIndex);
70                         var s =    d.data.is_displayed ? 0 : 1;
71                         d.set('is_displayed', s);
72                         new Pman.Request({
73                             baseURL : 'Roo/cms_rssaggr',
74                             method : 'POST',
75                             params : {
76                                 id : d.data.id,
77                                 is_displayed : s
78                             },
79                             success : function( ) {
80                             
81                             } 
82                             // should error on failure.
83                         });
84                         
85                         
86                         
87                     
88                     }
89                 },
90                 autoExpandColumn : 'headline',
91                 loadMask : true,
92                 dataSource : {
93                     xtype: 'Store',
94                     xns: Roo.data,
95                     remoteSort : true,
96                     sortInfo : { field : 'published_dt', direction: 'DESC' },
97                     proxy : {
98                         xtype: 'HttpProxy',
99                         xns: Roo.data,
100                         method : 'GET',
101                         url : baseURL + '/Roo/cms_rssaggr.php'
102                     },
103                     reader : {
104                         xtype: 'JsonReader',
105                         xns: Roo.data,
106                         totalProperty : 'total',
107                         root : 'data',
108                         id : 'id',
109                         fields : [
110                             {
111                                 'name': 'id',
112                                 'type': 'int'
113                             },
114                             {
115                                 'name': 'extid',
116                                 'type': 'string'
117                             },
118                             {
119                                 'name': 'published_dt',
120                                 'type': 'date',
121                                 'dateFormat': 'Y-m-d'
122                             },
123                             {
124                                 'name': 'headline',
125                                 'type': 'string'
126                             },
127                             {
128                                 'name': 'body',
129                                 'type': 'string'
130                             },
131                             {
132                                 'name': 'src_id',
133                                 'type': 'int'
134                             }
135                         ]
136                     }
137                 },
138                 footer : {
139                     xtype: 'PagingToolbar',
140                     xns: Roo,
141                     pageSize : 25,
142                     displayInfo : true,
143                     displayMsg : "Displaying cms_rssaggr{0} - {1} of {2}",
144                     emptyMsg : "No cms_rssaggr found"
145                 },
146                 toolbar : {
147                     xtype: 'Toolbar',
148                     xns: Roo,
149                     items : [
150                         {
151                             xtype: 'Button',
152                             xns: Roo.Toolbar,
153                             listeners : {
154                                 click : function (_self, e)
155                                 {
156                                     new Pman.Request({
157                                         url : baseURL + '/Roo/cms_rssaggr',
158                                         method : 'GET',
159                                         params : {
160                                             _pullfeed : 1
161                                         },
162                                         success : function() {
163                                             _this.grid.onClick('first');
164                                         }
165                                     });
166                                 }
167                             },
168                             text : "Update from Feed"
169                         },
170                         {
171                             xtype: 'Fill',
172                             xns: Roo.Toolbar
173                         },
174                         {
175                             xtype: 'Button',
176                             xns: Roo.Toolbar,
177                             text : "Add",
178                             cls : 'x-btn-text-icon',
179                             icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
180                             listeners : {
181                                 click : function()
182                                 {
183                                     if (!_this.dialog) return;
184                                     _this.dialog.show( { id : 0 } , function() {
185                                         _this.grid.footer.onClick('first');
186                                    }); 
187                                 }
188                             }
189                         },
190                         {
191                             xtype: 'Button',
192                             xns: Roo.Toolbar,
193                             text : "Edit",
194                             cls : 'x-btn-text-icon',
195                             icon : Roo.rootURL + 'images/default/tree/leaf.gif',
196                             listeners : {
197                                 click : function()
198                                 {
199                                     var s = _this.grid.getSelectionModel().getSelections();
200                                     if (!s.length || (s.length > 1))  {
201                                         Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
202                                         return;
203                                     }
204                                     if (!_this.dialog) return;
205                                     _this.dialog.show(s[0].data, function() {
206                                         _this.grid.footer.onClick('first');
207                                     }); 
208                                     
209                                 }
210                             }
211                         },
212                         {
213                             xtype: 'Button',
214                             xns: Roo.Toolbar,
215                             text : "Delete",
216                             cls : 'x-btn-text-icon',
217                             icon : rootURL + '/Pman/templates/images/trash.gif',
218                             listeners : {
219                                 click : function()
220                                 {
221                                      Pman.genericDelete(_this, 'cms_rssaggr'); 
222                                 }
223                             }
224                         }
225                     ]
226                 },
227                 colModel : [
228                     {
229                         xtype: 'ColumnModel',
230                         xns: Roo.grid,
231                         dataIndex : 'is_displayed',
232                         header : 'Displayed',
233                         width : 75,
234                         renderer : function(v) {  
235                             var state = v> 0 ?  '-checked' : '';
236                         
237                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
238                                         
239                          }
240                     },
241                     {
242                         xtype: 'ColumnModel',
243                         xns: Roo.grid,
244                         dataIndex : 'published_dt',
245                         header : 'Published',
246                         width : 75,
247                         renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
248                     },
249                     {
250                         xtype: 'ColumnModel',
251                         xns: Roo.grid,
252                         header : 'Headline',
253                         width : 200,
254                         dataIndex : 'headline',
255                         renderer : function(v) { return String.format('{0}', v); }
256                     },
257                     {
258                         xtype: 'ColumnModel',
259                         xns: Roo.grid,
260                         header : 'Body',
261                         width : 200,
262                         dataIndex : 'body',
263                         renderer : function(v) { return String.format('{0}', v); }
264                     }
265                 ]
266             }
267         });
268         this.layout = this.panel.layout;
269
270     }
271 });