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