d35b68ff609520e392375dc46b19bfe990d77d90
[app.Builder.js] / resources / Editors / Editor.Roo.LayoutDialog.bjs
1 {
2  "name" : "Editor.Roo.LayoutDialog",
3  "parent" : "",
4  "title" : "",
5  "path" : "/home/alan/gitlive/app.Builder.js/resources/Editors/Editor.Roo.LayoutDialog.bjs",
6  "permname" : "",
7  "modOrder" : "001",
8  "strings" : {
9   "b021df6aac4654c454f46c77646e745f" : "Label",
10   "793548e77e782c209a78ed67f255b5e2" : "Display Field",
11   "4ce58cbe362a5d7b156992a496d55bf3" : "Database Column",
12   "189efd19c4153526994a6d7ea5f6f068" : "Field Type",
13   "2f616612593df62aeed112de4f03110e" : "Edit a Grid",
14   "0ccc2bf3fb98387c23b6ca5500244d6e" : "Use ",
15   "c671c787b49f50a3ace9fdc5bd597825" : "core_enum",
16   "32954654ac8fe66a1d09be19001de2d4" : "Width",
17   "a1fa27779242b4902f7ae3bdd5c6d508" : "Type",
18   "6e7376dca68a2386a8737944196ab491" : "Create / Edit Grid"
19  },
20  "items" : [
21   {
22    "listeners" : {
23     "|activate" : "function() {\n    _this.panel = this;\n    if (_this.grid) {\n        _this.grid.footer.onClick('first');\n    }\n}"
24    },
25    "| function loadData" : "function(data) { \n\n     alert(\"IPC:TEST:\" + JSON.stringify(data,null,4));\n    var ar = [];\n    for (var k in data) { \n        var r = data[k];\n        var has_s = typeof(r.relates_to_schema) != 'undefined'\n        ar.push([ !has_s , r.Field, r.Type,  r.Field, 100] );\n        if (!has_s) {\n            continue;\n        }\n        /*\n        for (var kk in r.relates_to_schema) {         \n            var rr = r.relates_to_schema[kk];\n            if (rr.Field == r.relates_to_col) {\n                continue;\n            }\n            ar.push([ false, r.Field + '_'+ rr.Field, rr.Type,  rr.Field, 100] );\n        }\n        */\n    }\n    this.schema = data;\n    alert(\"IPC:TEST:\" + JSON.stringify(ar));\n    this.grid.dataSource.loadData(ar);\n}",
26    "| function toBJS" : "function() { \n\n// convert the selected cells into a BJS data ready to send back to the UI..\n   \n    this.table = \"XXX\";\n    this.firstTxtCol = \"XXX\";\n   \n    var formHeight = 50;\n    \n    var jreader = {};\n    var  formElements = [];\n    this.grid.dataSource.each(function(rec) {\n        if (!rec.data.active) {\n            return;\n        }\n        \n        var el = {\n            fieldLabel : rec.data.title,\n            name : rec.data.dataIndex,\n            width : 200, //row.type == 'string' ? 200 : 75,\n            '|xns' : 'Roo.form',\n            xtype : rec.data.ftype\n        }\n        \n        formElements.push(el);\n        \n        formHeight += rec.data.ftype == 'TextArea' ? 100 : 30;\n        \n        \n    });\n    \n    \n    \n    \n    \n    \n     var frmCfg = \n    {\n        '|xns' : 'Roo.form',\n        xtype : \"Form\",\n        listeners : {\n            \"|actioncomplete\" : \"function(_self,action)\\n\"+\n                \"{\\n\"+\n                \"    if (action.type == 'setdata') {\\n\"+\n                \"       //this.load({ method: 'GET', params: { '_id' : _this.data.id }});\\n\"+\n                \"       return;\\n\"+\n                \"    }\\n\"+\n                \"    if (action.type == 'load') {\\n\"+\n                \"        return;\\n\"+\n                \"    }\\n\"+\n                \"    if (action.type =='submit') {\\n\"+\n                \"    \\n\"+\n                \"        _this.dialog.hide();\\n\"+\n                \"    \\n\"+\n                \"         if (_this.callback) {\\n\"+\n                \"            _this.callback.call(_this, action.result.data);\\n\"+\n                \"         }\\n\"+\n                \"         _this.form.reset();\\n\"+\n                \"         return;\\n\"+\n                \"    }\\n\"+\n                \"}\\n\",\n            \n            \"|rendered\" : \"function (form)\\n\"+\n                \"{\\n\"+\n                \"    _this.form= form;\\n\"+\n                \"}\\n\"\n        },\n        method : \"POST\",\n        style : \"margin:10px;\",\n        \"|url\" : \"baseURL + '/Roo/\" + this.table + \"'\",\n        items : formElements\n    };\n    \n\n    alert(\"IPC:OUT:\" + JSON.stringify({\n            \"closable\": false,\n            \"collapsible\": false,\n            \"height\": formHeight,\n            \"resizable\": false,\n            \"title\": \"Edit / Create \" + this.table,\n            \"width\": 400,\n            \"modal\" : true,\n            \"xtype\": \"LayoutDialog\",\n            \"|xns\": \"Roo\",\n            \"items\": [\n                {\n                    \"|xns\": \"Roo\",\n                    \"xtype\": \"LayoutRegion\",\n                    \"*prop\": \"center\"\n                },\n                {\n                    \"region\": \"center\",\n                    \"xtype\": \"ContentPanel\",\n                    \"|xns\": \"Roo\",\n                    \"items\": [\n                        frmCfg\n                    ]\n                },\n                \n                {\n                    \"listeners\": {\n                        \"click\": \"function (_self, e)\\n{\\n    _this.dialog.hide();\\n}\"\n                    },\n                    \"*prop\": \"buttons[]\",\n                    \"text\": \"Cancel\",\n                    \"xtype\": \"Button\",\n                    \"|xns\": \"Roo\"\n                },\n                {\n                    \"listeners\": {\n                        \"click\": \"function (_self, e)\\n{\\n    // do some checks?\\n     \\n    \\n    _this.dialog.el.mask(\\\"Saving\\\");\\n    _this.form.doAction(\\\"submit\\\");\\n\\n}\"\n                    },\n                    \"*prop\": \"buttons[]\",\n                    \"text\": \"Save\",\n                    \"xtype\": \"Button\",\n                    \"|xns\": \"Roo\"\n                }\n            ]\n        \n        \n        \n    }, null, 4));\n\n}",
27    "fitToframe" : true,
28    "background" : false,
29    "region" : "center",
30    "title" : "core_enum",
31    "xtype" : "GridPanel",
32    "$ xns" : "Roo",
33    "fitContainer" : true,
34    "String title" : "Create / Edit Grid",
35    "tableName" : "core_enum",
36    "items" : [
37     {
38      "listeners" : {
39       "|rowdblclick" : "function (_self, rowIndex, e)\n{\n    if (!_this.dialog) return;\n  \n}\n",
40       "|render" : "function() \n{\n    _this.grid = this; \n    //_this.dialog = Pman.Dialog.FILL_IN\n\n}",
41       "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 * 1 ? 0 : 1);\n        rec.commit();\n         \n        \n}"
42      },
43      "Number clicksToEdit" : 1,
44      "autoExpandColumn" : "title",
45      "xtype" : "EditorGrid",
46      "loadMask" : true,
47      "$ xns" : "Roo.grid",
48      "* prop" : "grid",
49      "items" : [
50       {
51        "$ Array fields" : "[ 'active', 'dataIndex', 'type','title', 'width' ]",
52        "$ Array data" : "[\n  [ 1, 'test', 'test', 110 ]\n  \n\n]",
53        "Number id" : "'dataIndex'",
54        "xtype" : "SimpleStore",
55        "$ xns" : "Roo.data",
56        "* prop" : "ds"
57       },
58       {
59        "xtype" : "Toolbar",
60        "$ xns" : "Roo",
61        "* prop" : "toolbar",
62        "items" : [
63         {
64          "string text" : "Edit a Grid",
65          "xtype" : "TextItem",
66          "$ xns" : "Roo.Toolbar"
67         }
68        ]
69       },
70       {
71        "xtype" : "ColumnModel",
72        "width" : 75,
73        "header" : "Use ",
74        "$ renderer" : "function(v) {  \n    var state = v *1 > 0 ?  '-checked' : '';\n\n    return '<img class=\"x-grid-check-icon' + state + '\" src=\"' + Roo.BLANK_IMAGE_URL + '\"/>';\n                \n }",
75        "$ xns" : "Roo.grid",
76        "* prop" : "cm[]",
77        "dataIndex" : "active"
78       },
79       {
80        "xtype" : "ColumnModel",
81        "header" : "Database Column",
82        "width" : 150,
83        "$ renderer" : "function(v) { return String.format('{0}', v); }",
84        "$ xns" : "Roo.grid",
85        "* prop" : "cm[]",
86        "dataIndex" : "dataIndex"
87       },
88       {
89        "xtype" : "ColumnModel",
90        "width" : 100,
91        "header" : "Type",
92        "$ renderer" : "function(v) { return String.format('{0}', v); }",
93        "$ xns" : "Roo.grid",
94        "* prop" : "cm[]",
95        "dataIndex" : "type"
96       },
97       {
98        "xtype" : "ColumnModel",
99        "header" : "Label",
100        "width" : 75,
101        "$ renderer" : "function(v) { return String.format('{0}', v); }",
102        "$ xns" : "Roo.grid",
103        "* prop" : "cm[]",
104        "dataIndex" : "title",
105        "items" : [
106         {
107          "xtype" : "GridEditor",
108          "$ xns" : "Roo.grid",
109          "* prop" : "editor",
110          "items" : [
111           {
112            "xtype" : "TextField",
113            "$ xns" : "Roo.form",
114            "* prop" : "field"
115           }
116          ]
117         }
118        ]
119       },
120       {
121        "xtype" : "ColumnModel",
122        "width" : 75,
123        "header" : "Field Type",
124        "$ renderer" : "function(v) { return String.format('{0}', v); }",
125        "$ xns" : "Roo.grid",
126        "* prop" : "cm[]",
127        "dataIndex" : "ftype",
128        "items" : [
129         {
130          "xtype" : "GridEditor",
131          "$ xns" : "Roo.grid",
132          "* prop" : "editor",
133          "items" : [
134           {
135            "listWidth" : 200,
136            "triggerAction" : "all",
137            "displayField" : "fname",
138            "hiddenName" : "status",
139            "valueField" : "ftype",
140            "xtype" : "ComboBox",
141            "allowBlank" : false,
142            "editable" : false,
143            "width" : 150,
144            "$ xns" : "Roo.form",
145            "mode" : "local",
146            "name" : "status",
147            "* prop" : "field",
148            "items" : [
149             {
150              "xtype" : "SimpleStore",
151              "$ data" : "[ \n    [ 'ComboBox', \"ComboBox\"],\n    [ 'Text' , \"TextField\"],\n    [ 'Number', \"NumberField\"],\n    [ 'TextArea', \"TextArea\"],\n    [ 'Html', \"HtmlEntry\"]\n    \n]\n",
152              "$ fields" : "[  'ftype', 'fname']",
153              "$ xns" : "Roo.data",
154              "* prop" : "store"
155             }
156            ]
157           }
158          ]
159         }
160        ]
161       },
162       {
163        "xtype" : "ColumnModel",
164        "header" : "Display Field",
165        "width" : 75,
166        "$ renderer" : "function(v) { return String.format('{0}', v); }",
167        "$ xns" : "Roo.grid",
168        "* prop" : "cm[]",
169        "dataIndex" : "ftype",
170        "items" : [
171         {
172          "xtype" : "GridEditor",
173          "$ xns" : "Roo.grid",
174          "* prop" : "editor",
175          "items" : [
176           {
177            "listWidth" : 200,
178            "triggerAction" : "all",
179            "displayField" : "fname",
180            "hiddenName" : "status",
181            "valueField" : "ftype",
182            "xtype" : "ComboBox",
183            "allowBlank" : false,
184            "editable" : false,
185            "width" : 150,
186            "$ xns" : "Roo.form",
187            "mode" : "local",
188            "name" : "status",
189            "* prop" : "field",
190            "items" : [
191             {
192              "xtype" : "SimpleStore",
193              "$ data" : "[ \n    [ 'ComboBox', \"ComboBox\"],\n    [ 'Text' , \"TextField\"],\n    [ 'Number', \"NumberField\"],\n    [ 'TextArea', \"TextArea\"],\n    [ 'Html', \"HtmlEntry\"]\n    \n]\n",
194              "$ fields" : "[  'ftype', 'fname']",
195              "$ xns" : "Roo.data",
196              "* prop" : "store"
197             }
198            ]
199           }
200          ]
201         }
202        ]
203       },
204       {
205        "xtype" : "ColumnModel",
206        "width" : 75,
207        "header" : "Width",
208        "$ renderer" : "function(v) { return String.format('{0}', v); }",
209        "$ xns" : "Roo.grid",
210        "* prop" : "cm[]",
211        "dataIndex" : "width",
212        "items" : [
213         {
214          "xtype" : "GridEditor",
215          "$ xns" : "Roo.grid",
216          "* prop" : "editor",
217          "items" : [
218           {
219            "xtype" : "NumberField",
220            "Number decimalPrecision" : 0,
221            "$ xns" : "Roo.form",
222            "* prop" : "field"
223           }
224          ]
225         }
226        ]
227       }
228      ]
229     }
230    ]
231   }
232  ]
233 }