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