Pman.Dialog.CmsProduct.bjs
[Pman.Cms] / Pman.Dialog.CmsProduct.bjs
1 {
2     "id": "roo-file-114",
3     "name": "Pman.Dialog.CmsProduct",
4     "parent": "",
5     "title": "",
6     "path": "/home/alan/gitlive/Pman.Cms/Pman.Dialog.CmsProduct.bjs",
7     "items": [
8         {
9             "closable": false,
10             "collapsible": false,
11             "height": 380,
12             "modal": true,
13             "resizable": false,
14             "title": "Edit / Create Product",
15             "width": 700,
16             "xtype": "LayoutDialog",
17             "|xns": "Roo",
18             "items": [
19                 {
20                     "|xns": "Roo",
21                     "xtype": "LayoutRegion",
22                     "*prop": "center"
23                 },
24                 {
25                     "*prop": "east",
26                     "width": 300,
27                     "xtype": "LayoutRegion",
28                     "|xns": "Roo"
29                 },
30                 {
31                     "region": "center",
32                     "xtype": "ContentPanel",
33                     "|xns": "Roo",
34                     "items": [
35                         {
36                             "listeners": {
37                                 "|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         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",
38                                 "|rendered": "function (form)\n{\n    _this.form= form;\n}\n"
39                             },
40                             "method": "POST",
41                             "style": "margin:10px;",
42                             "xtype": "Form",
43                             "|url": "baseURL + '/Roo/Product.php'",
44                             "|xns": "Roo.form",
45                             "items": [
46                                 {
47                                     "fieldLabel": "Name",
48                                     "name": "name",
49                                     "width": 200,
50                                     "|xns": "Roo.form",
51                                     "xtype": "TextField"
52                                 },
53                                 {
54                                     "fieldLabel": "Sku",
55                                     "name": "sku",
56                                     "width": 200,
57                                     "|xns": "Roo.form",
58                                     "xtype": "TextField"
59                                 },
60                                 {
61                                     "listeners": {
62                                         "valid": "function (_self)\n{\n\n}"
63                                     },
64                                     "fieldLabel": "Visible",
65                                     "name": "visible",
66                                     "width": 75,
67                                     "xtype": "Checkbox",
68                                     "|xns": "Roo.form"
69                                 },
70                                 {
71                                     "labelAlign": "top",
72                                     "width": 360,
73                                     "xtype": "Column",
74                                     "|xns": "Roo.form",
75                                     "items": [
76                                         {
77                                             "fieldLabel": "Description",
78                                             "height": 180,
79                                             "name": "description",
80                                             "width": 350,
81                                             "xtype": "TextArea",
82                                             "|xns": "Roo.form"
83                                         }
84                                     ]
85                                 },
86                                 {
87                                     "name": "id",
88                                     "|xns": "Roo.form",
89                                     "xtype": "Hidden"
90                                 }
91                             ]
92                         }
93                     ]
94                 },
95                 {
96                     "listeners": {
97                         "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}"
98                     },
99                     "region": "east",
100                     "title": "Images / PDF",
101                     "xtype": "NestedLayoutPanel",
102                     "|xns": "Roo",
103                     "items": [
104                         {
105                             "|xns": "Roo",
106                             "xtype": "BorderLayout",
107                             "*prop": "layout",
108                             "items": [
109                                 {
110                                     "*prop": "center",
111                                     "xtype": "LayoutRegion",
112                                     "|xns": "Roo",
113                                     "listeners": {}
114                                 },
115                                 {
116                                     "*prop": "south",
117                                     "height": 60,
118                                     "xtype": "LayoutRegion",
119                                     "|xns": "Roo"
120                                 },
121                                 {
122                                     "autoScroll": true,
123                                     "fitContainer": true,
124                                     "fitToFrame": true,
125                                     "region": "center",
126                                     "xtype": "ContentPanel",
127                                     "|xns": "Roo",
128                                     "items": [
129                                         {
130                                             "|xns": "Roo",
131                                             "xtype": "Toolbar",
132                                             "*prop": "toolbar",
133                                             "items": [
134                                                 {
135                                                     "listeners": {
136                                                         "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}"
137                                                     },
138                                                     "text": "Download",
139                                                     "xtype": "Button",
140                                                     "|xns": "Roo.Toolbar"
141                                                 },
142                                                 {
143                                                     "|xns": "Roo.Toolbar",
144                                                     "xtype": "Fill"
145                                                 },
146                                                 {
147                                                     "listeners": {
148                                                         "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 }"
149                                                     },
150                                                     "text": "Delete File/Image",
151                                                     "xtype": "Button",
152                                                     "|xns": "Roo.Toolbar"
153                                                 }
154                                             ]
155                                         },
156                                         {
157                                             "listeners": {
158                                                 "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}"
159                                             },
160                                             "jsonRoot": "data",
161                                             "singleSelect": true,
162                                             "xtype": "JsonView",
163                                             "|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",
164                                             "|xns": "Roo",
165                                             "items": [
166                                                 {
167                                                     "*prop": "tpl",
168                                                     "xtype": "Template",
169                                                     "|html": "'<div class=\"thumb-wrap\"> ' + \n  '<div class=\"thumb\"><img  src=\"'+ baseURL + '/Images/Thumb/150/{id}/{filename}\" class=\"thumb-img\"></div>' + \n'</div>'",
170                                                     "|xns": "Roo"
171                                                 }
172                                             ]
173                                         }
174                                     ]
175                                 },
176                                 {
177                                     "region": "south",
178                                     "xtype": "ContentPanel",
179                                     "|xns": "Roo",
180                                     "items": [
181                                         {
182                                             "listeners": {
183                                                 "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}",
184                                                 "rendered": "function (form)\n{\n  _this.uploadForm = form;\n}"
185                                             },
186                                             "fileUpload": true,
187                                             "labelAlign": "top",
188                                             "labelWidth": 150,
189                                             "style": "margin: 10px;",
190                                             "xtype": "Form",
191                                             "|url": "baseURL + '/Roo/Images.php'",
192                                             "|xns": "Roo.form",
193                                             "items": [
194                                                 {
195                                                     "|xns": "Roo.form",
196                                                     "xtype": "Row",
197                                                     "items": [
198                                                         {
199                                                             "allowBlank": false,
200                                                             "fieldLabel": "Upload Image or File",
201                                                             "inputType": "file",
202                                                             "name": "imageUpload",
203                                                             "width": 250,
204                                                             "xtype": "TextField",
205                                                             "|xns": "Roo.form",
206                                                             "listeners": {}
207                                                         }
208                                                     ]
209                                                 },
210                                                 {
211                                                     "name": "onid",
212                                                     "xtype": "Hidden",
213                                                     "|xns": "Roo.form"
214                                                 },
215                                                 {
216                                                     "name": "ontable",
217                                                     "value": "Product",
218                                                     "xtype": "Hidden",
219                                                     "|xns": "Roo.form"
220                                                 }
221                                             ]
222                                         }
223                                     ]
224                                 }
225                             ]
226                         }
227                     ]
228                 },
229                 {
230                     "listeners": {
231                         "click": "function (_self, e)\n{\n    _this.dialog.hide();\n}"
232                     },
233                     "*prop": "buttons[]",
234                     "text": "Cancel",
235                     "xtype": "Button",
236                     "|xns": "Roo"
237                 },
238                 {
239                     "listeners": {
240                         "click": "function (_self, e)\n{\n    // do some checks?\n     \n    \n    _this.dialog.el.mask(\"Saving\");\n    _this.form.doAction(\"submit\");\n\n}"
241                     },
242                     "*prop": "buttons[]",
243                     "text": "Save",
244                     "xtype": "Button",
245                     "|xns": "Roo"
246                 }
247             ]
248         }
249     ]
250 }