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) {
168 var cb = _this.callback;
169 _this.callback = function() {
170 _this.uploadSending = false;
174 _this.uploadSending = true;
178 _this.uploadSending =true;
179 _this.uploadForm.findField('onid').setValue(_this.data.id);
180 _this.uploadForm.el.mask("Sending");
181 _this.uploadForm.submit.defer(100, _this.uploadForm);
188 title : "Images / PDF",
190 xtype: 'BorderLayout',
194 xtype: 'ContentPanel',
205 beforerender : function (_self, data)
207 _this.imageView = _self;
209 if (this.stylesheet) {
212 this.el.addClass('thumb-browser');
215 this.stylesheet = Roo.util.CSS.createStyleSheet(
217 '.thumb-browser .thumb-wrap' : {
218 border:'3px solid #EEE',
222 'padding-left':'5px',
226 '.thumb-browser .x-view-selected' : {
227 border:'3px solid #333'
239 loadImages : function() {
240 if (!_this.data.id) {return; }
243 url : baseURL + '/Roo/Images.php',
247 onid : _this.data.id,
248 'query[imagesize]' : 150
257 html : '<div class="thumb-wrap"> ' +
258 '<div class="thumb"><img src="'+ baseURL + '/Images/Thumb/150/{id}/{filename}" class="thumb-img"></div>' +
271 click : function (_self, e)
274 if (!_this.imageView.getSelectedNodes().length) {
275 Roo.MessageBox.alert("Error", "Select an Image");
278 var n = _this.imageView.getNodeData(_this.imageView.getSelectedNodes()[0]);
280 // open a new window with this file in..
282 url: baseURL + '/Images/Download/' + n.id + '/' + n.filename
296 click : function (_self, e)
298 if (!_this.imageView.getSelectedNodes().length) {
299 Roo.MessageBox.alert("Error", "Select an Image");
302 var id = _this.imageView.getNodeData(_this.imageView.getSelectedNodes()[0]).id;
303 _this.imageView.el.mask('Deleting');
306 url : baseURL + '/Roo/Images.php',
311 success : function() {
312 _this.imageView.el.unmask();
313 _this.imageView.loadImages();
315 failure : function() {
316 _this.imageView.el.unmask();
317 Roo.MessageBox.alert("Error", "Error deleting image");
323 text : "Delete File/Image"
329 xtype: 'ContentPanel',
337 actioncomplete : function (_self, action)
339 // only action this will handle is submit?
340 // should test for errors..
341 if (action.failureType) {
342 _this.uploadForm.el.unmask();
343 _this.uploadSending = false;
344 Roo.MessageBox.alert("Error", "Upload Failed");
350 if (action.type =='submit') {
351 _this.uploadForm.reset();
352 _this.uploadSending = false;
353 _this.uploadForm.el.unmask();
354 _this.imageView.loadImages();
359 rendered : function (form)
361 _this.uploadForm = form;
367 style : 'margin: 10px;',
368 url : baseURL + '/Roo/Images.php',
378 fieldLabel : 'Upload Image or File',
380 name : 'imageUpload',
402 xtype: 'LayoutRegion',
406 xtype: 'LayoutRegion',
414 xtype: 'LayoutRegion',
418 xtype: 'LayoutRegion',
427 click : function (_self, e)
438 click : function (_self, e)
443 _this.dialog.el.mask("Saving");
444 _this.form.doAction("submit");