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