1 //<script type="text/javascript">
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
5 Pman.Dialog.CmsProduct = {
10 show : function(data, cb)
18 this.dialog.show(this.data._el);
21 this.form.setValues(data);
22 this.form.fireEvent('actioncomplete', this.form, { type: 'setdata', data: data });
30 this.dialog = Roo.factory({
31 xtype: 'LayoutDialog',
37 title : "Edit / Create Product",
41 xtype: 'ContentPanel',
49 actioncomplete : function(_self,action)
51 if (action.type == 'setdata') {
52 _this.dialog.el.mask("Loading");
54 _this.dialog.el.mask("Loading");
55 this.load({ method: 'GET', params: { '_id' : _this.data.id }});
58 _this.imageView.loadImages();
61 if (action.type == 'load') {
62 _this.imageView.loadImages();
63 _this.dialog.el.unmask();
66 if (action.type =='submit') {
68 _this.dialog.el.unmask();
72 _this.callback.call(_this, _this.form.getValues());
78 rendered : function (form)
84 style : 'margin:10px;',
85 url : baseURL + '/Roo/Product.php',
105 valid : function (_self)
110 fieldLabel : 'Visible',
123 fieldLabel : 'Description',
125 name : 'description',
140 xtype: 'NestedLayoutPanel',
143 activate : function (_self)
145 //console.log('activate');
146 if ( _this.imageView ){
147 _this.imageView.loadImages();
150 if (_this.hasUploadWatch) {
153 _this.hasUploadWatch =true;
154 _this.uploadSending =false;
155 window.setInterval( function()
157 var val = _this.uploadForm.findField('imageUpload').getValue();
158 if (!val || !val.length) {
162 if (_this.uploadSending) {
172 _this.uploadSending =true;
173 _this.uploadForm.findField('onid').setValue(_this.data.id);
174 _this.uploadForm.el.mask("Sending");
175 _this.uploadForm.submit.defer(100, _this.uploadForm);
182 title : "Images / PDF",
184 xtype: 'BorderLayout',
188 xtype: 'ContentPanel',
199 beforerender : function (_self, data)
201 _this.imageView = _self;
203 if (this.stylesheet) {
206 this.el.addClass('thumb-browser');
209 this.stylesheet = Roo.util.CSS.createStyleSheet(
211 '.thumb-browser .thumb-wrap' : {
212 border:'3px solid #EEE',
216 'padding-left':'5px',
220 '.thumb-browser .x-view-selected' : {
221 border:'3px solid #333'
233 loadImages : function() {
234 if (!_this.data.id) {return; }
237 url : baseURL + '/Roo/Images.php',
241 onid : _this.data.id,
242 'query[imagesize]' : 150
251 html : '<div class="thumb-wrap"> ' +
252 '<div class="thumb"><img src="'+ baseURL + '/Images/Thumb/150/{id}/{filename}" class="thumb-img"></div>' +
265 click : function (_self, e)
268 if (!_this.imageView.getSelectedNodes().length) {
269 Roo.MessageBox.alert("Error", "Select an Image");
272 var n = _this.imageView.getNodeData(_this.imageView.getSelectedNodes()[0]);
274 // open a new window with this file in..
276 url: baseURL + '/Images/Download/' + n.id + '/' + n.filename
290 click : function (_self, e)
292 if (!_this.imageView.getSelectedNodes().length) {
293 Roo.MessageBox.alert("Error", "Select an Image");
296 var id = _this.imageView.getNodeData(_this.imageView.getSelectedNodes()[0]).id;
297 _this.imageView.el.mask('Deleting');
300 url : baseURL + '/Roo/Images.php',
305 success : function() {
306 _this.imageView.el.unmask();
307 _this.imageView.loadImages();
309 failure : function() {
310 _this.imageView.el.unmask();
311 Roo.MessageBox.alert("Error", "Error deleting image");
317 text : "Delete File/Image"
323 xtype: 'ContentPanel',
331 actioncomplete : function (_self, action)
333 // only action this will handle is submit?
334 // should test for errors..
335 if (action.failureType) {
336 _this.uploadForm.el.unmask();
337 _this.uploadSending = false;
338 Roo.MessageBox.alert("Error", "Upload Failed");
344 if (action.type =='submit') {
345 _this.uploadForm.reset();
346 _this.uploadSending = false;
347 _this.uploadForm.el.unmask();
348 _this.imageView.loadImages();
353 rendered : function (form)
355 _this.uploadForm = form;
361 style : 'margin: 10px;',
362 url : baseURL + '/Roo/Images.php',
372 fieldLabel : 'Upload Image or File',
374 name : 'imageUpload',
396 xtype: 'LayoutRegion',
400 xtype: 'LayoutRegion',
408 xtype: 'LayoutRegion',
412 xtype: 'LayoutRegion',
421 click : function (_self, e)
432 click : function (_self, e)
437 _this.dialog.el.mask("Saving");
438 _this.form.doAction("submit");