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',
38 title : "Edit / Create Product",
42 xtype: 'ContentPanel',
50 actioncomplete : function(_self,action)
52 if (action.type == 'setdata') {
55 _this.dialog.el.mask("Loading");
56 this.load({ method: 'GET', params: { '_id' : _this.data.id }});
59 _this.imageView.loadImages();
62 if (action.type == 'load') {
63 _this.imageView.loadImages();
64 _this.dialog.el.unmask();
67 if (action.type =='submit') {
69 _this.dialog.el.unmask();
71 _this.data.id = action.result.data.id;
72 _this.form.findField('id').setValue(_this.data.id);
74 var res = _this.callback.call(_this, _this.form.getValues());
84 rendered : function (form)
90 style : 'margin:10px;',
91 url : baseURL + '/Roo/Product.php',
111 valid : function (_self)
116 fieldLabel : 'Visible',
129 fieldLabel : 'Description',
131 name : 'description',
151 xtype: 'NestedLayoutPanel',
154 activate : function (_self)
156 //console.log('activate');
157 if ( _this.imageView ){
158 _this.imageView.loadImages();
161 if (_this.hasUploadWatch) {
164 _this.hasUploadWatch =true;
165 _this.uploadSending =false;
166 window.setInterval( function()
168 var val = _this.uploadForm.findField('imageUpload').getValue();
169 if (!val || !val.length) {
173 if (_this.uploadSending) {
177 if (!_this.data.id) {
179 var cb = _this.callback;
180 _this.callback = function() {
181 _this.uploadSending = false;
185 _this.uploadSending = true;
186 _this.form.doAction("submit");
190 _this.uploadSending =true;
191 _this.uploadForm.findField('onid').setValue(_this.data.id);
192 _this.uploadForm.el.mask("Sending");
193 _this.uploadForm.submit.defer(100, _this.uploadForm);
200 title : "Images / PDF",
202 xtype: 'BorderLayout',
206 xtype: 'ContentPanel',
217 beforerender : function (_self, data)
219 _this.imageView = _self;
221 if (this.stylesheet) {
224 this.el.addClass('thumb-browser');
227 this.stylesheet = Roo.util.CSS.createStyleSheet(
229 '.thumb-browser .thumb-wrap' : {
230 border:'3px solid #EEE',
234 'padding-left':'5px',
238 '.thumb-browser .x-view-selected' : {
239 border:'3px solid #333'
251 loadImages : function() {
252 if (!_this.data.id) {
253 this.clearSelections();
260 url : baseURL + '/Roo/Images.php',
264 onid : _this.data.id,
265 'query[imagesize]' : 150
274 html : '<div class="thumb-wrap"> ' +
275 '<div class="thumb"><img src="'+ baseURL + '/Images/Thumb/150/{id}/{filename}" class="thumb-img"></div>' +
288 click : function (_self, e)
291 if (!_this.imageView.getSelectedNodes().length) {
292 Roo.MessageBox.alert("Error", "Select an Image");
295 var n = _this.imageView.getNodeData(_this.imageView.getSelectedNodes()[0]);
297 // open a new window with this file in..
299 url: baseURL + '/Images/Download/' + n.id + '/' + n.filename
313 click : function (_self, e)
315 if (!_this.imageView.getSelectedNodes().length) {
316 Roo.MessageBox.alert("Error", "Select an Image");
319 var id = _this.imageView.getNodeData(_this.imageView.getSelectedNodes()[0]).id;
320 _this.imageView.el.mask('Deleting');
323 url : baseURL + '/Roo/Images.php',
328 success : function() {
329 _this.imageView.el.unmask();
330 _this.imageView.loadImages();
332 failure : function() {
333 _this.imageView.el.unmask();
334 Roo.MessageBox.alert("Error", "Error deleting image");
340 text : "Delete File/Image"
346 xtype: 'ContentPanel',
354 actioncomplete : function (_self, action)
356 // only action this will handle is submit?
357 // should test for errors..
358 if (action.failureType) {
359 _this.uploadForm.el.unmask();
360 _this.uploadSending = false;
361 Roo.MessageBox.alert("Error", "Upload Failed");
367 if (action.type =='submit') {
368 _this.uploadForm.reset();
369 _this.uploadSending = false;
370 _this.uploadForm.el.unmask();
371 _this.imageView.loadImages();
376 rendered : function (form)
378 _this.uploadForm = form;
384 style : 'margin: 10px;',
385 url : baseURL + '/Roo/Images.php',
395 fieldLabel : 'Upload Image or File',
397 name : 'imageUpload',
419 xtype: 'LayoutRegion',
423 xtype: 'LayoutRegion',
431 xtype: 'LayoutRegion',
435 xtype: 'LayoutRegion',
444 click : function (_self, e)
455 click : function (_self, e)
460 _this.dialog.el.mask("Saving");
461 _this.form.doAction("submit");