Pman.Tab.CmsProduct.js
[Pman.Cms] / Pman.Tab.CmsProduct.bjs
1 {
2     "id": "roo-file-89",
3     "name": "Pman.Tab.CmsProduct",
4     "parent": "Pman.Tab.CmsProductMgr",
5     "title": "Pman.Tab.CmsProduct",
6     "path": "/home/alan/gitlive/Pman.Cms/Pman.Tab.CmsProduct.bjs",
7     "items": [
8         {
9             "|xns": "Roo",
10             "xtype": "GridPanel",
11             "title": "Product",
12             "fitToframe": true,
13             "fitContainer": true,
14             "tableName": "Product",
15             "background": true,
16             "region": "center",
17             "listeners": {
18                 "|activate": "function() {\n    _this.panel = this;\n    if (_this.grid) {\n        _this.grid.footer.onClick('first');\n    }\n}"
19             },
20             "items": [
21                 {
22                     "listeners": {
23                         "|render": "function() \n{\n    _this.grid = this; \n    _this.dialog = Pman.Dialog.CmsProduct;\n    if (_this.panel.active) {\n       this.footer.onClick('first');\n    }\n}",
24                         "|rowdblclick": "function (_self, rowIndex, e)\n{\n    if (!_this.dialog) return;\n    _this.dialog.show( this.getDataSource().getAt(rowIndex), function() {\n        _this.grid.footer.onClick('first');\n    }); \n}\n"
25                     },
26                     "*prop": "grid",
27                     "autoExpandColumn": "description",
28                     "ddGroup": "products",
29                     "enableDrag": true,
30                     "loadMask": true,
31                     "xtype": "Grid",
32                     "|xns": "Roo.grid",
33                     "items": [
34                         {
35                             "listeners": {
36                                 "beforeload": "function (_self, options)\n{\n    if (!Pman.Tab.CmsProductCategory.panel) {\n        return false;\n    }\n    options.params['query[search]'] =  _this.searchBox.getValue();\n    // category..\n    var sn = Pman.Tab.CmsProductCategory.panel.tree.getSelectionModel().getSelectedNode();\n    if (sn && !isNaN(parseInt(sn.attributes.id))) {\n        options.params.category_id  = sn.attributes.id;\n    }\n    \n}"
37                             },
38                             "*prop": "dataSource",
39                             "remoteSort": true,
40                             "xtype": "Store",
41                             "|sortInfo": "{ field : 'name', direction: 'ASC' }",
42                             "|xns": "Roo.data",
43                             "items": [
44                                 {
45                                     "*prop": "proxy",
46                                     "xtype": "HttpProxy",
47                                     "method": "GET",
48                                     "|url": "baseURL + '/Roo/Product.php'",
49                                     "|xns": "Roo.data"
50                                 },
51                                 {
52                                     "|xns": "Roo.data",
53                                     "xtype": "JsonReader",
54                                     "totalProperty": "total",
55                                     "root": "data",
56                                     "*prop": "reader",
57                                     "id": "id",
58                                     "|fields": "[\n    {\n        'name': 'id',\n        'type': 'int'\n    },\n    {\n        'name': 'name',\n        'type': 'string'\n    },\n    {\n        'name': 'sku',\n        'type': 'string'\n    },\n    {\n        'name': 'price',\n        'type': 'float'\n    },\n    {\n        'name': 'shortdesc',\n        'type': 'string'\n    },\n    {\n        'name': 'description',\n        'type': 'string'\n    },\n    {\n        'name': 'visible',\n        'type': 'int'\n    },\n    {\n        'name': 'itemtypes',\n        'type': 'string'\n    },\n    {\n        'name': 'category_id',\n        'type': 'int'\n    },\n    {\n        'name': 'currency',\n        'type': 'string'\n    },\n    {\n        'name': 'vender_url',\n        'type': 'string'\n    },\n    {\n        'name': 'supplier_id',\n        'type': 'int'\n    }\n]"
59                                 }
60                             ]
61                         },
62                         {
63                             "*prop": "footer",
64                             "xtype": "PagingToolbar",
65                             "pageSize": 25,
66                             "displayInfo": true,
67                             "displayMsg": "Displaying Product{0} - {1} of {2}",
68                             "emptyMsg": "No Product found",
69                             "|xns": "Roo"
70                         },
71                         {
72                             "*prop": "toolbar",
73                             "xtype": "Toolbar",
74                             "|xns": "Roo",
75                             "items": [
76                                 {
77                                     "listeners": {
78                                         "render": "function (_self)\n{\n    _this.searchBox = _self;\n}",
79                                         "specialkey": "function (_self, e)\n{\n  if (e.getKey() == 13) {\n     _this.grid.footer.onClick( 'first' );\n  }\n}"
80                                     },
81                                     "xtype": "TextField",
82                                     "|xns": "Roo.form"
83                                 },
84                                 {
85                                     "listeners": {
86                                         "|click": "function (_self, e)\n{\n_this.grid.footer.onClick('first');\n}"
87                                     },
88                                     "cls": "x-btn-icon",
89                                     "xtype": "Button",
90                                     "|icon": "rootURL + '/Pman/templates/images/search.gif'",
91                                     "|xns": "Roo.Toolbar"
92                                 },
93                                 {
94                                     "listeners": {
95                                         "|click": "function (_self, e)\n{\n_this.searchBox.setValue('');\n    _this.grid.footer.onClick('first');\n}"
96                                     },
97                                     "cls": "x-btn-icon",
98                                     "xtype": "Button",
99                                     "|icon": "rootURL + '/Pman/templates/images/edit-clear.gif'",
100                                     "|xns": "Roo.Toolbar"
101                                 },
102                                 {
103                                     "|xns": "Roo.Toolbar",
104                                     "xtype": "Fill"
105                                 },
106                                 {
107                                     "listeners": {
108                                         "|click": "function()\n{\n    if (!_this.dialog) return;\n    \n      var sel = Pman.Tab.CmsProductCategory.panel.tree.getSelectionModel().getSelectedNode();\n      var id =  (!sel || isNaN(parseInt(sel.attributes.id))) ? 0 : sel.attributes.id;\n      if (!id) {\n         Roo.MessageBox.alert(\"Error\", \"Select a Category to add it to\");\n         return;\n     }\n\n    \n    _this.dialog.show( { id : 0, category_id :id } , function(data) {\n        _this.searchBox.setValue(data.name);\n        _this.grid.footer.onClick('first');\n   }); \n}\n"
109                                     },
110                                     "cls": "x-btn-text-icon",
111                                     "text": "Add",
112                                     "xtype": "Button",
113                                     "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'",
114                                     "|xns": "Roo.Toolbar"
115                                 },
116                                 {
117                                     "text": "Edit",
118                                     "xtype": "Button",
119                                     "cls": "x-btn-text-icon",
120                                     "|icon": "Roo.rootURL + 'images/default/tree/leaf.gif'",
121                                     "listeners": {
122                                         "|click": "function()\n{\n    var s = _this.grid.getSelectionModel().getSelections();\n    if (!s.length || (s.length > 1))  {\n        Roo.MessageBox.alert(\"Error\", s.length ? \"Select only one Row\" : \"Select a Row\");\n        return;\n    }\n    if (!_this.dialog) return;\n    _this.dialog.show(s[0].data, function() {\n        _this.grid.footer.onClick('first');\n    }); \n    \n}\n"
123                                     },
124                                     "|xns": "Roo.Toolbar"
125                                 },
126                                 {
127                                     "text": "Delete",
128                                     "cls": "x-btn-text-icon",
129                                     "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
130                                     "xtype": "Button",
131                                     "listeners": {
132                                         "|click": "function()\n{\n     Pman.genericDelete(_this, 'Product'); \n}\n        "
133                                     },
134                                     "|xns": "Roo.Toolbar"
135                                 }
136                             ]
137                         },
138                         {
139                             "*prop": "colModel[]",
140                             "dataIndex": "id",
141                             "header": "Photo",
142                             "width": 100,
143                             "xtype": "ColumnModel",
144                             "|renderer": "function(v,x,r) {\n    if (!r.json.images.length) {\n        return '';\n    }\n    \n    return String.format('<img height=\"100\" src=\"{0}/Images/Thumb/100x100/{1}/{2}\">',\n        baseURL , r.json.images[0].id,r.json.images[0].filename ); }",
145                             "|xns": "Roo.grid"
146                         },
147                         {
148                             "*prop": "colModel[]",
149                             "dataIndex": "category_id_title",
150                             "header": "Category",
151                             "width": 75,
152                             "xtype": "ColumnModel",
153                             "|renderer": "function(v) { return String.format('{0}', v); }",
154                             "|xns": "Roo.grid",
155                             "sortable": true,
156                             "listeners": {}
157                         },
158                         {
159                             "*prop": "colModel[]",
160                             "dataIndex": "name",
161                             "header": "Name",
162                             "sortable": true,
163                             "width": 200,
164                             "xtype": "ColumnModel",
165                             "|renderer": "function(v) { return String.format('{0}', v); }",
166                             "|xns": "Roo.grid"
167                         },
168                         {
169                             "*prop": "colModel[]",
170                             "dataIndex": "sku",
171                             "header": "Sku",
172                             "width": 200,
173                             "xtype": "ColumnModel",
174                             "|renderer": "function(v) { return String.format('{0}', v); }",
175                             "|xns": "Roo.grid",
176                             "sortable": true,
177                             "listeners": {}
178                         },
179                         {
180                             "*prop": "colModel[]",
181                             "dataIndex": "description",
182                             "header": "Description",
183                             "sortable": true,
184                             "width": 200,
185                             "xtype": "ColumnModel",
186                             "|renderer": "function(v) { return String.format('{0}', v); }",
187                             "|xns": "Roo.grid"
188                         },
189                         {
190                             "*prop": "colModel[]",
191                             "dataIndex": "visible",
192                             "header": "Visible",
193                             "sortable": true,
194                             "width": 75,
195                             "xtype": "ColumnModel",
196                             "|renderer": "function(v) { return String.format('{0}', v); }",
197                             "|xns": "Roo.grid"
198                         }
199                     ]
200                 }
201             ]
202         }
203     ],
204     "permname": "Cms.Products"
205 }