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