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