Pman.Dialog.AdminCoreEnum.bjs
[Pman.Admin] / Pman.Dialog.AdminCoreEnum.bjs
1 {
2     "id": "roo-file-180",
3     "name": "Pman.Dialog.AdminCoreEnum",
4     "parent": "",
5     "title": "",
6     "path": "/home/alan/gitlive/Pman.Admin/Pman.Dialog.AdminCoreEnum.bjs",
7     "items": [
8         {
9             "height": 400,
10             "title": "Pulldown Options",
11             "width": 950,
12             "xtype": "LayoutDialog",
13             "|xns": "Roo",
14             "items": [
15                 {
16                     "|xns": "Roo",
17                     "xtype": "LayoutRegion",
18                     "*prop": "center"
19                 },
20                 {
21                     "listeners": {
22                         "|activate": "function() {\n    _this.panel = this;\n    if (_this.grid) {\n     //   _this.grid.footer.onClick('first');\n    }\n}"
23                     },
24                     "background": false,
25                     "fitContainer": true,
26                     "fitToframe": true,
27                     "region": "center",
28                     "tableName": "core_enum",
29                     "title": "Pulldown Options",
30                     "xtype": "GridPanel",
31                     "|xns": "Roo",
32                     "items": [
33                         {
34                             "listeners": {
35                                 "|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}",
36                                 "afteredit": "function (e)\n{\n   e.record.commit();     \n}",
37                                 "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}",
38                                 "beforeedit": "function (e)\n{\n    if(e.field == 'name' && e.record.data.is_system_enum*1 == 1){\n        return false;\n    }\n}"
39                             },
40                             "*prop": "grid",
41                             "autoExpandColumn": "display_name",
42                             "clicksToEdit": 1,
43                             "loadMask": true,
44                             "xtype": "EditorGrid",
45                             "|xns": "Roo.grid",
46                             "items": [
47                                 {
48                                     "listeners": {
49                                         "beforeload": "function (_self, options)\n{\n    if (!_this.etypeCombo) {\n        return false;\n    }\n    options.params.etype = _this.etypeCombo.getValue();\n    if (!options.params.etype.length) {\n        return false;\n    }\n}",
50                                         "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.etypeCombo.getValue(),\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}"
51                                     },
52                                     "*prop": "dataSource",
53                                     "remoteSort": true,
54                                     "xtype": "Store",
55                                     "|sortInfo": "{ field : 'etype', direction: 'ASC' }",
56                                     "|xns": "Roo.data",
57                                     "items": [
58                                         {
59                                             "*prop": "proxy",
60                                             "method": "GET",
61                                             "xtype": "HttpProxy",
62                                             "|url": "baseURL + '/Roo/core_enum.php'",
63                                             "|xns": "Roo.data"
64                                         },
65                                         {
66                                             "|xns": "Roo.data",
67                                             "xtype": "JsonReader",
68                                             "totalProperty": "total",
69                                             "root": "data",
70                                             "*prop": "reader",
71                                             "id": "id",
72                                             "|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]"
73                                         }
74                                     ]
75                                 },
76                                 {
77                                     "*prop": "footer",
78                                     "xtype": "PagingToolbar",
79                                     "pageSize": 25,
80                                     "displayInfo": true,
81                                     "displayMsg": "Displaying core_enum{0} - {1} of {2}",
82                                     "emptyMsg": "No core_enum found",
83                                     "|xns": "Roo",
84                                     "items": [
85                                         {
86                                             "listeners": {
87                                                 "click": "function (_self, e)\n{\n    new Pman.Download({\n        grid : _this.grid\n    });\n    Roo.MessageBox.alert(\"Downloading\", \"File is downloading\");\n}"
88                                             },
89                                             "text": "Download",
90                                             "xtype": "Button",
91                                             "|xns": "Roo.Toolbar"
92                                         }
93                                     ]
94                                 },
95                                 {
96                                     "*prop": "toolbar",
97                                     "xtype": "Toolbar",
98                                     "|xns": "Roo",
99                                     "items": [
100                                         {
101                                             "text": "Pulldown Name:",
102                                             "xtype": "TextItem",
103                                             "|xns": "Roo.Toolbar"
104                                         },
105                                         {
106                                             "listeners": {
107                                                 "render": "function (_self)\n{\n    _this.etypeCombo = _self;\n}",
108                                                 "select": "function (combo, record, index)\n{\n    _this.grid.footer.onClick('first');\n}"
109                                             },
110                                             "alwaysQuery": true,
111                                             "displayField": "name",
112                                             "editable": "false",
113                                             "emptyText": "Select pulldown",
114                                             "fieldLabel": "core_enum",
115                                             "forceSelection": true,
116                                             "listWidth": 400,
117                                             "loadingText": "Searching...",
118                                             "minChars": 2,
119                                             "pageSize": 50,
120                                             "qtip": "Select type",
121                                             "queryParam": "query[name]",
122                                             "selectOnFocus": true,
123                                             "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{display_name}</b> - {name} </div>",
124                                             "triggerAction": "all",
125                                             "typeAhead": false,
126                                             "valueField": "name",
127                                             "width": 300,
128                                             "xtype": "ComboBox",
129                                             "|xns": "Roo.form",
130                                             "items": [
131                                                 {
132                                                     "listeners": {
133                                                         "|beforeload": "function (_self, o){\n    o.params = o.params || {};\n    // set more here\n    o.params['query[empty_etype]'] = 1; \n}\n"
134                                                     },
135                                                     "*prop": "store",
136                                                     "remoteSort": true,
137                                                     "xtype": "Store",
138                                                     "|sortInfo": "{ direction : 'ASC', field: 'display_name' }",
139                                                     "|xns": "Roo.data",
140                                                     "items": [
141                                                         {
142                                                             "*prop": "proxy",
143                                                             "xtype": "HttpProxy",
144                                                             "method": "GET",
145                                                             "|xns": "Roo.data",
146                                                             "|url": "baseURL + '/Roo/core_enum.php'"
147                                                         },
148                                                         {
149                                                             "*prop": "reader",
150                                                             "xtype": "JsonReader",
151                                                             "|xns": "Roo.data",
152                                                             "id": "id",
153                                                             "root": "data",
154                                                             "totalProperty": "total",
155                                                             "|fields": "[{\"name\":\"id\",\"type\":\"int\"},{\"name\":\"etype\",\"type\":\"string\"}]"
156                                                         }
157                                                     ]
158                                                 }
159                                             ]
160                                         },
161                                         {
162                                             "listeners": {
163                                                 "|click": "function()\n{\n    \n    // if we do not have a selected type... - what should we show..?\n    var et = _this.etypeCombo.getValue();\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    _this.grid.startEditing(r, 1); // name... \n}\n"
164                                             },
165                                             "cls": "x-btn-text-icon",
166                                             "text": "Add Value",
167                                             "xtype": "Button",
168                                             "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'",
169                                             "|xns": "Roo.Toolbar"
170                                         },
171                                         {
172                                             "listeners": {
173                                                 "|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"
174                                             },
175                                             "cls": "x-btn-text-icon",
176                                             "text": "Add Images",
177                                             "xtype": "Button",
178                                             "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'",
179                                             "|xns": "Roo.Toolbar"
180                                         },
181                                         {
182                                             "|xns": "Roo.Toolbar",
183                                             "xtype": "Fill"
184                                         },
185                                         {
186                                             "listeners": {
187                                                 "|click": "function()\n{\n    \n    Roo.MessageBox.prompt (\"Create a new Enum type\",\n        \"Enter the name for a new enum type, \" + \n        \"this is only relivant if you  know how it is going to be used\",\n        function(btn,txt) {\n            if (btn != 'ok') {\n                return; \n            }\n            new Pman.Request({\n                url : baseURL + '/Roo/Core_enum.php',\n                method : 'POST',\n                params : {\n                    etype : '',\n                    name : txt,\n                    active : 1\n                }, \n                success : function() {\n                    Roo.MessageBox.alert(\"Created\", \"You can now select it from the type list on the left\");\n                }\n            });\n                    \n            \n             \n             \n        }\n    ); \n         \n         \n\n}\n"
188                                             },
189                                             "cls": "x-btn-text-icon",
190                                             "text": "Add new pulldown list",
191                                             "xtype": "Button",
192                                             "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'",
193                                             "|xns": "Roo.Toolbar"
194                                         }
195                                     ]
196                                 },
197                                 {
198                                     "*prop": "colModel[]",
199                                     "dataIndex": "id",
200                                     "header": "Internal #",
201                                     "width": 75,
202                                     "xtype": "ColumnModel",
203                                     "|renderer": "function(v) { return String.format('{0}', v); }",
204                                     "|xns": "Roo.grid"
205                                 },
206                                 {
207                                     "*prop": "colModel[]",
208                                     "dataIndex": "images_id_id",
209                                     "header": "Image",
210                                     "width": 75,
211                                     "xtype": "ColumnModel",
212                                     "|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); }",
213                                     "|xns": "Roo.grid"
214                                 },
215                                 {
216                                     "xtype": "ColumnModel",
217                                     "header": "Name",
218                                     "width": 200,
219                                     "dataIndex": "name",
220                                     "|renderer": "function(v) { return String.format('{0}', v); }",
221                                     "|xns": "Roo.grid",
222                                     "*prop": "colModel[]",
223                                     "items": [
224                                         {
225                                             "|xns": "Roo.grid",
226                                             "xtype": "GridEditor",
227                                             "*prop": "editor",
228                                             "items": [
229                                                 {
230                                                     "|xns": "Roo.form",
231                                                     "xtype": "TextField",
232                                                     "*prop": "field"
233                                                 }
234                                             ]
235                                         }
236                                     ]
237                                 },
238                                 {
239                                     "*prop": "colModel[]",
240                                     "dataIndex": "display_name",
241                                     "header": "Display Name",
242                                     "width": 200,
243                                     "xtype": "ColumnModel",
244                                     "|renderer": "function(v) { return String.format('{0}', v); }",
245                                     "|xns": "Roo.grid",
246                                     "items": [
247                                         {
248                                             "|xns": "Roo.grid",
249                                             "xtype": "GridEditor",
250                                             "*prop": "editor",
251                                             "items": [
252                                                 {
253                                                     "|xns": "Roo.form",
254                                                     "xtype": "TextField",
255                                                     "*prop": "field"
256                                                 }
257                                             ]
258                                         }
259                                     ]
260                                 },
261                                 {
262                                     "*prop": "colModel[]",
263                                     "dataIndex": "active",
264                                     "header": "Active",
265                                     "width": 75,
266                                     "xtype": "ColumnModel",
267                                     "|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 }",
268                                     "|xns": "Roo.grid"
269                                 },
270                                 {
271                                     "*prop": "colModel[]",
272                                     "dataIndex": "seqid",
273                                     "header": "Order #",
274                                     "sortable": true,
275                                     "width": 75,
276                                     "xtype": "ColumnModel",
277                                     "|renderer": "function(v) { return String.format('{0}', v); }",
278                                     "|xns": "Roo.grid",
279                                     "items": [
280                                         {
281                                             "|xns": "Roo.grid",
282                                             "xtype": "GridEditor",
283                                             "*prop": "editor",
284                                             "items": [
285                                                 {
286                                                     "*prop": "field",
287                                                     "allowDecimals": false,
288                                                     "allowNegative": true,
289                                                     "decimalPrecision": 0,
290                                                     "xtype": "NumberField",
291                                                     "|xns": "Roo.form"
292                                                 }
293                                             ]
294                                         }
295                                     ]
296                                 }
297                             ]
298                         }
299                     ]
300                 },
301                 {
302                     "|xns": "Roo",
303                     "xtype": "Button",
304                     "*prop": "buttons[]"
305                 }
306             ]
307         }
308     ],
309     "permname": "",
310     "modOrder": "001"
311 }