Pman.Dialog.AdminCoreEnum.bjs
[Pman.Admin] / Pman.Dialog.AdminCoreEnum.bjs
1 {
2     "name" : "Pman.Dialog.AdminCoreEnum",
3     "parent" : "",
4     "title" : "",
5     "path" : "/home/alan/gitlive/Pman.Admin/Pman.Dialog.AdminCoreEnum.bjs",
6     "permname" : "",
7     "modOrder" : "001",
8     "items" : [
9         {
10             "listeners" : {
11                 "show" : "function (_self)\n{\n    if(!isAdmin && Pman.Tab.Hopedb){\n        Roo.MessageBox.alert(\"Error\", \"Permission Denied\", function(){\n            _this.dialog.hide();\n        });\n        return;\n    }\n    var name_hidden = false;\n\n    if (typeof(_this.data._hide_name) != 'undefined') {\n        name_hidden = true;\n    \n    }\n    \n  _this.grid.colModel.setHidden(1,name_hidden);\n    _this.grid.footer.onClick('first');\n}"
12             },
13             "modal" : true,
14             "title" : "Pulldown Options",
15             "xtype" : "LayoutDialog",
16             "width" : 950,
17             "$ xns" : "Roo",
18             "closable" : false,
19             "resizable" : false,
20             "height" : 400,
21             "items" : [
22                 {
23                     "xtype" : "LayoutRegion",
24                     "$ xns" : "Roo",
25                     "* prop" : "center"
26                 },
27                 {
28                     "listeners" : {
29                         "|activate" : "function() {\n    _this.panel = this;\n    if (_this.grid) {\n     //   _this.grid.footer.onClick('first');\n    }\n}"
30                     },
31                     "fitToframe" : true,
32                     "background" : false,
33                     "region" : "center",
34                     "title" : "Pulldown Options",
35                     "xtype" : "GridPanel",
36                     "fitContainer" : true,
37                     "$ xns" : "Roo",
38                     "tableName" : "core_enum",
39                     "items" : [
40                         {
41                             "listeners" : {
42                                 "beforeedit" : "function (e)\n{\n  \n    // force fill in of name first.. (Except when it's hidden)\n    if (typeof(_this.data._hide_name) != 'undefined') { \n        if(e.field == 'display_name' && e.record.data.is_system_enum*1 == 1){\n            return ;\n        }\n \n    }\n    \n    if(e.field == 'name' && e.record.data.is_system_enum*1 == 1){\n        Roo.log(\"block name?\");\n        return false;\n    }\n}",
43                                 "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}",
44                                 "|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}",
45                                 "afteredit" : "function (e)\n{\n   e.record.commit();   \n}"
46                             },
47                             "autoExpandColumn" : "display_name",
48                             "xtype" : "EditorGrid",
49                             "loadMask" : true,
50                             "clicksToEdit" : 1,
51                             "$ xns" : "Roo.grid",
52                             "* prop" : "grid",
53                             "items" : [
54                                 {
55                                     "listeners" : {
56                                         "update" : "function (_self, record, operation)\n{\n    if (operation != Roo.data.Record.COMMIT) {\n        return;\n    }\n    Roo.log(record);\n\n    if (typeof(_this.data._hide_name) != 'undefined') {\n        record.set('name', record.data.display_name);\n    }\n    if (!record.data.name.length) {\n        return;\n    }\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.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}",
57                                         "beforeload" : "function (_self, options)\n{\n\n    options.params.etype = _this.data.etype;\n    if (!options.params.etype.length) {\n        return false;\n    }\n}"
58                                     },
59                                     "xtype" : "Store",
60                                     "remoteSort" : true,
61                                     "$ sortInfo" : "{ field : 'etype', direction: 'ASC' }",
62                                     "$ xns" : "Roo.data",
63                                     "* prop" : "dataSource",
64                                     "items" : [
65                                         {
66                                             "$ url" : "baseURL + '/Roo/core_enum.php'",
67                                             "xtype" : "HttpProxy",
68                                             "method" : "GET",
69                                             "$ xns" : "Roo.data",
70                                             "* prop" : "proxy"
71                                         },
72                                         {
73                                             "id" : "id",
74                                             "root" : "data",
75                                             "xtype" : "JsonReader",
76                                             "$ xns" : "Roo.data",
77                                             "$ 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]",
78                                             "* prop" : "reader",
79                                             "totalProperty" : "total"
80                                         }
81                                     ]
82                                 },
83                                 {
84                                     "pageSize" : 25,
85                                     "xtype" : "PagingToolbar",
86                                     "emptyMsg" : "No core_enum found",
87                                     "$ xns" : "Roo",
88                                     "displayInfo" : true,
89                                     "displayMsg" : "Displaying core_enum{0} - {1} of {2}",
90                                     "* prop" : "footer"
91                                 },
92                                 {
93                                     "xtype" : "Toolbar",
94                                     "$ xns" : "Roo",
95                                     "* prop" : "toolbar",
96                                     "items" : [
97                                         {
98                                             "listeners" : {
99                                                 "|click" : "function()\n{\n    \n    // if we do not have a selected type... - what should we show..?\n    var et = _this.data.etype;\n    var ds = _this.grid.getDataSource();\n    if (!et) {\n        Roo.MessageBox.alert(\"Error\", \"Select a pulldown\");\n        return;\n    }\n\n    var add = ds.reader.newRow({    \n             id: 0, \n             display_name : '', \n             name : '', \n             etype: et, \n             active: 1, \n             seqid: 0\n      });\n     var r = ds.data.length;\n    ds.insert(r  , add);  \n    \n    var ec = 1;\n    if (typeof(_this.data._hide_name) != 'undefined') { \n        ec =2;\n    }\n    _this.grid.startEditing(r, ec); // name... \n}\n"
100                                             },
101                                             "text" : "Add Value",
102                                             "xtype" : "Button",
103                                             "cls" : "x-btn-text-icon",
104                                             "$ icon" : "Roo.rootURL + 'images/default/dd/drop-add.gif'",
105                                             "$ xns" : "Roo.Toolbar"
106                                         },
107                                         {
108                                             "xtype" : "Fill",
109                                             "$ xns" : "Roo.Toolbar"
110                                         }
111                                     ]
112                                 },
113                                 {
114                                     "xtype" : "ColumnModel",
115                                     "header" : "Internal #",
116                                     "width" : 75,
117                                     "$ renderer" : "function(v) { return String.format('{0}', v); }",
118                                     "$ xns" : "Roo.grid",
119                                     "* prop" : "colModel[]",
120                                     "dataIndex" : "id"
121                                 },
122                                 {
123                                     "xtype" : "ColumnModel",
124                                     "width" : 200,
125                                     "header" : "Name",
126                                     "$ renderer" : "function(v) { return String.format('{0}', v); }",
127                                     "$ xns" : "Roo.grid",
128                                     "* prop" : "colModel[]",
129                                     "dataIndex" : "name",
130                                     "items" : [
131                                         {
132                                             "xtype" : "GridEditor",
133                                             "$ xns" : "Roo.grid",
134                                             "* prop" : "editor",
135                                             "items" : [
136                                                 {
137                                                     "xtype" : "TextField",
138                                                     "$ xns" : "Roo.form",
139                                                     "* prop" : "field"
140                                                 }
141                                             ]
142                                         }
143                                     ]
144                                 },
145                                 {
146                                     "xtype" : "ColumnModel",
147                                     "header" : "Display Name",
148                                     "width" : 200,
149                                     "$ renderer" : "function(v) { return String.format('{0}', v); }",
150                                     "$ xns" : "Roo.grid",
151                                     "* prop" : "colModel[]",
152                                     "dataIndex" : "display_name",
153                                     "items" : [
154                                         {
155                                             "xtype" : "GridEditor",
156                                             "$ xns" : "Roo.grid",
157                                             "* prop" : "editor",
158                                             "items" : [
159                                                 {
160                                                     "xtype" : "TextField",
161                                                     "$ xns" : "Roo.form",
162                                                     "* prop" : "field"
163                                                 }
164                                             ]
165                                         }
166                                     ]
167                                 },
168                                 {
169                                     "xtype" : "ColumnModel",
170                                     "header" : "Active",
171                                     "width" : 75,
172                                     "$ 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 }",
173                                     "$ xns" : "Roo.grid",
174                                     "* prop" : "colModel[]",
175                                     "dataIndex" : "active"
176                                 },
177                                 {
178                                     "xtype" : "ColumnModel",
179                                     "sortable" : true,
180                                     "header" : "Order #",
181                                     "width" : 75,
182                                     "$ renderer" : "function(v) { return String.format('{0}', v); }",
183                                     "$ xns" : "Roo.grid",
184                                     "* prop" : "colModel[]",
185                                     "dataIndex" : "seqid",
186                                     "items" : [
187                                         {
188                                             "xtype" : "GridEditor",
189                                             "$ xns" : "Roo.grid",
190                                             "* prop" : "editor",
191                                             "items" : [
192                                                 {
193                                                     "allowNegative" : true,
194                                                     "xtype" : "NumberField",
195                                                     "allowDecimals" : false,
196                                                     "decimalPrecision" : 0,
197                                                     "$ xns" : "Roo.form",
198                                                     "* prop" : "field"
199                                                 }
200                                             ]
201                                         }
202                                     ]
203                                 }
204                             ]
205                         }
206                     ]
207                 },
208                 {
209                     "listeners" : {
210                         "click" : "function (_self, e)\n{\n  _this.dialog.hide();\n}"
211                     },
212                     "text" : "Cancel",
213                     "xtype" : "Button",
214                     "$ xns" : "Roo",
215                     "* prop" : "buttons[]"
216                 },
217                 {
218                     "listeners" : {
219                         "click" : "function (_self, e)\n{\n    var sel = _this.grid.selModel.getSelectedCell();\n    if (!sel && _this.callback) {\n        Roo.MessageBox.alert(\"Error\", \"Select an item\");\n        return;\n    }\n    \n\n    if (_this.callback) {\n        var rec = _this.grid.ds.getAt(sel[0]);\n       _this.callback(rec.data);\n   }\n   _this.dialog.hide();\n}"
220                     },
221                     "text" : "OK",
222                     "xtype" : "Button",
223                     "$ xns" : "Roo",
224                     "* prop" : "buttons[]"
225                 }
226             ]
227         }
228     ]
229 }