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/edward/gitlive/Pman.Admin/Pman.Tab.AdminEnum.bjs",
6  "permname" : "",
7  "modOrder" : "500",
8  "strings" : {
9   "2df80d5febcde0c10a66818488622b7c" : "Pulldown Options",
10   "d1228f5476d15142b1358ae4b5fa2454" : "Order #",
11   "fdff10eac021dfbb69e9c38204237fdc" : "Add new pulldown list",
12   "1206eb8aea05be4625371c9c12818785" : "Pulldown",
13   "801ab24683a4a8c433c6eb40c48bcd9d" : "Download",
14   "7af54708cf5a4286cf0cfa58ff5148a8" : "Internal #",
15   "be53a0541a6d36f6ecb879fa2c584b08" : "Image",
16   "b48968e1c912da07df5e8d6d246291ec" : "Display Name",
17   "510bc6e58593b2b8002c9fe0c21f3fde" : "Displaying core_enum{0} - {1} of {2}",
18   "1ba4d808fc7b27a7f60ce2ff75a8af3a" : "No core_enum found",
19   "c550aeed26e71a81a88360c1889245ab" : "Upload Values",
20   "d9ec74f5aa29ceef6bf7b45f7fec5d0f" : "Add Value",
21   "b9c49611cfda3259a2b837b39489e650" : "Add Image",
22   "4d3d769b812b6faa6b76e1a8abaece2d" : "Active",
23   "f2a6c498fb90ee345d997f888fce3b18" : "Delete",
24   "49ee3087348e8d44e1feda1917443987" : "Name",
25   "7215ee9c7d9dc229d2921a40e899ec5f" : " "
26  },
27  "items" : [
28   {
29    "xtype" : "NestedLayoutPanel",
30    "String region" : "center",
31    "$ xns" : "Roo",
32    "String title" : "Pulldown Options",
33    "items" : [
34     {
35      "xtype" : "BorderLayout",
36      "$ xns" : "Roo",
37      "* prop" : "layout",
38      "items" : [
39       {
40        "Number width" : 200,
41        "xtype" : "LayoutRegion",
42        "$ xns" : "Roo",
43        "* prop" : "west",
44        "Boolean split" : true
45       },
46       {
47        "xtype" : "LayoutRegion",
48        "$ xns" : "Roo",
49        "* prop" : "center"
50       },
51       {
52        "listeners" : {
53         "|activate" : "function() {\n    _this.epanel = this;\n    //if (_this.egrid) {\n    //    _this.egrid.footer.onClick('first');\n    //}\n}"
54        },
55        "background" : false,
56        "region" : "west",
57        "title" : "Pulldown Options",
58        "xtype" : "GridPanel",
59        "$ xns" : "Roo",
60        "tableName" : "core_enum",
61        "items" : [
62         {
63          "listeners" : {
64           "beforeedit" : "function (e)\n{\n    if(e.field == 'name' && e.record.data.is_system_enum*1 == 1){\n        return false;\n    }\n}",
65           "|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}",
66           "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}",
67           "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}",
68           "afteredit" : "function (e)\n{\n   e.record.commit();     \n}"
69          },
70          "autoExpandColumn" : "display_name",
71          "xtype" : "EditorGrid",
72          "loadMask" : true,
73          "clicksToEdit" : 1,
74          "$ xns" : "Roo.grid",
75          "* prop" : "grid",
76          "items" : [
77           {
78            "listeners" : {
79             "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}",
80             "beforeload" : "function (_self, o)\n{\n    o.params['query[empty_etype]'] = 1; \n  \n}"
81            },
82            "xtype" : "Store",
83            "remoteSort" : true,
84            "$ sortInfo" : "{ field : 'etype', direction: 'ASC' }",
85            "$ xns" : "Roo.data",
86            "* prop" : "dataSource",
87            "items" : [
88             {
89              "$ url" : "baseURL + '/Roo/core_enum.php'",
90              "method" : "GET",
91              "xtype" : "HttpProxy",
92              "$ xns" : "Roo.data",
93              "* prop" : "proxy"
94             },
95             {
96              "id" : "id",
97              "root" : "data",
98              "xtype" : "JsonReader",
99              "$ xns" : "Roo.data",
100              "$ 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]",
101              "* prop" : "reader",
102              "totalProperty" : "total"
103             }
104            ]
105           },
106           {
107            "listeners" : {
108             "selectionchange" : "function (_self, selection)\n{\n    _this.grid.footer.onClick('first');\n}"
109            },
110            "xtype" : "CellSelectionModel",
111            "$ xns" : "Roo.grid",
112            "* prop" : "sm"
113           },
114           {
115            "pageSize" : 100,
116            "xtype" : "PagingToolbar",
117            "emptyMsg" : "No core_enum found",
118            "$ xns" : "Roo",
119            "displayInfo" : false,
120            "displayMsg" : " ",
121            "* prop" : "footer"
122           },
123           {
124            "xtype" : "Toolbar",
125            "$ xns" : "Roo",
126            "* prop" : "toolbar",
127            "items" : [
128             {
129              "listeners" : {
130               "|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"
131              },
132              "text" : "Add new pulldown list",
133              "xtype" : "Button",
134              "cls" : "x-btn-text-icon",
135              "$ icon" : "Roo.rootURL + 'images/default/dd/drop-add.gif'",
136              "$ xns" : "Roo.Toolbar"
137             }
138            ]
139           },
140           {
141            "xtype" : "ColumnModel",
142            "width" : 200,
143            "header" : "Pulldown",
144            "$ 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}",
145            "$ xns" : "Roo.grid",
146            "* prop" : "colModel[]",
147            "dataIndex" : "display_name"
148           },
149           {
150            "xtype" : "ColumnModel",
151            "width" : 50,
152            "header" : "Active",
153            "$ 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 }",
154            "$ xns" : "Roo.grid",
155            "* prop" : "colModel[]",
156            "dataIndex" : "active"
157           }
158          ]
159         }
160        ]
161       },
162       {
163        "listeners" : {
164         "|activate" : "function() {\n    _this.panel = this;\n    if (_this.grid) {\n        _this.grid.footer.onClick('first');\n    }\n}"
165        },
166        "background" : false,
167        "region" : "center",
168        "fitToframe" : true,
169        "title" : "Pulldown Options",
170        "xtype" : "GridPanel",
171        "$ xns" : "Roo",
172        "tableName" : "core_enum",
173        "items" : [
174         {
175          "listeners" : {
176           "keypress" : "function (e)\n{\n    if(e.keyCode == 13){\n        _this.grid.footer.onClick('first');\n    }\n}",
177           "beforeedit" : "function (e)\n{\n    if(e.field == 'name' && e.record.data.is_system_enum*1 == 1){\n        return false;\n    }\n}",
178           "|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}",
179           "cellclick" : "function (_self, rowIndex, columnIndex, e)\n{\n\n        var di = this.colModel.getDataIndex(columnIndex);\n        var rec = _this.grid.ds.getAt(rowIndex);\n            \n        if (di == 'active') {\n            \n            rec.set('active', rec.data.active ? 0 : 1);\n            rec.commit();\n            return;\n        }\n        if (di == 'id' ) {\n            \n            if (!e.ctrlKey && !e.shiftKey) { // shift or control not pressed -clear selection.\n            \n                this.dataSource.each(function(rr) {\n                    rr.selected = 0;\n                    rr.set('sel', 0);\n                });\n            }\n            \n            if (this.last_selected && e.shiftKey) {\n                // the highlight all the lines between the one last selected, and this one.\n                var s = this.dataSource.indexOf(this.last_selected);\n                var e = this.dataSource.indexOf(rec);\n                var ss = Math.min(s,e);\n                var ee = Math.max(s,e) +1;\n                for(var i = ss; i < ee; i++) {\n                    var rr = this.dataSource.getAt(i);\n                    rr.selected = 1;\n                    rr.set('sel', 1);\n                }\n                this.last_selected = rec;\n                return;\n\n            }\n            \n            rec.selected = rec.selected ? 0 : 1;\n            this.last_selected = rec.selected ? rec : false;\n            rec.set('sel', rec.data.sel ? 0 : 1);\n        }\n         \n\n         \n        \n}",
180           "afteredit" : "function (e)\n{\n   e.record.commit();     \n}"
181          },
182          "autoExpandColumn" : "display_name",
183          "xtype" : "EditorGrid",
184          "loadMask" : true,
185          "clicksToEdit" : 1,
186          "$ xns" : "Roo.grid",
187          "* prop" : "grid",
188          "items" : [
189           {
190            "listeners" : {
191             "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}",
192             "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}"
193            },
194            "xtype" : "Store",
195            "remoteSort" : true,
196            "$ sortInfo" : "{ field : 'etype', direction: 'ASC' }",
197            "$ xns" : "Roo.data",
198            "* prop" : "dataSource",
199            "items" : [
200             {
201              "$ url" : "baseURL + '/Roo/core_enum.php'",
202              "xtype" : "HttpProxy",
203              "method" : "GET",
204              "$ xns" : "Roo.data",
205              "* prop" : "proxy"
206             },
207             {
208              "id" : "id",
209              "root" : "data",
210              "xtype" : "JsonReader",
211              "$ xns" : "Roo.data",
212              "$ 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]",
213              "* prop" : "reader",
214              "totalProperty" : "total"
215             }
216            ]
217           },
218           {
219            "pageSize" : 25,
220            "xtype" : "PagingToolbar",
221            "emptyMsg" : "No core_enum found",
222            "$ xns" : "Roo",
223            "displayInfo" : true,
224            "displayMsg" : "Displaying core_enum{0} - {1} of {2}",
225            "* prop" : "footer",
226            "items" : [
227             {
228              "listeners" : {
229               "click" : "function (_self, e)\n{\n    new Pman.Download({\n        grid : _this.grid\n    });\n    Roo.MessageBox.alert(\"Downloading\", \"File is downloading\");\n}"
230              },
231              "text" : "Download",
232              "xtype" : "Button",
233              "$ xns" : "Roo.Toolbar"
234             },
235             {
236              "listeners" : {
237               "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}"
238              },
239              "text" : "Upload Values",
240              "xtype" : "Button",
241              "$ xns" : "Roo.Toolbar"
242             }
243            ]
244           },
245           {
246            "xtype" : "Toolbar",
247            "$ xns" : "Roo",
248            "* prop" : "toolbar",
249            "items" : [
250             {
251              "listeners" : {
252               "|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"
253              },
254              "text" : "Add Value",
255              "xtype" : "Button",
256              "cls" : "x-btn-text-icon",
257              "$ icon" : "baseURL + '/Pman/templates/images/search.gif'",
258              "$ xns" : "Roo.Toolbar"
259             },
260             {
261              "listeners" : {
262               "|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"
263              },
264              "text" : "Add Image",
265              "xtype" : "Button",
266              "cls" : "x-btn-text-icon",
267              "$ icon" : "Roo.rootURL + 'images/default/dd/drop-add.gif'",
268              "$ xns" : "Roo.Toolbar"
269             },
270             {
271              "listeners" : {
272               "render" : "function (_self)\n{\n    _this.searchBox = this;\n}"
273              },
274              "String name" : "search",
275              "xtype" : "TextField",
276              "String fieldLabel" : "Search",
277              "$ xns" : "Roo.form"
278             },
279             {
280              "listeners" : {
281               "click" : "function (_self, e)\n{\n    _this.grid.footer.onClick('first');\n}"
282              },
283              "String cls" : "x-btn-icon",
284              "xtype" : "Button",
285              "$ xns" : "Roo.Toolbar",
286              "$ icon" : "rootURL + '/Pman/templates/images/search.gif'"
287             },
288             {
289              "listeners" : {
290               "click" : "function (_self, e)\n{\n     _this.searchBox.setValue('');\n     _this.grid.footer.onClick('first');\n}"
291              },
292              "String cls" : "x-btn-icon",
293              "xtype" : "Button",
294              "$ icon" : "rootURL + '/Pman/templates/images/edit-clear.gif'",
295              "$ xns" : "Roo.Toolbar"
296             },
297             {
298              "xtype" : "Fill",
299              "$ xns" : "Roo.Toolbar"
300             },
301             {
302              "listeners" : {
303               "|click" : "function()\n{\n    var ids = [];\n    _this.grid.dataSource.each(function(rr) {\n        if (rr.selected) {\n            ids.push(rr.data.id);\n        }\n    });   \n    if (!ids.length) {\n        Roo.MessageBox.alert(\"Error\", \"Select rows by clicking on the Internal# column\");\n        return;\n    }\n    \n    Roo.MessageBox.confirm(\n        \"Confirm\", \n        \"Confirm Deletion of selected rows (some rows can not be deleted if they are referenced elsewhere\", \n        function(res) {\n            if(res != 'yes') {\n                return;\n            }\n            new Pman.Request({\n                method : 'POST',\n                url : baseURL + '/Roo/Core_enum',\n                params : {\n                    _delete  : ids.join(',')\n                },\n                success : function() {\n                    _this.grid.footer.onClick('refresh');\n                }\n            });\n        }\n    );\n    \n    \n}\n\n        "
304              },
305              "text" : "Delete",
306              "xtype" : "Button",
307              "cls" : "x-btn-text-icon",
308              "$ icon" : "rootURL + '/Pman/templates/images/trash.gif'",
309              "$ xns" : "Roo.Toolbar"
310             }
311            ]
312           },
313           {
314            "xtype" : "ColumnModel",
315            "header" : "Internal #",
316            "width" : 75,
317            "$ renderer" : "function(v,x,r) { \n    var fmt = '{0}';\n    if (r.selected) {\n        fmt = '<span style=\"color:orange;font-weight:bold;\">{0}</span>';\n    }\n    return String.format(fmt, v); }",
318            "$ xns" : "Roo.grid",
319            "Boolean sortable" : true,
320            "* prop" : "colModel[]",
321            "dataIndex" : "id"
322           },
323           {
324            "xtype" : "ColumnModel",
325            "header" : "Image",
326            "width" : 75,
327            "$ 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); }",
328            "$ xns" : "Roo.grid",
329            "* prop" : "colModel[]",
330            "dataIndex" : "images_id_id"
331           },
332           {
333            "xtype" : "ColumnModel",
334            "width" : 200,
335            "header" : "Name",
336            "$ renderer" : "function(v) { return String.format('{0}', v); }",
337            "$ xns" : "Roo.grid",
338            "Boolean sortable" : true,
339            "* prop" : "colModel[]",
340            "dataIndex" : "name",
341            "items" : [
342             {
343              "xtype" : "GridEditor",
344              "$ xns" : "Roo.grid",
345              "* prop" : "editor",
346              "items" : [
347               {
348                "xtype" : "TextField",
349                "$ xns" : "Roo.form",
350                "* prop" : "field"
351               }
352              ]
353             }
354            ]
355           },
356           {
357            "xtype" : "ColumnModel",
358            "header" : "Display Name",
359            "width" : 200,
360            "$ renderer" : "function(v) { return String.format('{0}', v); }",
361            "$ xns" : "Roo.grid",
362            "Boolean sortable" : true,
363            "* prop" : "colModel[]",
364            "dataIndex" : "display_name",
365            "items" : [
366             {
367              "xtype" : "GridEditor",
368              "$ xns" : "Roo.grid",
369              "* prop" : "editor",
370              "items" : [
371               {
372                "xtype" : "TextField",
373                "$ xns" : "Roo.form",
374                "* prop" : "field"
375               }
376              ]
377             }
378            ]
379           },
380           {
381            "xtype" : "ColumnModel",
382            "header" : "Active",
383            "width" : 75,
384            "$ 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 }",
385            "$ xns" : "Roo.grid",
386            "Boolean sortable" : true,
387            "* prop" : "colModel[]",
388            "dataIndex" : "active"
389           },
390           {
391            "xtype" : "ColumnModel",
392            "sortable" : true,
393            "header" : "Order #",
394            "width" : 75,
395            "$ renderer" : "function(v) { return String.format('{0}', v); }",
396            "$ xns" : "Roo.grid",
397            "Boolean sortable" : true,
398            "* prop" : "colModel[]",
399            "dataIndex" : "seqid",
400            "items" : [
401             {
402              "xtype" : "GridEditor",
403              "$ xns" : "Roo.grid",
404              "* prop" : "editor",
405              "items" : [
406               {
407                "allowNegative" : true,
408                "xtype" : "NumberField",
409                "allowDecimals" : false,
410                "decimalPrecision" : 0,
411                "$ xns" : "Roo.form",
412                "* prop" : "field"
413               }
414              ]
415             }
416            ]
417           }
418          ]
419         }
420        ]
421       }
422      ]
423     }
424    ]
425   }
426  ]
427 }