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) {
170 _this.uploadSending =true;
171 _this.uploadForm.findField('onid').setValue(_this.data.id);
172 _this.uploadForm.el.mask("Sending");
173 _this.uploadForm.submit.defer(100, _this.uploadForm);
180 title : "Images / PDF",
182 xtype: 'BorderLayout',
186 xtype: 'ContentPanel',
197 beforerender : function (_self, data)
199 _this.imageView = _self;
201 if (this.stylesheet) {
204 this.el.addClass('thumb-browser');
207 this.stylesheet = Roo.util.CSS.createStyleSheet(
209 '.thumb-browser .thumb-wrap' : {
210 border:'3px solid #EEE',
214 'padding-left':'5px',
218 '.thumb-browser .x-view-selected' : {
219 border:'3px solid #333'
231 loadImages : function() {
232 if (!_this.data.id) {return; }
235 url : baseURL + '/Roo/Images.php',
239 onid : _this.data.id,
240 'query[imagesize]' : 150
249 html : '<div class="thumb-wrap"> ' +
250 '<div class="thumb"><img src="'+ baseURL + '/Images/Thumb/150/{id}/{filename}" class="thumb-img"></div>' +
263 click : function (_self, e)
266 if (!_this.imageView.getSelectedNodes().length) {
267 Roo.MessageBox.alert("Error", "Select an Image");
270 var n = _this.imageView.getNodeData(_this.imageView.getSelectedNodes()[0]);
272 // open a new window with this file in..
274 url: baseURL + '/Images/Download/' + n.id + '/' + n.filename
288 click : function (_self, e)
290 if (!_this.imageView.getSelectedNodes().length) {
291 Roo.MessageBox.alert("Error", "Select an Image");
294 var id = _this.imageView.getNodeData(_this.imageView.getSelectedNodes()[0]).id;
295 _this.imageView.el.mask('Deleting');
298 url : baseURL + '/Roo/Images.php',
303 success : function() {
304 _this.imageView.el.unmask();
305 _this.imageView.loadImages();
307 failure : function() {
308 _this.imageView.el.unmask();
309 Roo.MessageBox.alert("Error", "Error deleting image");
315 text : "Delete File/Image"
321 xtype: 'ContentPanel',
329 actioncomplete : function (_self, action)
331 // only action this will handle is submit?
332 // should test for errors..
333 if (action.failureType) {
334 _this.uploadForm.el.unmask();
335 _this.uploadSending = false;
336 Roo.MessageBox.alert("Error", "Upload Failed");
342 if (action.type =='submit') {
343 _this.uploadForm.reset();
344 _this.uploadSending = false;
345 _this.uploadForm.el.unmask();
346 _this.imageView.loadImages();
351 rendered : function (form)
353 _this.uploadForm = form;
359 style : 'margin: 10px;',
360 url : baseURL + '/Roo/Images.php',
370 fieldLabel : 'Upload Image or File',
372 name : 'imageUpload',
394 xtype: 'LayoutRegion',
398 xtype: 'LayoutRegion',
406 xtype: 'LayoutRegion',
410 xtype: 'LayoutRegion',
419 click : function (_self, e)
430 click : function (_self, e)
435 _this.dialog.el.mask("Saving");
436 _this.form.doAction("submit");