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