pulldown js error
[Pman.Admin] / Pman.Tab.AdminEnum.bjs
1 {
2     "name" : "Pman.Tab.AdminEnum",
3     "parent" : "Pman.Tab.Admin",
4     "title" : "Pman.Tab.AdminEnum",
5     "path" : "/home/michael/gitlive/Pman.Admin/Pman.Tab.AdminEnum.bjs",
6     "permname" : "",
7     "modOrder" : "500",
8     "items" : [
9         {
10             "xtype" : "NestedLayoutPanel",
11             "$ xns" : "Roo",
12             "String region" : "center",
13             "String title" : "Pulldown Options",
14             "items" : [
15                 {
16                     "xtype" : "BorderLayout",
17                     "$ xns" : "Roo",
18                     "* prop" : "layout",
19                     "items" : [
20                         {
21                             "Number width" : 200,
22                             "xtype" : "LayoutRegion",
23                             "$ xns" : "Roo",
24                             "* prop" : "west",
25                             "Boolean split" : true
26                         },
27                         {
28                             "xtype" : "LayoutRegion",
29                             "$ xns" : "Roo",
30                             "* prop" : "center"
31                         },
32                         {
33                             "listeners" : {
34                                 "|activate" : "function() {\n    _this.epanel = this;\n    if (_this.egrid) {\n        _this.egrid.footer.onClick('first');\n    }\n}"
35                             },
36                             "background" : false,
37                             "region" : "west",
38                             "title" : "Pulldown Options",
39                             "xtype" : "GridPanel",
40                             "$ xns" : "Roo",
41                             "tableName" : "core_enum",
42                             "items" : [
43                                 {
44                                     "listeners" : {
45                                         "beforeedit" : "function (e)\n{\n    if(e.field == 'name' && e.record.data.is_system_enum*1 == 1){\n        return false;\n    }\n}",
46                                         "cellclick" : "function (_self, rowIndex, columnIndex, e)\n{\n\n        var di = this.colModel.getDataIndex(columnIndex);\n        if (di != 'active') {\n            return;\n        }\n         \n        var rec = _this.grid.ds.getAt(rowIndex);\n        \n        rec.set('active', rec.data.active ? 0 : 1);\n        rec.commit();\n         \n        \n}",
47                                         "|render" : "function() \n{\n    _this.egrid = this; \n    //_this.dialog = Pman.Dialog.FILL_IN\n    if (_this.epanel.active) {\n       this.footer.onClick('first');\n    }\n}",
48                                         "celldblclick" : "function (_self, rowIndex, columnIndex, e)\n{\n    var rec = _this.egrid.ds.getAt(rowIndex);\n    Pman.Dialog.AdminEnumType.show(rec.data,function(){\n        \n        _this.egrid.footer.onClick('first');\n    });\n}",
49                                         "afteredit" : "function (e)\n{\n   e.record.commit();     \n}"
50                                     },
51                                     "autoExpandColumn" : "display_name",
52                                     "xtype" : "EditorGrid",
53                                     "loadMask" : true,
54                                     "clicksToEdit" : 1,
55                                     "$ xns" : "Roo.grid",
56                                     "* prop" : "grid",
57                                     "items" : [
58                                         {
59                                             "listeners" : {
60                                                 "update" : "function (_self, record, operation)\n{\n    if (operation != Roo.data.Record.COMMIT) {\n        return;\n    }\n    // got commit..\n    new Pman.Request({\n        url : baseURL + '/Roo/Core_enum.php',\n        method : 'POST',\n        params : {\n            id : record.data.id,\n            etype : _this.grid.ds.getById(record.id).data.etype,\n            name : record.data.name,\n            active : record.data.active,\n            seqid : record.data.seqid,\n            display_name : record.data.display_name\n        }, \n        success : function(res) {\n            //Roo.log(data);\n            // update the ID if it's not set..\n            if (record.data.id * 1 < 1) {\n                record.set('id', res.data.id);\n            }\n        }\n    });\n    \n}",
61                                                 "beforeload" : "function (_self, o)\n{\n    o.params['query[empty_etype]'] = 1; \n  \n}"
62                                             },
63                                             "xtype" : "Store",
64                                             "remoteSort" : true,
65                                             "$ sortInfo" : "{ field : 'etype', direction: 'ASC' }",
66                                             "$ xns" : "Roo.data",
67                                             "* prop" : "dataSource",
68                                             "items" : [
69                                                 {
70                                                     "$ url" : "baseURL + '/Roo/core_enum.php'",
71                                                     "xtype" : "HttpProxy",
72                                                     "method" : "GET",
73                                                     "$ xns" : "Roo.data",
74                                                     "* prop" : "proxy"
75                                                 },
76                                                 {
77                                                     "id" : "id",
78                                                     "root" : "data",
79                                                     "xtype" : "JsonReader",
80                                                     "$ xns" : "Roo.data",
81                                                     "$ fields" : "[\n    {\n        'name': 'id',\n        'type': 'int'\n    },\n    {\n        'name': 'etype',\n        'type': 'string'\n    },\n    {\n        'name': 'name',\n        'type': 'string'\n    },\n    {\n        'name': 'active',\n        'type': 'int'\n    },\n    {\n        'name': 'seqid',\n        'type': 'int'\n    }\n]",
82                                                     "* prop" : "reader",
83                                                     "totalProperty" : "total"
84                                                 }
85                                             ]
86                                         },
87                                         {
88                                             "listeners" : {
89                                                 "selectionchange" : "function (_self, selection)\n{\n    _this.grid.footer.onClick('first');\n}"
90                                             },
91                                             "xtype" : "CellSelectionModel",
92                                             "$ xns" : "Roo.grid",
93                                             "* prop" : "sm"
94                                         },
95                                         {
96                                             "pageSize" : 100,
97                                             "xtype" : "PagingToolbar",
98                                             "emptyMsg" : "No core_enum found",
99                                             "$ xns" : "Roo",
100                                             "displayInfo" : false,
101                                             "displayMsg" : " ",
102                                             "* prop" : "footer"
103                                         },
104                                         {
105                                             "xtype" : "Toolbar",
106                                             "$ xns" : "Roo",
107                                             "* prop" : "toolbar",
108                                             "items" : [
109                                                 {
110                                                     "listeners" : {
111                                                         "|click" : "function()\n{\n    \n    Roo.MessageBox.prompt (\"Create a new Enum type\",\n        \"Enter the name for a new enum type, \" + \n        \"this is only relivant if you  know how it is going to be used\",\n        function(btn,txt) {\n            if (btn != 'ok') {\n                return; \n            }\n            new Pman.Request({\n                url : baseURL + '/Roo/Core_enum.php',\n                method : 'POST',\n                params : {\n                    etype : '',\n                    name : txt,\n                    active : 1\n                }, \n                success : function() {\n                    Roo.MessageBox.alert(\"Created\", \"You can now select it from the type list on the left\");\n                }\n            });\n                    \n            \n             \n             \n        }\n    ); \n         \n         \n\n}\n"
112                                                     },
113                                                     "text" : "Add new pulldown list",
114                                                     "xtype" : "Button",
115                                                     "cls" : "x-btn-text-icon",
116                                                     "$ icon" : "Roo.rootURL + 'images/default/dd/drop-add.gif'",
117                                                     "$ xns" : "Roo.Toolbar"
118                                                 }
119                                             ]
120                                         },
121                                         {
122                                             "xtype" : "ColumnModel",
123                                             "header" : "Pulldown",
124                                             "width" : 200,
125                                             "$ renderer" : "function(v,x,r) { \n\n\n    return String.format('<span qtip=\"{1}\">{0}</span>', (''+v).length ? v : r.data.name, r.data.name); \n}",
126                                             "$ xns" : "Roo.grid",
127                                             "* prop" : "colModel[]",
128                                             "dataIndex" : "display_name"
129                                         },
130                                         {
131                                             "xtype" : "ColumnModel",
132                                             "header" : "Active",
133                                             "width" : 50,
134                                             "$ renderer" : "function(v) {  \n    var state = v> 0 ?  '-checked' : '';\n\n    return '<img class=\"x-grid-check-icon' + state + '\" src=\"' + Roo.BLANK_IMAGE_URL + '\"/>';\n                \n }",
135                                             "$ xns" : "Roo.grid",
136                                             "* prop" : "colModel[]",
137                                             "dataIndex" : "active"
138                                         }
139                                     ]
140                                 }
141                             ]
142                         },
143                         {
144                             "listeners" : {
145                                 "|activate" : "function() {\n    _this.panel = this;\n    if (_this.grid) {\n        _this.grid.footer.onClick('first');\n    }\n}"
146                             },
147                             "fitToframe" : true,
148                             "background" : false,
149                             "region" : "center",
150                             "title" : "Pulldown Options",
151                             "xtype" : "GridPanel",
152                             "$ xns" : "Roo",
153                             "tableName" : "core_enum",
154                             "items" : [
155                                 {
156                                     "listeners" : {
157                                         "beforeedit" : "function (e)\n{\n    if(e.field == 'name' && e.record.data.is_system_enum*1 == 1){\n        return false;\n    }\n}",
158                                         "|render" : "function() \n{\n    _this.grid = this; \n    //_this.dialog = Pman.Dialog.FILL_IN\n    if (_this.panel.active) {\n       this.footer.onClick('first');\n    }\n}",
159                                         "cellclick" : "function (_self, rowIndex, columnIndex, e)\n{\n\n        var di = this.colModel.getDataIndex(columnIndex);\n        if (di != 'active') {\n            return;\n        }\n         \n        var rec = _this.grid.ds.getAt(rowIndex);\n        \n        rec.set('active', rec.data.active ? 0 : 1);\n        rec.commit();\n         \n        \n}",
160                                         "afteredit" : "function (e)\n{\n   e.record.commit();     \n}"
161                                     },
162                                     "autoExpandColumn" : "display_name",
163                                     "xtype" : "EditorGrid",
164                                     "loadMask" : true,
165                                     "clicksToEdit" : 1,
166                                     "$ xns" : "Roo.grid",
167                                     "* prop" : "grid",
168                                     "items" : [
169                                         {
170                                             "listeners" : {
171                                                 "update" : "function (_self, record, operation)\n{\n    if (operation != Roo.data.Record.COMMIT) {\n        return;\n    }\n    // got commit..\n    new Pman.Request({\n        url : baseURL + '/Roo/Core_enum.php',\n        method : 'POST',\n        params : {\n            id : record.data.id,\n            etype : _this.grid.ds.getById(record.id).data.etype,\n            name : record.data.name,\n            active : record.data.active,\n            seqid : record.data.seqid,\n            display_name : record.data.display_name\n        }, \n        success : function(res) {\n            //Roo.log(data);\n            // update the ID if it's not set..\n            if (record.data.id * 1 < 1) {\n                record.set('id', res.data.id);\n            }\n        }\n    });\n    \n}",
172                                                 "beforeload" : "function (_self, options)\n{\n\n    var s =     _this.egrid.getSelectionModel().getSelectedCell();\n    \n\n    if (!s) {\n        return false;\n    }\n    var d = _this.egrid.dataSource.getAt(s[0]);\n    \n    options.params.etype = d.data.name;\n    if (!options.params.etype.length) {\n        return false;\n    }\n}"
173                                             },
174                                             "xtype" : "Store",
175                                             "remoteSort" : true,
176                                             "$ sortInfo" : "{ field : 'etype', direction: 'ASC' }",
177                                             "$ xns" : "Roo.data",
178                                             "* prop" : "dataSource",
179                                             "items" : [
180                                                 {
181                                                     "$ url" : "baseURL + '/Roo/core_enum.php'",
182                                                     "method" : "GET",
183                                                     "xtype" : "HttpProxy",
184                                                     "$ xns" : "Roo.data",
185                                                     "* prop" : "proxy"
186                                                 },
187                                                 {
188                                                     "id" : "id",
189                                                     "root" : "data",
190                                                     "xtype" : "JsonReader",
191                                                     "$ xns" : "Roo.data",
192                                                     "$ fields" : "[\n    {\n        'name': 'id',\n        'type': 'int'\n    },\n    {\n        'name': 'etype',\n        'type': 'string'\n    },\n    {\n        'name': 'name',\n        'type': 'string'\n    },\n    {\n        'name': 'active',\n        'type': 'int'\n    },\n    {\n        'name': 'seqid',\n        'type': 'int'\n    }\n]",
193                                                     "* prop" : "reader",
194                                                     "totalProperty" : "total"
195                                                 }
196                                             ]
197                                         },
198                                         {
199                                             "pageSize" : 25,
200                                             "xtype" : "PagingToolbar",
201                                             "emptyMsg" : "No core_enum found",
202                                             "$ xns" : "Roo",
203                                             "displayInfo" : true,
204                                             "displayMsg" : "Displaying core_enum{0} - {1} of {2}",
205                                             "* prop" : "footer",
206                                             "items" : [
207                                                 {
208                                                     "listeners" : {
209                                                         "click" : "function (_self, e)\n{\n    new Pman.Download({\n        grid : _this.grid\n    });\n    Roo.MessageBox.alert(\"Downloading\", \"File is downloading\");\n}"
210                                                     },
211                                                     "text" : "Download",
212                                                     "xtype" : "Button",
213                                                     "$ xns" : "Roo.Toolbar"
214                                                 },
215                                                 {
216                                                     "listeners" : {
217                                                         "click" : "function (_self, e)\n{\n\n  var s =     _this.egrid.getSelectionModel().getSelectedCell();\n    \n\n    if (!s) {\n        Roo.MessageBox.alert(\"Error\", \"Select a pulldown\");\n    }\n    \n    var d = _this.egrid.dataSource.getAt(s[0]);\n \n\n    var etype = d.data.name;\n    \n    if(!etype.length){\n        Roo.MessageBox.alert('Error', 'Please select a pulldown');\n        return;\n    }\n    \n    Pman.Dialog.Image.show(\n       {\n            _url : baseURL+'/Xtuple/Import/Enum?' + Roo.urlEncode({'etype' : etype})\n        \n       },\n       function () {\n            _this.grid.footer.onClick('first');\n       }\n   );\n}"
218                                                     },
219                                                     "text" : "Upload Value",
220                                                     "xtype" : "Button",
221                                                     "$ xns" : "Roo.Toolbar"
222                                                 }
223                                             ]
224                                         },
225                                         {
226                                             "xtype" : "Toolbar",
227                                             "$ xns" : "Roo",
228                                             "* prop" : "toolbar",
229                                             "items" : [
230                                                 {
231                                                     "listeners" : {
232                                                         "|click" : "function()\n{\n    \n    // if we do not have a selected type... - what should we show..?\n    \n    \n    var s =     _this.egrid.getSelectionModel().getSelectedCell();\n    \n\n    if (!s) {\n        Roo.MessageBox.alert(\"Error\", \"Select a pulldown\");\n    }\n    \n    var d = _this.egrid.dataSource.getAt(s[0]);\n \n\n    var ds = _this.grid.getDataSource();\n\n    var add = ds.reader.newRow({    \n             id: 0, \n             display_name : '', \n             name : '', \n             etype: d.data.name, \n             active: 1, \n             seqid: 0\n      });\n     var r = ds.data.length;\n    ds.insert(r  , add);  \n    _this.grid.startEditing(r, 1); // name... \n}\n"
233                                                     },
234                                                     "text" : "Add Value",
235                                                     "xtype" : "Button",
236                                                     "cls" : "x-btn-text-icon",
237                                                     "$ icon" : "Roo.rootURL + 'images/default/dd/drop-add.gif'",
238                                                     "$ xns" : "Roo.Toolbar"
239                                                 },
240                                                 {
241                                                     "listeners" : {
242                                                         "|click" : "function()\n{\n    \n    // if we do not have a selected type... - what should we show..?\n    var et = _this.etypeCombo.getValue();\n    \n    if (!et) {\n        Roo.MessageBox.alert(\"Error\", \"Select a pulldown\");\n        return;\n    }\n    var sc = _this.grid.getSelectionModel().getSelectedCell();\n    Roo.log(sc);\n    var ds = _this.grid.ds.getAt(sc[0]);\n    if (!ds) {\n        Roo.MessageBox.alert(\"Error\", \"Select enum\");\n        return;\n    }\n    \n    Roo.log(ds);\n    Pman.Dialog.AdminEnumImages.show({onid:ds.data.id}, function(){\n        _this.grid.footer.onClick('first');\n    });\n    \n}\n"
243                                                     },
244                                                     "text" : "Add Image",
245                                                     "xtype" : "Button",
246                                                     "cls" : "x-btn-text-icon",
247                                                     "$ icon" : "Roo.rootURL + 'images/default/dd/drop-add.gif'",
248                                                     "$ xns" : "Roo.Toolbar"
249                                                 }
250                                             ]
251                                         },
252                                         {
253                                             "xtype" : "ColumnModel",
254                                             "width" : 75,
255                                             "header" : "Internal #",
256                                             "$ renderer" : "function(v) { return String.format('{0}', v); }",
257                                             "$ xns" : "Roo.grid",
258                                             "* prop" : "colModel[]",
259                                             "dataIndex" : "id"
260                                         },
261                                         {
262                                             "xtype" : "ColumnModel",
263                                             "width" : 75,
264                                             "header" : "Image",
265                                             "$ renderer" : "function(v,x,r) { return String.format('<img src=\"{0}/Images/Thumb/25/{1}/{2}\" width=\"25\" height=\"25\">', baseURL, v, r.data.images_id_filename); }",
266                                             "$ xns" : "Roo.grid",
267                                             "* prop" : "colModel[]",
268                                             "dataIndex" : "images_id_id"
269                                         },
270                                         {
271                                             "xtype" : "ColumnModel",
272                                             "header" : "Name",
273                                             "width" : 200,
274                                             "$ renderer" : "function(v) { return String.format('{0}', v); }",
275                                             "$ xns" : "Roo.grid",
276                                             "* prop" : "colModel[]",
277                                             "dataIndex" : "name",
278                                             "items" : [
279                                                 {
280                                                     "xtype" : "GridEditor",
281                                                     "$ xns" : "Roo.grid",
282                                                     "* prop" : "editor",
283                                                     "items" : [
284                                                         {
285                                                             "xtype" : "TextField",
286                                                             "$ xns" : "Roo.form",
287                                                             "* prop" : "field"
288                                                         }
289                                                     ]
290                                                 }
291                                             ]
292                                         },
293                                         {
294                                             "xtype" : "ColumnModel",
295                                             "width" : 200,
296                                             "header" : "Display Name",
297                                             "$ renderer" : "function(v) { return String.format('{0}', v); }",
298                                             "$ xns" : "Roo.grid",
299                                             "* prop" : "colModel[]",
300                                             "dataIndex" : "display_name",
301                                             "items" : [
302                                                 {
303                                                     "xtype" : "GridEditor",
304                                                     "$ xns" : "Roo.grid",
305                                                     "* prop" : "editor",
306                                                     "items" : [
307                                                         {
308                                                             "xtype" : "TextField",
309                                                             "$ xns" : "Roo.form",
310                                                             "* prop" : "field"
311                                                         }
312                                                     ]
313                                                 }
314                                             ]
315                                         },
316                                         {
317                                             "xtype" : "ColumnModel",
318                                             "width" : 75,
319                                             "header" : "Active",
320                                             "$ renderer" : "function(v) {  \n    var state = v> 0 ?  '-checked' : '';\n\n    return '<img class=\"x-grid-check-icon' + state + '\" src=\"' + Roo.BLANK_IMAGE_URL + '\"/>';\n                \n }",
321                                             "$ xns" : "Roo.grid",
322                                             "* prop" : "colModel[]",
323                                             "dataIndex" : "active"
324                                         },
325                                         {
326                                             "xtype" : "ColumnModel",
327                                             "sortable" : true,
328                                             "header" : "Order #",
329                                             "width" : 75,
330                                             "$ renderer" : "function(v) { return String.format('{0}', v); }",
331                                             "$ xns" : "Roo.grid",
332                                             "* prop" : "colModel[]",
333                                             "dataIndex" : "seqid",
334                                             "items" : [
335                                                 {
336                                                     "xtype" : "GridEditor",
337                                                     "$ xns" : "Roo.grid",
338                                                     "* prop" : "editor",
339                                                     "items" : [
340                                                         {
341                                                             "allowNegative" : true,
342                                                             "xtype" : "NumberField",
343                                                             "allowDecimals" : false,
344                                                             "decimalPrecision" : 0,
345                                                             "$ xns" : "Roo.form",
346                                                             "* prop" : "field"
347                                                         }
348                                                     ]
349                                                 }
350                                             ]
351                                         }
352                                     ]
353                                 }
354                             ]
355                         }
356                     ]
357                 }
358             ]
359         }
360     ]
361 }