Pman.Dialog.CmsBlog.bjs
[Pman.Cms] / Pman.Dialog.CmsProduct.bjs
1 {
2     "id": "roo-file-60",
3     "name": "Pman.Dialog.CmsProduct",
4     "parent": "",
5     "title": "",
6     "path": "/home/edward/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        _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",
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": "category_id",
88                                     "xtype": "Hidden",
89                                     "|xns": "Roo.form"
90                                 },
91                                 {
92                                     "name": "id",
93                                     "|xns": "Roo.form",
94                                     "xtype": "Hidden"
95                                 }
96                             ]
97                         }
98                     ]
99                 },
100                 {
101                     "listeners": {
102                         "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}"
103                     },
104                     "region": "east",
105                     "title": "Images / PDF",
106                     "xtype": "NestedLayoutPanel",
107                     "|xns": "Roo",
108                     "items": [
109                         {
110                             "|xns": "Roo",
111                             "xtype": "BorderLayout",
112                             "*prop": "layout",
113                             "items": [
114                                 {
115                                     "*prop": "center",
116                                     "xtype": "LayoutRegion",
117                                     "|xns": "Roo",
118                                     "listeners": {}
119                                 },
120                                 {
121                                     "*prop": "south",
122                                     "height": 60,
123                                     "xtype": "LayoutRegion",
124                                     "|xns": "Roo"
125                                 },
126                                 {
127                                     "autoScroll": true,
128                                     "fitContainer": true,
129                                     "fitToFrame": true,
130                                     "region": "center",
131                                     "xtype": "ContentPanel",
132                                     "|xns": "Roo",
133                                     "items": [
134                                         {
135                                             "|xns": "Roo",
136                                             "xtype": "Toolbar",
137                                             "*prop": "toolbar",
138                                             "items": [
139                                                 {
140                                                     "listeners": {
141                                                         "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}"
142                                                     },
143                                                     "text": "Download",
144                                                     "xtype": "Button",
145                                                     "|xns": "Roo.Toolbar"
146                                                 },
147                                                 {
148                                                     "|xns": "Roo.Toolbar",
149                                                     "xtype": "Fill"
150                                                 },
151                                                 {
152                                                     "listeners": {
153                                                         "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 }"
154                                                     },
155                                                     "text": "Delete File/Image",
156                                                     "xtype": "Button",
157                                                     "|xns": "Roo.Toolbar"
158                                                 }
159                                             ]
160                                         },
161                                         {
162                                             "listeners": {
163                                                 "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}"
164                                             },
165                                             "jsonRoot": "data",
166                                             "singleSelect": true,
167                                             "xtype": "JsonView",
168                                             "|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",
169                                             "|xns": "Roo",
170                                             "items": [
171                                                 {
172                                                     "*prop": "tpl",
173                                                     "xtype": "Template",
174                                                     "|html": "'<div class=\"thumb-wrap\"> ' + \n  '<div class=\"thumb\"><img  src=\"'+ baseURL + '/Images/Thumb/150/{id}/{filename}\" class=\"thumb-img\"></div>' + \n'</div>'",
175                                                     "|xns": "Roo"
176                                                 }
177                                             ]
178                                         }
179                                     ]
180                                 },
181                                 {
182                                     "region": "south",
183                                     "xtype": "ContentPanel",
184                                     "|xns": "Roo",
185                                     "items": [
186                                         {
187                                             "listeners": {
188                                                 "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}",
189                                                 "rendered": "function (form)\n{\n  _this.uploadForm = form;\n}"
190                                             },
191                                             "fileUpload": true,
192                                             "labelAlign": "top",
193                                             "labelWidth": 150,
194                                             "style": "margin: 10px;",
195                                             "xtype": "Form",
196                                             "|url": "baseURL + '/Roo/Images.php'",
197                                             "|xns": "Roo.form",
198                                             "items": [
199                                                 {
200                                                     "|xns": "Roo.form",
201                                                     "xtype": "Row",
202                                                     "items": [
203                                                         {
204                                                             "allowBlank": false,
205                                                             "fieldLabel": "Upload Image or File",
206                                                             "inputType": "file",
207                                                             "name": "imageUpload",
208                                                             "width": 250,
209                                                             "xtype": "TextField",
210                                                             "|xns": "Roo.form",
211                                                             "listeners": {}
212                                                         }
213                                                     ]
214                                                 },
215                                                 {
216                                                     "name": "onid",
217                                                     "xtype": "Hidden",
218                                                     "|xns": "Roo.form"
219                                                 },
220                                                 {
221                                                     "name": "ontable",
222                                                     "value": "Product",
223                                                     "xtype": "Hidden",
224                                                     "|xns": "Roo.form"
225                                                 }
226                                             ]
227                                         }
228                                     ]
229                                 }
230                             ]
231                         }
232                     ]
233                 },
234                 {
235                     "listeners": {
236                         "click": "function (_self, e)\n{\n    _this.dialog.hide();\n}"
237                     },
238                     "*prop": "buttons[]",
239                     "text": "Cancel",
240                     "xtype": "Button",
241                     "|xns": "Roo"
242                 },
243                 {
244                     "listeners": {
245                         "click": "function (_self, e)\n{\n    // do some checks?\n     \n    \n    _this.dialog.el.mask(\"Saving\");\n    _this.form.doAction(\"submit\");\n\n}"
246                     },
247                     "*prop": "buttons[]",
248                     "text": "Save",
249                     "xtype": "Button",
250                     "|xns": "Roo"
251                 }
252             ]
253         }
254     ],
255     "permname": "",
256     "modOrder": "001"
257 }