{ "id": "roo-file-90", "name": "Pman.Dialog.CmsProduct", "parent": "", "title": "", "path": "/home/alan/gitlive/Pman.Cms/Pman.Dialog.CmsProduct.bjs", "items": [ { "closable": false, "collapsible": false, "height": 380, "modal": true, "resizable": false, "title": "Edit / Create Product", "width": 700, "xtype": "LayoutDialog", "|xns": "Roo", "items": [ { "|xns": "Roo", "xtype": "LayoutRegion", "*prop": "center" }, { "*prop": "east", "width": 300, "xtype": "LayoutRegion", "|xns": "Roo" }, { "region": "center", "xtype": "ContentPanel", "|xns": "Roo", "items": [ { "listeners": { "|actioncomplete": "function(_self,action)\n{\n if (action.type == 'setdata') {\n \n if (_this.data.id) {\n _this.dialog.el.mask(\"Loading\");\n this.load({ method: 'GET', params: { '_id' : _this.data.id }});\n return;\n }\n _this.imageView.loadImages();\n return;\n }\n if (action.type == 'load') {\n _this.imageView.loadImages();\n _this.dialog.el.unmask();\n return;\n }\n if (action.type =='submit') {\n \n _this.dialog.el.unmask();\n \n _this.data.id = action.result.data.id;\n _this.form.findField('id').setValue(_this.data.id);\n if (_this.callback) {\n var res = _this.callback.call(_this, _this.form.getValues());\n if (res === false) {\n return;\n }\n }\n _this.dialog.hide();\n _this.form.reset();\n return;\n }\n}\n", "|rendered": "function (form)\n{\n _this.form= form;\n}\n" }, "method": "POST", "style": "margin:10px;", "xtype": "Form", "|url": "baseURL + '/Roo/Product.php'", "|xns": "Roo.form", "items": [ { "fieldLabel": "Name", "name": "name", "width": 200, "|xns": "Roo.form", "xtype": "TextField" }, { "fieldLabel": "Sku", "name": "sku", "width": 200, "|xns": "Roo.form", "xtype": "TextField" }, { "listeners": { "valid": "function (_self)\n{\n\n}" }, "fieldLabel": "Visible", "name": "visible", "width": 75, "xtype": "Checkbox", "|xns": "Roo.form" }, { "labelAlign": "top", "width": 360, "xtype": "Column", "|xns": "Roo.form", "items": [ { "fieldLabel": "Description", "height": 180, "name": "description", "width": 350, "xtype": "TextArea", "|xns": "Roo.form" } ] }, { "name": "category_id", "xtype": "Hidden", "|xns": "Roo.form" }, { "name": "id", "|xns": "Roo.form", "xtype": "Hidden" } ] } ] }, { "listeners": { "activate": "function (_self)\n{\n //console.log('activate');\n if ( _this.imageView ){ \n _this.imageView.loadImages();\n }\n\n if (_this.hasUploadWatch) {\n return;\n }\n _this.hasUploadWatch =true;\n _this.uploadSending =false;\n window.setInterval( function()\n {\n var val = _this.uploadForm.findField('imageUpload').getValue();\n if (!val || !val.length) {\n return;\n }\n \n if (_this.uploadSending) {\n return;\n }\n \n if (!_this.data.id) {\n // trigger a save..\n var cb = _this.callback;\n _this.callback = function() {\n _this.uploadSending = false;\n _this.callback = cb;\n return false;\n }\n _this.uploadSending = true;\n _this.form.doAction(\"submit\");\n return;\n }\n \n _this.uploadSending =true;\n _this.uploadForm.findField('onid').setValue(_this.data.id);\n _this.uploadForm.el.mask(\"Sending\");\n _this.uploadForm.submit.defer(100, _this.uploadForm);\n \n }, 1000) \n \n}" }, "region": "east", "title": "Images / PDF", "xtype": "NestedLayoutPanel", "|xns": "Roo", "items": [ { "|xns": "Roo", "xtype": "BorderLayout", "*prop": "layout", "items": [ { "*prop": "center", "xtype": "LayoutRegion", "|xns": "Roo", "listeners": {} }, { "*prop": "south", "height": 60, "xtype": "LayoutRegion", "|xns": "Roo" }, { "autoScroll": true, "fitContainer": true, "fitToFrame": true, "region": "center", "xtype": "ContentPanel", "|xns": "Roo", "items": [ { "|xns": "Roo", "xtype": "Toolbar", "*prop": "toolbar", "items": [ { "listeners": { "click": "function (_self, e)\n{\n \n if (!_this.imageView.getSelectedNodes().length) {\n Roo.MessageBox.alert(\"Error\", \"Select an Image\");\n return;\n }\n var n = _this.imageView.getNodeData(_this.imageView.getSelectedNodes()[0]);\n\n // open a new window with this file in..\n Pman.download( {\n url: baseURL + '/Images/Download/' + n.id + '/' + n.filename\n });\n}" }, "text": "Download", "xtype": "Button", "|xns": "Roo.Toolbar" }, { "|xns": "Roo.Toolbar", "xtype": "Fill" }, { "listeners": { "click": "function (_self, e)\n{\n if (!_this.imageView.getSelectedNodes().length) {\n Roo.MessageBox.alert(\"Error\", \"Select an Image\");\n return;\n }\n var id = _this.imageView.getNodeData(_this.imageView.getSelectedNodes()[0]).id;\n _this.imageView.el.mask('Deleting');\n \n Roo.Ajax.request({\n url : baseURL + '/Roo/Images.php',\n params : {\n _delete : id\n },\n method : 'GET',\n success : function() {\n _this.imageView.el.unmask();\n _this.imageView.loadImages();\n },\n failure : function() {\n _this.imageView.el.unmask();\n Roo.MessageBox.alert(\"Error\", \"Error deleting image\");\n return;\n }\n });\n }" }, "text": "Delete File/Image", "xtype": "Button", "|xns": "Roo.Toolbar" } ] }, { "listeners": { "beforerender": "function (_self, data)\n{\n _this.imageView = _self;\n \n if (this.stylesheet) {\n return;\n }\n this.el.addClass('thumb-browser');\n\n \n this.stylesheet = Roo.util.CSS.createStyleSheet(\n {\n '.thumb-browser .thumb-wrap' : {\n border:'3px solid #EEE',\n 'float':'left',\n height:'160px',\n margin:'2px',\n 'padding-left':'5px',\n 'padding-top':'5px',\n width:'160px'\n },\n '.thumb-browser .x-view-selected' : {\n border:'3px solid #333'\n \n }\n\n\n }, Roo.id()\n );\n \n}" }, "jsonRoot": "data", "singleSelect": true, "xtype": "JsonView", "|loadImages": "function() {\n if (!_this.data.id) {\n this.clearSelections();\n this.el.update(\"\");\n this.jsonData = [];\n return; \n } \n\n this.load({\n url : baseURL + '/Roo/Images.php',\n method : 'GET',\n params : {\n ontable : 'Product',\n onid : _this.data.id,\n 'query[imagesize]' : 150\n },\n text : 'Loading'\n });\n \n}\n", "|xns": "Roo", "items": [ { "*prop": "tpl", "xtype": "Template", "|html": "'
' + \n '
' + \n'
'", "|xns": "Roo" } ] } ] }, { "region": "south", "xtype": "ContentPanel", "|xns": "Roo", "items": [ { "listeners": { "actioncomplete": "function (_self, action)\n{\n// only action this will handle is submit?\n// should test for errors..\n if (action.failureType) {\n _this.uploadForm.el.unmask();\n _this.uploadSending = false;\n Roo.MessageBox.alert(\"Error\", \"Upload Failed\");\n return false;\n \n }\n \n \n if (action.type =='submit') {\n _this.uploadForm.reset();\n _this.uploadSending = false;\n _this.uploadForm.el.unmask(); \n _this.imageView.loadImages();\n return;\n }\n \n}", "rendered": "function (form)\n{\n _this.uploadForm = form;\n}" }, "fileUpload": true, "labelAlign": "top", "labelWidth": 150, "style": "margin: 10px;", "xtype": "Form", "|url": "baseURL + '/Roo/Images.php'", "|xns": "Roo.form", "items": [ { "|xns": "Roo.form", "xtype": "Row", "items": [ { "allowBlank": false, "fieldLabel": "Upload Image or File", "inputType": "file", "name": "imageUpload", "width": 250, "xtype": "TextField", "|xns": "Roo.form", "listeners": {} } ] }, { "name": "onid", "xtype": "Hidden", "|xns": "Roo.form" }, { "name": "ontable", "value": "Product", "xtype": "Hidden", "|xns": "Roo.form" } ] } ] } ] } ] }, { "listeners": { "click": "function (_self, e)\n{\n _this.dialog.hide();\n}" }, "*prop": "buttons[]", "text": "Cancel", "xtype": "Button", "|xns": "Roo" }, { "listeners": { "click": "function (_self, e)\n{\n // do some checks?\n \n \n _this.dialog.el.mask(\"Saving\");\n _this.form.doAction(\"submit\");\n\n}" }, "*prop": "buttons[]", "text": "Save", "xtype": "Button", "|xns": "Roo" } ] } ], "permname": "" }