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