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',
146 xtype: 'NestedLayoutPanel',
149 activate : function (_self)
151 //console.log('activate');
152 if ( _this.imageView ){
153 _this.imageView.loadImages();
156 if (_this.hasUploadWatch) {
159 _this.hasUploadWatch =true;
160 _this.uploadSending =false;
161 window.setInterval( function()
163 var val = _this.uploadForm.findField('imageUpload').getValue();
164 if (!val || !val.length) {
168 if (_this.uploadSending) {
172 if (!_this.data.id) {
174 var cb = _this.callback;
175 _this.callback = function() {
176 _this.uploadSending = false;
180 _this.uploadSending = true;
181 _this.form.doAction("submit");
185 _this.uploadSending =true;
186 _this.uploadForm.findField('onid').setValue(_this.data.id);
187 _this.uploadForm.el.mask("Sending");
188 _this.uploadForm.submit.defer(100, _this.uploadForm);
195 title : "Images / PDF",
197 xtype: 'BorderLayout',
201 xtype: 'ContentPanel',
212 beforerender : function (_self, data)
214 _this.imageView = _self;
216 if (this.stylesheet) {
219 this.el.addClass('thumb-browser');
222 this.stylesheet = Roo.util.CSS.createStyleSheet(
224 '.thumb-browser .thumb-wrap' : {
225 border:'3px solid #EEE',
229 'padding-left':'5px',
233 '.thumb-browser .x-view-selected' : {
234 border:'3px solid #333'
246 loadImages : function() {
247 if (!_this.data.id) {
248 this.clearSelections();
255 url : baseURL + '/Roo/Images.php',
259 onid : _this.data.id,
260 'query[imagesize]' : 150
269 html : '<div class="thumb-wrap"> ' +
270 '<div class="thumb"><img src="'+ baseURL + '/Images/Thumb/150/{id}/{filename}" class="thumb-img"></div>' +
283 click : function (_self, e)
286 if (!_this.imageView.getSelectedNodes().length) {
287 Roo.MessageBox.alert("Error", "Select an Image");
290 var n = _this.imageView.getNodeData(_this.imageView.getSelectedNodes()[0]);
292 // open a new window with this file in..
294 url: baseURL + '/Images/Download/' + n.id + '/' + n.filename
308 click : function (_self, e)
310 if (!_this.imageView.getSelectedNodes().length) {
311 Roo.MessageBox.alert("Error", "Select an Image");
314 var id = _this.imageView.getNodeData(_this.imageView.getSelectedNodes()[0]).id;
315 _this.imageView.el.mask('Deleting');
318 url : baseURL + '/Roo/Images.php',
323 success : function() {
324 _this.imageView.el.unmask();
325 _this.imageView.loadImages();
327 failure : function() {
328 _this.imageView.el.unmask();
329 Roo.MessageBox.alert("Error", "Error deleting image");
335 text : "Delete File/Image"
341 xtype: 'ContentPanel',
349 actioncomplete : function (_self, action)
351 // only action this will handle is submit?
352 // should test for errors..
353 if (action.failureType) {
354 _this.uploadForm.el.unmask();
355 _this.uploadSending = false;
356 Roo.MessageBox.alert("Error", "Upload Failed");
362 if (action.type =='submit') {
363 _this.uploadForm.reset();
364 _this.uploadSending = false;
365 _this.uploadForm.el.unmask();
366 _this.imageView.loadImages();
371 rendered : function (form)
373 _this.uploadForm = form;
379 style : 'margin: 10px;',
380 url : baseURL + '/Roo/Images.php',
390 fieldLabel : 'Upload Image or File',
392 name : 'imageUpload',
414 xtype: 'LayoutRegion',
418 xtype: 'LayoutRegion',
426 xtype: 'LayoutRegion',
430 xtype: 'LayoutRegion',
439 click : function (_self, e)
450 click : function (_self, e)
455 _this.dialog.el.mask("Saving");
456 _this.form.doAction("submit");