Pman.Tab.AdminEnum.bjs
[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    var data = {\n        active:1,\n        display_name:'',\n        etype:'',\n        name:''\n    };\n    Pman.Dialog.AdminEnumType.show(data,function(){\n        \n        _this.egrid.footer.onClick('first');\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                             "background" : false,
148                             "region" : "center",
149                             "fitToframe" : true,
150                             "title" : "Pulldown Options",
151                             "xtype" : "GridPanel",
152                             "$ xns" : "Roo",
153                             "tableName" : "core_enum",
154                             "items" : [
155                                 {
156                                     "listeners" : {
157                                         "keypress" : "function (e)\n{\n    if(e.keyCode == 13){\n        _this.grid.footer.onClick('first');\n    }\n}",
158                                         "beforeedit" : "function (e)\n{\n    if(e.field == 'name' && e.record.data.is_system_enum*1 == 1){\n        return false;\n    }\n}",
159                                         "|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}",
160                                         "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}",
161                                         "afteredit" : "function (e)\n{\n   e.record.commit();     \n}"
162                                     },
163                                     "autoExpandColumn" : "display_name",
164                                     "xtype" : "EditorGrid",
165                                     "loadMask" : true,
166                                     "clicksToEdit" : 1,
167                                     "$ xns" : "Roo.grid",
168                                     "* prop" : "grid",
169                                     "items" : [
170                                         {
171                                             "listeners" : {
172                                                 "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}",
173                                                 "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    options.params['query[search]'] = _this.searchBox.getValue();\n    if (!options.params.etype.length) {\n        return false;\n    }\n}"
174                                             },
175                                             "xtype" : "Store",
176                                             "remoteSort" : true,
177                                             "$ sortInfo" : "{ field : 'etype', direction: 'ASC' }",
178                                             "$ xns" : "Roo.data",
179                                             "* prop" : "dataSource",
180                                             "items" : [
181                                                 {
182                                                     "$ url" : "baseURL + '/Roo/core_enum.php'",
183                                                     "method" : "GET",
184                                                     "xtype" : "HttpProxy",
185                                                     "$ xns" : "Roo.data",
186                                                     "* prop" : "proxy"
187                                                 },
188                                                 {
189                                                     "id" : "id",
190                                                     "root" : "data",
191                                                     "xtype" : "JsonReader",
192                                                     "$ xns" : "Roo.data",
193                                                     "$ 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]",
194                                                     "* prop" : "reader",
195                                                     "totalProperty" : "total"
196                                                 }
197                                             ]
198                                         },
199                                         {
200                                             "pageSize" : 25,
201                                             "xtype" : "PagingToolbar",
202                                             "emptyMsg" : "No core_enum found",
203                                             "$ xns" : "Roo",
204                                             "displayInfo" : true,
205                                             "displayMsg" : "Displaying core_enum{0} - {1} of {2}",
206                                             "* prop" : "footer",
207                                             "items" : [
208                                                 {
209                                                     "listeners" : {
210                                                         "click" : "function (_self, e)\n{\n    new Pman.Download({\n        grid : _this.grid\n    });\n    Roo.MessageBox.alert(\"Downloading\", \"File is downloading\");\n}"
211                                                     },
212                                                     "text" : "Download",
213                                                     "xtype" : "Button",
214                                                     "$ xns" : "Roo.Toolbar"
215                                                 },
216                                                 {
217                                                     "listeners" : {
218                                                         "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+'/Admin/Import/Enum?' + Roo.urlEncode({'etype' : etype})\n        \n       },\n       function () {\n            _this.grid.footer.onClick('first');\n       }\n   );\n}"
219                                                     },
220                                                     "text" : "Upload Values",
221                                                     "xtype" : "Button",
222                                                     "$ xns" : "Roo.Toolbar"
223                                                 }
224                                             ]
225                                         },
226                                         {
227                                             "xtype" : "Toolbar",
228                                             "$ xns" : "Roo",
229                                             "* prop" : "toolbar",
230                                             "items" : [
231                                                 {
232                                                     "listeners" : {
233                                                         "|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"
234                                                     },
235                                                     "text" : "Add Value",
236                                                     "xtype" : "Button",
237                                                     "cls" : "x-btn-text-icon",
238                                                     "$ icon" : "baseURL + '/Pman/templates/images/search.gif'",
239                                                     "$ xns" : "Roo.Toolbar"
240                                                 },
241                                                 {
242                                                     "listeners" : {
243                                                         "|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"
244                                                     },
245                                                     "text" : "Add Image",
246                                                     "xtype" : "Button",
247                                                     "cls" : "x-btn-text-icon",
248                                                     "$ icon" : "Roo.rootURL + 'images/default/dd/drop-add.gif'",
249                                                     "$ xns" : "Roo.Toolbar"
250                                                 },
251                                                 {
252                                                     "listeners" : {
253                                                         "render" : "function (_self)\n{\n    _this.searchBox = this;\n}"
254                                                     },
255                                                     "String name" : "search",
256                                                     "xtype" : "TextField",
257                                                     "String fieldLabel" : "Search",
258                                                     "$ xns" : "Roo.form"
259                                                 },
260                                                 {
261                                                     "listeners" : {
262                                                         "click" : "function (_self, e)\n{\n    _this.grid.footer.onClick('first');\n}"
263                                                     },
264                                                     "String cls" : "x-btn-icon",
265                                                     "xtype" : "Button",
266                                                     "$ xns" : "Roo.Toolbar",
267                                                     "$ icon" : "rootURL + '/Pman/templates/images/search.gif'"
268                                                 },
269                                                 {
270                                                     "listeners" : {
271                                                         "click" : "function (_self, e)\n{\n     _this.searchBox.setValue('');\n     _this.grid.footer.onClick('first');\n}"
272                                                     },
273                                                     "String cls" : "x-btn-icon",
274                                                     "xtype" : "Button",
275                                                     "$ icon" : "rootURL + '/Pman/templates/images/edit-clear.gif'",
276                                                     "$ xns" : "Roo.Toolbar"
277                                                 }
278                                             ]
279                                         },
280                                         {
281                                             "xtype" : "ColumnModel",
282                                             "width" : 75,
283                                             "header" : "Internal #",
284                                             "$ renderer" : "function(v) { return String.format('{0}', v); }",
285                                             "$ xns" : "Roo.grid",
286                                             "Boolean sortable" : true,
287                                             "* prop" : "colModel[]",
288                                             "dataIndex" : "id"
289                                         },
290                                         {
291                                             "xtype" : "ColumnModel",
292                                             "width" : 75,
293                                             "header" : "Image",
294                                             "$ 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); }",
295                                             "$ xns" : "Roo.grid",
296                                             "* prop" : "colModel[]",
297                                             "dataIndex" : "images_id_id"
298                                         },
299                                         {
300                                             "xtype" : "ColumnModel",
301                                             "header" : "Name",
302                                             "width" : 200,
303                                             "$ renderer" : "function(v) { return String.format('{0}', v); }",
304                                             "$ xns" : "Roo.grid",
305                                             "Boolean sortable" : true,
306                                             "* prop" : "colModel[]",
307                                             "dataIndex" : "name",
308                                             "items" : [
309                                                 {
310                                                     "xtype" : "GridEditor",
311                                                     "$ xns" : "Roo.grid",
312                                                     "* prop" : "editor",
313                                                     "items" : [
314                                                         {
315                                                             "xtype" : "TextField",
316                                                             "$ xns" : "Roo.form",
317                                                             "* prop" : "field"
318                                                         }
319                                                     ]
320                                                 }
321                                             ]
322                                         },
323                                         {
324                                             "xtype" : "ColumnModel",
325                                             "width" : 200,
326                                             "header" : "Display Name",
327                                             "$ renderer" : "function(v) { return String.format('{0}', v); }",
328                                             "$ xns" : "Roo.grid",
329                                             "Boolean sortable" : true,
330                                             "* prop" : "colModel[]",
331                                             "dataIndex" : "display_name",
332                                             "items" : [
333                                                 {
334                                                     "xtype" : "GridEditor",
335                                                     "$ xns" : "Roo.grid",
336                                                     "* prop" : "editor",
337                                                     "items" : [
338                                                         {
339                                                             "xtype" : "TextField",
340                                                             "$ xns" : "Roo.form",
341                                                             "* prop" : "field"
342                                                         }
343                                                     ]
344                                                 }
345                                             ]
346                                         },
347                                         {
348                                             "xtype" : "ColumnModel",
349                                             "width" : 75,
350                                             "header" : "Active",
351                                             "$ 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 }",
352                                             "$ xns" : "Roo.grid",
353                                             "Boolean sortable" : true,
354                                             "* prop" : "colModel[]",
355                                             "dataIndex" : "active"
356                                         },
357                                         {
358                                             "xtype" : "ColumnModel",
359                                             "sortable" : true,
360                                             "header" : "Order #",
361                                             "width" : 75,
362                                             "$ renderer" : "function(v) { return String.format('{0}', v); }",
363                                             "$ xns" : "Roo.grid",
364                                             "Boolean sortable" : true,
365                                             "* prop" : "colModel[]",
366                                             "dataIndex" : "seqid",
367                                             "items" : [
368                                                 {
369                                                     "xtype" : "GridEditor",
370                                                     "$ xns" : "Roo.grid",
371                                                     "* prop" : "editor",
372                                                     "items" : [
373                                                         {
374                                                             "allowNegative" : true,
375                                                             "xtype" : "NumberField",
376                                                             "allowDecimals" : false,
377                                                             "decimalPrecision" : 0,
378                                                             "$ xns" : "Roo.form",
379                                                             "* prop" : "field"
380                                                         }
381                                                     ]
382                                                 }
383                                             ]
384                                         }
385                                     ]
386                                 }
387                             ]
388                         }
389                     ]
390                 }
391             ]
392         }
393     ]
394 }