DataObjects/Cms_page.php
[Pman.Cms] / Pman.Dialog.CmsProduct.js
index 48790eb..0693f2c 100644 (file)
@@ -33,6 +33,7 @@ Pman.Dialog.CmsProduct = {
             closable : false,
             collapsible : false,
             height : 380,
+            modal : true,
             resizable : false,
             title : "Edit / Create Product",
             width : 700,
@@ -49,7 +50,7 @@ Pman.Dialog.CmsProduct = {
                                 actioncomplete : function(_self,action)
                                 {
                                     if (action.type == 'setdata') {
-                                       _this.dialog.el.mask("Loading");
+                                 
                                        if (_this.data.id) {
                                            _this.dialog.el.mask("Loading");
                                            this.load({ method: 'GET', params: { '_id' : _this.data.id }});
@@ -66,11 +67,16 @@ Pman.Dialog.CmsProduct = {
                                     if (action.type =='submit') {
                                     
                                         _this.dialog.el.unmask();
-                                        _this.dialog.hide();
-                                    
+                                      
+                                        _this.data.id = action.result.data.id;
+                                        _this.form.findField('id').setValue(_this.data.id);
                                          if (_this.callback) {
-                                            _this.callback.call(_this, _this.form.getValues());
+                                            var res = _this.callback.call(_this, _this.form.getValues());
+                                            if (res === false) {
+                                                return;
+                                            }
                                          }
+                                         _this.dialog.hide();
                                          _this.form.reset();
                                          return;
                                     }
@@ -127,6 +133,11 @@ Pman.Dialog.CmsProduct = {
                                         }
                                     ]
                                 },
+                                {
+                                    xtype: 'Hidden',
+                                    xns: Roo.form,
+                                    name : 'category_id'
+                                },
                                 {
                                     xtype: 'Hidden',
                                     xns: Roo.form,
@@ -151,8 +162,9 @@ Pman.Dialog.CmsProduct = {
                              return;
                            }
                            _this.hasUploadWatch =true;
-                             _this.uploadSending =false;
-                               window.setInterval( function() {
+                           _this.uploadSending =false;
+                           window.setInterval( function()
+                            {
                                 var val = _this.uploadForm.findField('imageUpload').getValue();
                                 if (!val || !val.length) {
                                     return;
@@ -161,6 +173,20 @@ Pman.Dialog.CmsProduct = {
                                 if (_this.uploadSending) {
                                     return;
                                 }
+                                
+                                if (!_this.data.id) {
+                                    // trigger a save..
+                                    var cb = _this.callback;
+                                    _this.callback = function() {
+                                        _this.uploadSending = false;
+                                        _this.callback = cb;
+                                        return false;
+                                    }
+                                    _this.uploadSending = true;
+                                     _this.form.doAction("submit");
+                                    return;
+                                }
+                                
                                  _this.uploadSending =true;
                                 _this.uploadForm.findField('onid').setValue(_this.data.id);
                                 _this.uploadForm.el.mask("Sending");
@@ -223,7 +249,12 @@ Pman.Dialog.CmsProduct = {
                                         jsonRoot : 'data',
                                         singleSelect : true,
                                         loadImages : function() {
-                                            if (!_this.data.id) {return; } 
+                                            if (!_this.data.id) {
+                                                 this.clearSelections();
+                                                this.el.update("");
+                                                this.jsonData = [];
+                                                return; 
+                                            } 
                                         
                                            this.load({
                                                 url : baseURL + '/Roo/Images.php',
@@ -296,7 +327,7 @@ Pman.Dialog.CmsProduct = {
                                                       method : 'GET',
                                                       success : function() {
                                                           _this.imageView.el.unmask();
-                                                           _this.imageView.loadImages()
+                                                           _this.imageView.loadImages();
                                                       },
                                                       failure : function() {
                                                            _this.imageView.el.unmask();