Pman.Dialog.AdminEnumImages.bjs
[Pman.Admin] / Pman.Dialog.AdminEnumImages.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Pman.Dialog.AdminEnumImages = {
6
7     dialog : false,
8     callback:  false,
9
10     show : function(data, cb)
11     {
12         if (!this.dialog) {
13             this.create();
14         }
15
16         this.callback = cb;
17         this.data = data;
18         this.dialog.show(this.data._el);
19         if (this.form) {
20            this.form.reset();
21            this.form.setValues(data);
22            this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
23         }
24
25     },
26
27     create : function()
28     {
29         var _this = this;
30         this.dialog = Roo.factory({
31             xtype: 'LayoutDialog',
32             xns: Roo,
33             height : 500,
34             modal : true,
35             title : "Add / Edit Images",
36             width : 900,
37             items : [
38                 {
39                     xtype: 'GridPanel',
40                     xns: Roo,
41                     listeners : {
42                         activate : function() {
43                             _this.panel = this;
44                             if (_this.grid) {
45                                 _this.grid.footer.onClick('first');
46                             }
47                         }
48                     },
49                     background : false,
50                     fitContainer : true,
51                     fitToframe : true,
52                     region : 'center',
53                     tableName : 'Images',
54                     title : "Images",
55                     grid : {
56                         xtype: 'Grid',
57                         xns: Roo.grid,
58                         autoExpandColumn : 'title',
59                         loadMask : true,
60                         listeners : {
61                             render : function() { 
62                                 _this.grid = this; 
63                                 //_this.dialog = Pman.Dialog.FILL_IN
64                                 if (_this.panel.active) {
65                                    this.footer.onClick('first');
66                                 }
67                             },
68                             rowdblclick : function (_self, rowIndex, e)
69                             {
70                               
71                                var s =  _self.getDataSource().getAt(rowIndex);
72                                  Pman.Dialog.PressReleaseImage.show(s.data, function() {
73                                             _this.grid.footer.onClick('first');
74                                            }); 
75                             }
76                         },
77                         dataSource : {
78                             xtype: 'Store',
79                             xns: Roo.data,
80                             listeners : {
81                                 beforeload : function (_self, o)
82                                 {
83                                     //o.params.ontable = 'Companies';
84                                     
85                                   //   o.params.imgtype = 'PressRelease';
86                                     
87                                     
88                                     
89                                     
90                                 },
91                                 load : function (_self, records, options)
92                                 {
93                                  _this.panel.el.unmask();
94                                 }
95                             },
96                             remoteSort : true,
97                             sortInfo : { field: 'created' , direction: 'DESC' },
98                             reader : {
99                                 xtype: 'JsonReader',
100                                 xns: Roo.data,
101                                 id : 'id',
102                                 root : 'data',
103                                 totalProperty : 'total',
104                                 fields : [
105                                     {
106                                         'name': 'id',
107                                         'type': 'int'
108                                     },
109                                     {
110                                         'name': 'filename',
111                                         'type': 'string'
112                                     },
113                                     {
114                                         'name': 'ontable',
115                                         'type': 'string'
116                                     },
117                                     {
118                                         'name': 'onid',
119                                         'type': 'int'
120                                     },
121                                     {
122                                         'name': 'mimetype',
123                                         'type': 'string'
124                                     },
125                                     {
126                                         'name': 'width',
127                                         'type': 'int'
128                                     },
129                                     {
130                                         'name': 'height',
131                                         'type': 'int'
132                                     },
133                                     {
134                                         'name': 'filesize',
135                                         'type': 'int'
136                                     },
137                                     {
138                                         'name': 'displayorder',
139                                         'type': 'int'
140                                     },
141                                     {
142                                         'name': 'language',
143                                         'type': 'string'
144                                     },
145                                     {
146                                         'name': 'parent_image_id',
147                                         'type': 'int'
148                                     },
149                                     {
150                                         'name': 'created',
151                                         'type': 'date',
152                                         'dateFormat' : 'Y-m-d H:i:s'
153                                     },
154                                     {
155                                         'name': 'imgtype',
156                                         'type': 'string'
157                                     },
158                                     {
159                                         'name': 'linkurl',
160                                         'type': 'string'
161                                     },
162                                     {
163                                         'name': 'descript',
164                                         'type': 'string'
165                                     },
166                                     {
167                                         'name': 'title',
168                                         'type': 'string'
169                                     }
170                                 ]
171                             },
172                             proxy : {
173                                 xtype: 'HttpProxy',
174                                 xns: Roo.data,
175                                 method : 'GET',
176                                 url : baseURL + '/Roo/Images.php'
177                             }
178                         },
179                         footer : {
180                             xtype: 'PagingToolbar',
181                             xns: Roo,
182                             pageSize : 25,
183                             displayInfo : true,
184                             displayMsg : "Displaying Images  {0} - {1} of {2}",
185                             emptyMsg : "No Images found"
186                         },
187                         toolbar : {
188                             xtype: 'Toolbar',
189                             xns: Roo,
190                             items : [
191                                 {
192                                     xtype: 'Button',
193                                     xns: Roo.Toolbar,
194                                     listeners : {
195                                         click : function()
196                                                 {
197                                                     
198                                               var sel = Pman.Tab.PressReleaseCompanies  ? Pman.Tab.PressReleaseCompanies.grid.getSelectionModel().getSelected() : false
199                                              
200                                             Pman.Dialog.Image.show( {
201                                                id : 0, 
202                                                 ontable: 'Companies', 
203                                                  onid: sel.data.id,
204                                             imgtype : 'PressRelease'
205                                              }, 
206                                             function(data) {
207                                                         if (!data) { return; } 
208                                              Pman.Dialog.PressReleaseImage.show( data, function() {
209                                                           _this.grid.footer.onClick('first');
210                                         
211                                                     }); 
212                                                         }); 
213                                         
214                                                 }
215                                     },
216                                     cls : 'x-btn-text-icon',
217                                     text : "Add",
218                                     icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
219                                 },
220                                 {
221                                     xtype: 'Button',
222                                     xns: Roo,
223                                     listeners : {
224                                         click : function()
225                                         {
226                                             var s = _this.grid.getSelectionModel().getSelections();
227                                             if (!s || s.length != 1) {
228                                                 Roo.MessageBox.alert("Error", "Select a single image to edit");
229                                                return;
230                                              }
231                                              var data = _this.grid.getDataSource().getById(s[0].data.id).data;
232                                             
233                                                      Pman.Dialog.PressReleaseImage.show(data, function() {
234                                                         _this.grid.footer.onClick('first');
235                                                        }); 
236                                                     
237                                                 }
238                                     },
239                                     cls : 'x-btn-text-icon',
240                                     text : "Edit",
241                                     icon : Roo.rootURL + 'images/default/tree/leaf.gif'
242                                 },
243                                 {
244                                     xtype: 'Button',
245                                     xns: Roo.Toolbar,
246                                     listeners : {
247                                         click : function()
248                                                 {
249                                                 Pman.genericDelete(_this, 'Images'); 
250                                                 }
251                                     },
252                                     cls : 'x-btn-text-icon',
253                                     text : "Delete",
254                                     icon : rootURL + '/Pman/templates/images/trash.gif'
255                                 }
256                             ]
257                         },
258                         colModel : [
259                             {
260                                 xtype: 'ColumnModel',
261                                 xns: Roo.grid,
262                                 header : 'Created',
263                                 width : 100,
264                                 dataIndex : 'created',
265                                 renderer : function(v,x,r) {
266                                        return String.format('{0}<br/><i>{1}</i><br/>{2}<br/><i>{3}x{4}</i>',
267                                             v.format('d/M/Y'), r.data.mimetype, r.data.filename,
268                                     r.data.width, r.data.height
269                                     ); 
270                                 },
271                                 sortable : true
272                             },
273                             {
274                                 xtype: 'ColumnModel',
275                                 xns: Roo.grid,
276                                 dataIndex : 'id',
277                                 header : 'Image',
278                                 width : 100,
279                                 renderer : function(v,x,r) { return String.format('<img src="{0}/Images/Thumb/100/{1}/{2}" width="100">', baseURL, v, r.data.filename); }
280                             },
281                             {
282                                 xtype: 'ColumnModel',
283                                 xns: Roo.grid,
284                                 dataIndex : 'title',
285                                 header : 'Details',
286                                 width : 100,
287                                 renderer : function(v,x,r) {
288                                      var surl = r.json.url.replace(/\/release.php\/Images\//, '/i/').replace(/\/([0-9]+)\/.*$/, '/$1');;
289                                      var svurl = r.json.url_view.replace(/\/release.php\/Images\//, '/i/').replace(/\/([0-9]+)\/.*$/, '/$1');;
290                                       return String.format(
291                                           'Download Url : <a href="http://{0}{1}" target="_new">http://{0}{1}</a>' + 
292                                           '<br/>View Url : <a href="http://{0}{2}" target="_new">http://{0}{2}</a>' + 
293                                           '<br/><b>{3}</b><br/>{4}</i>', 
294                                           window.location.host, surl, svurl,
295                                            v, r.json.descript); 
296                                      
297                                     }
298                             }
299                         ]
300                     }
301                 }
302             ],
303             center : {
304                 xtype: 'LayoutRegion',
305                 xns: Roo
306             },
307             buttons : [
308                 {
309                     xtype: 'Button',
310                     xns: Roo,
311                     listeners : {
312                         click : function (_self, e)
313                         {
314                             _this.dialog.hide();
315                             _this.callback(true);
316                         }
317                     },
318                     text : "Cancel"
319                 },
320                 {
321                     xtype: 'Button',
322                     xns: Roo,
323                     listeners : {
324                         click : function (_self, e)
325                         {
326                             _this.dialog.hide();
327                             _this.callback(true);
328                         }
329                     },
330                     text : "OK"
331                 }
332             ]
333         });
334     }
335 };