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