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: 'core_enum',
211                                                 onid: _this.data.onid,
212                                                 imgtype : ''
213                                             }, function(data){
214                                                 if (!data) { return; } 
215                                                  
216                                             }); 
217                                         
218                                         }
219                                     },
220                                     cls : 'x-btn-text-icon',
221                                     text : "Add",
222                                     icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
223                                 },
224                                 {
225                                     xtype: 'Button',
226                                     xns: Roo,
227                                     listeners : {
228                                         click : function()
229                                         {
230                                             var s = _this.grid.getSelectionModel().getSelections();
231                                             if (!s || s.length != 1) {
232                                                 Roo.MessageBox.alert("Error", "Select a single image to edit");
233                                                return;
234                                              }
235                                              var data = _this.grid.getDataSource().getById(s[0].data.id).data;
236                                             
237                                                      Pman.Dialog.PressReleaseImage.show(data, function() {
238                                                         _this.grid.footer.onClick('first');
239                                                        }); 
240                                                     
241                                                 }
242                                     },
243                                     cls : 'x-btn-text-icon',
244                                     text : "Edit",
245                                     icon : Roo.rootURL + 'images/default/tree/leaf.gif'
246                                 },
247                                 {
248                                     xtype: 'Button',
249                                     xns: Roo.Toolbar,
250                                     listeners : {
251                                         click : function()
252                                                 {
253                                                 Pman.genericDelete(_this, 'Images'); 
254                                                 }
255                                     },
256                                     cls : 'x-btn-text-icon',
257                                     text : "Delete",
258                                     icon : rootURL + '/Pman/templates/images/trash.gif'
259                                 }
260                             ]
261                         },
262                         colModel : [
263                             {
264                                 xtype: 'ColumnModel',
265                                 xns: Roo.grid,
266                                 header : 'Created',
267                                 width : 100,
268                                 dataIndex : 'created',
269                                 renderer : function(v,x,r) {
270                                        return String.format('{0}<br/><i>{1}</i><br/>{2}<br/><i>{3}x{4}</i>',
271                                             v.format('d/M/Y'), r.data.mimetype, r.data.filename,
272                                     r.data.width, r.data.height
273                                     ); 
274                                 },
275                                 sortable : true
276                             },
277                             {
278                                 xtype: 'ColumnModel',
279                                 xns: Roo.grid,
280                                 dataIndex : 'id',
281                                 header : 'Image',
282                                 width : 100,
283                                 renderer : function(v,x,r) { return String.format('<img src="{0}/Images/Thumb/100/{1}/{2}" width="100">', baseURL, v, r.data.filename); }
284                             },
285                             {
286                                 xtype: 'ColumnModel',
287                                 xns: Roo.grid,
288                                 dataIndex : 'title',
289                                 header : 'Details',
290                                 width : 100,
291                                 renderer : function(v,x,r) {
292                                 //     var surl = r.json.url.replace(/\/release.php\/Images\//, '/i/').replace(/\/([0-9]+)\/.*$/, '/$1');;
293                                   //   var svurl = r.json.url_view.replace(/\/release.php\/Images\//, '/i/').replace(/\/([0-9]+)\/.*$/, '/$1');;
294                                     //  return String.format(
295                                       //    'Download Url : <a href="http://{0}{1}" target="_new">http://{0}{1}</a>' + 
296                                         //  '<br/>View Url : <a href="http://{0}{2}" target="_new">http://{0}{2}</a>' + 
297                                           //'<br/><b>{3}</b><br/>{4}</i>', 
298                                          // window.location.host, surl, svurl,
299                                           // v, r.json.descript); 
300                                      
301                                     }
302                             }
303                         ]
304                     }
305                 }
306             ],
307             center : {
308                 xtype: 'LayoutRegion',
309                 xns: Roo
310             },
311             buttons : [
312                 {
313                     xtype: 'Button',
314                     xns: Roo,
315                     listeners : {
316                         click : function (_self, e)
317                         {
318                             _this.dialog.hide();
319                             _this.callback(true);
320                         }
321                     },
322                     text : "Cancel"
323                 },
324                 {
325                     xtype: 'Button',
326                     xns: Roo,
327                     listeners : {
328                         click : function (_self, e)
329                         {
330                             _this.dialog.hide();
331                             _this.callback(true);
332                         }
333                     },
334                     text : "OK"
335                 }
336             ]
337         });
338     }
339 };