Pman.Tab.BuilderTop.bjs
[Pman.Builder] / Pman.Tab.BuilderTop.bjs
1 {
2     "id": "roo-file-83",
3     "name": "Pman.Tab.BuilderTop",
4     "parent": "Pman.Tab.BuilderTab",
5     "title": "Pman.Tab.BuilderTop",
6     "path": "/home/alan/gitlive/Pman.Builder/Pman.Tab.BuilderTop.bjs",
7     "items": [
8         {
9             "background": true,
10             "fitToFrame": true,
11             "region": "north",
12             "xtype": "ContentPanel",
13             "|xns": "Roo",
14             "items": [
15                 {
16                     "|xns": "Roo",
17                     "xtype": "Toolbar",
18                     "*prop": "toolbar",
19                     "items": [
20                         {
21                             "text": "Manage Modules",
22                             "xtype": "Button",
23                             "|xns": "Roo.Toolbar",
24                             "items": [
25                                 {
26                                     "|xns": "Roo.menu",
27                                     "xtype": "Menu",
28                                     "*prop": "menu",
29                                     "items": [
30                                         {
31                                             "listeners": {
32                                                 "click": "function (_self, e)\n{\n    Pman.Dialog.BuilderModule.show({\n         id : 0\n    },function(data) {\n        if (data) {\n           _this.modsel.setFromData(data);\n        }\n    });\n\n}"
33                                             },
34                                             "text": "Create",
35                                             "xtype": "Item",
36                                             "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'",
37                                             "|xns": "Roo.menu"
38                                         },
39                                         {
40                                             "listeners": {
41                                                 "click": "function (_self, e)\n{\n \n    if (!_this.modsel.getValue()) {\n        Roo.MessageBox.alert(\"Error\", \"Select Module\");\n        return false;\n    }\n    Pman.Dialog.BuilderModule.show( { id : _this.modsel.getValue() } ,function(data) {\n        if (data) {\n            _this.modsel.setFromData(data);\n        }\n    });\n\n}"
42                                             },
43                                             "text": "Edit",
44                                             "xtype": "Item",
45                                             "|xns": "Roo.menu"
46                                         },
47                                         {
48                                             "listeners": {
49                                                 "click": "function (_self, e)\n{\n   \n\n}"
50                                             },
51                                             "text": "Delete",
52                                             "xtype": "Item",
53                                             "|xns": "Roo.menu"
54                                         },
55                                         {
56                                             "|xns": "Roo.menu",
57                                             "xtype": "Separator"
58                                         },
59                                         {
60                                             "listeners": {
61                                                 "click": "function (_self, e)\n{\n    new Pman.Request({\n        method : 'GET',\n        url : baseURL + '/Roo/Builder_modules.php',\n        params : {\n            'query[_sync]' : 1\n        },\n        success : function() {\n            Roo.MessageBox.alert(\"Done\", \"Re-syned modules\");\n        }\n    });\n}"
62                                             },
63                                             "text": "Sync",
64                                             "xtype": "Item",
65                                             "|xns": "Roo.menu"
66                                         }
67                                     ]
68                                 }
69                             ]
70                         },
71                         {
72                             "listeners": {
73                                 "select": "function (combo, record, index)\n{\n    _this.filesel.reset();\n    _this.filesel.fireEvent('select', false);\n\n}",
74                                 "render": "function (_self)\n{\n    _this.modsel = this;\n}"
75                             },
76                             "allowBlank": true,
77                             "alwaysQuery": true,
78                             "displayField": "name",
79                             "editable": false,
80                             "forceSelection": true,
81                             "listWidth": 300,
82                             "loadingText": "Searching...",
83                             "minChars": 2,
84                             "pageSize": 40,
85                             "queryParam": "query[name]",
86                             "selectOnFocus": true,
87                             "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{name}</b></div>",
88                             "triggerAction": "all",
89                             "typeAhead": true,
90                             "valueField": "id",
91                             "width": 100,
92                             "xtype": "ComboBox",
93                             "|xns": "Roo.form",
94                             "items": [
95                                 {
96                                     "*prop": "store",
97                                     "remoteSort": true,
98                                     "xtype": "Store",
99                                     "|sortInfo": "{ field : 'name' , direction : 'ASC' }",
100                                     "|xns": "Roo.data",
101                                     "items": [
102                                         {
103                                             "*prop": "proxy",
104                                             "method": "GET",
105                                             "xtype": "HttpProxy",
106                                             "|url": "baseURL + '/Roo/Builder_modules.php'",
107                                             "|xns": "Roo.data"
108                                         },
109                                         {
110                                             "*prop": "reader",
111                                             "id": "id",
112                                             "root": "data",
113                                             "totalProperty": "total",
114                                             "xtype": "JsonReader",
115                                             "|fields": "[\n \n    {\n        'name': 'name',\n        'type': 'string'\n    }\n    \n]",
116                                             "|xns": "Roo.data"
117                                         }
118                                     ]
119                                 }
120                             ]
121                         },
122                         {
123                             "text": "Manage Parts ",
124                             "xtype": "Button",
125                             "|xns": "Roo.Toolbar",
126                             "items": [
127                                 {
128                                     "|xns": "Roo.menu",
129                                     "xtype": "Menu",
130                                     "*prop": "menu",
131                                     "items": [
132                                         {
133                                             "listeners": {
134                                                 "click": "function (_self, e)\n{\n    if (!_this.modsel.getValue()) {\n        Roo.MessageBox.alert(\"Error\", \"Select Module\");\n        return false;\n    }\n    \n    Pman.Dialog.BuilderPart.show( {\n             id : 0, \n             module_id: _this.modsel.getValue() \n         } ,\n         function(data) {\n            _this.filesel.reset();\n            if (!data.id) {\n                return;\n            }\n            _this.filesel.setfromdata(data);\n            Pman.Tab.BuilderTree.clearAll();\n            Pman.Tab.BuilderTree.setCurrentNode(Pman.Tab.BuilderTree.tree.root,true);\n            \n            var bp = Pman.Tab.BuilderPanel;\n            bp.redraw.defer(100,bp,[true]);\n    });\n\n}"
135                                             },
136                                             "text": "New Part",
137                                             "xtype": "Item",
138                                             "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'",
139                                             "|xns": "Roo.menu"
140                                         },
141                                         {
142                                             "text": "Delete",
143                                             "xtype": "Item",
144                                             "|xns": "Roo.menu"
145                                         }
146                                     ]
147                                 }
148                             ]
149                         },
150                         {
151                             "listeners": {
152                                 "select": "function (combo, rec, index)\n{\n   //cb.lastData = rec.data;\n    \n    \n    \n    \n    var bt = Pman.Tab.BuilderTree.tree;\n    \n    \n    if (!rec) {\n        bt.clearAll();\n        bt.setCurrentNode(bt.root,true);\n       // var bv = Pman.Tab.BuilderView;\n       Pman.Tab.BuilderView.panel.clearAll();\n       // bv.panel.el.mask(\"select Module / Part\");\n        return;\n    }\n    //bv.panel.el.unmask();\n    \n    bt.loadBJS(_this.modsel.getValue(), rec.data.id)\n\n\n}",
153                                 "render": "function (_self)\n{\n    _this.filesel = this;\n}"
154                             },
155                             "allowBlank": true,
156                             "alwaysQuery": true,
157                             "displayField": "name",
158                             "editable": false,
159                             "forceSelection": true,
160                             "listWidth": 400,
161                             "loadingText": "Searching...",
162                             "minChars": 2,
163                             "pageSize": 40,
164                             "queryParam": "query[name]",
165                             "selectOnFocus": true,
166                             "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{name}</b></div>",
167                             "triggerAction": "all",
168                             "typeAhead": true,
169                             "valueField": "id",
170                             "width": 200,
171                             "xtype": "ComboBox",
172                             "|xns": "Roo.form",
173                             "items": [
174                                 {
175                                     "listeners": {
176                                         "beforeload": "function (_self, o)\n{\n     o.params = o.params || {}; \n   // o.params.btype = 'FORM';\n    if (!_this.modsel.getValue()) {\n        Roo.MessageBox.alert(\"Error\", \"Select Module\");\n        return false;\n    }\n    o.params.module_id = _this.modsel.getValue();\n    o.params._columns = 'id,name';\n}"
177                                     },
178                                     "*prop": "store",
179                                     "remoteSort": true,
180                                     "xtype": "Store",
181                                     "|sortInfo": "{ field : 'name' , direction : 'ASC' }",
182                                     "|xns": "Roo.data",
183                                     "items": [
184                                         {
185                                             "*prop": "proxy",
186                                             "method": "GET",
187                                             "xtype": "HttpProxy",
188                                             "|url": "baseURL + '/Roo/Builder_part.php'",
189                                             "|xns": "Roo.data"
190                                         },
191                                         {
192                                             "*prop": "reader",
193                                             "id": "id",
194                                             "root": "data",
195                                             "totalProperty": "total",
196                                             "xtype": "JsonReader",
197                                             "|fields": "[\n   \n    {\n        'name': 'name',\n        'type': 'string'\n    } \n]",
198                                             "|xns": "Roo.data"
199                                         }
200                                     ]
201                                 }
202                             ]
203                         },
204                         {
205                             "listeners": {
206                                 "click": "function (_self, e)\n{\n    this.save();\n}",
207                                 "render": "function (_self)\n{\n   _this.saveBtn = this;\n}"
208                             },
209                             "cls": "x-btn-text-icon",
210                             "text": "Save",
211                             "xtype": "Button",
212                             "|save": "function() {\n       // first see if first element has a name.. - we can not save otherwise..\n        var t = Pman.Tab.BuilderTree.tree;\n        if (!t.root.elConfig.name.length) {\n            Roo.MessageBox.alert(\"Error\", \"No name set for form\");\n            return;\n        }\n     \n        sid = (typeof(sid) == 'undefined') ?  (this.filesel.lastData ? this.filesel.lastData.id : 0) : sid;\n        \n        var js = Pman.Tab.BuilderTree.toJS();\n        var json = Roo.encode(js);\n       // console.log(js);\n       // console.log(json);\n        \n        // check the select box to see if that has been set... - save it with that id..\n        \n        var _this = this;\n        \n        Pman.request({\n            url: baseURL + '/Roo/Builder.php',\n            method : 'POST',\n            params : {\n                json : json,\n                name : t.root.elConfig.name,\n                module : t.root.elConfig['|module'],\n                app : t.root.elConfig.app,\n                btype : 'FORM',\n                id : sid\n            }, \n            success : function(data) {\n                // set the fileSel!!\n                console.log(data);\n                if (data) {\n                    _this.filesel.setFromData(data);\n                    if (cb) {\n                        cb.call(_this,data);\n                    }\n                    _this.postCode(data);\n                }\n            }\n        });\n}\n",
213                             "|icon": "rootURL + '/Pman/templates/images/save.gif'",
214                             "|xns": "Roo.Toolbar",
215                             "items": [
216                                 {
217                                     "|xns": "Roo.menu",
218                                     "xtype": "Menu",
219                                     "*prop": "menu",
220                                     "items": [
221                                         {
222                                             "listeners": {
223                                                 "click": "function (_self, e)\n{\n  _this.saveBtn.save(false,0);\n}"
224                                             },
225                                             "|icon": "rootURL + '/Pman/templates/images/save.gif'",
226                                             "text": "Save a copy as",
227                                             "xtype": "Item",
228                                             "|xns": "Roo.menu"
229                                         },
230                                         {
231                                             "listeners": {
232                                                 "click": "function (_self, e)\n{\n   _this.saveBtn.save(\n     function() {\n         Pman.Dialog.BuilderViewCode.show({ id : _this.filesel.getValue() } ); \n            \n\n  } );\n}"
233                                             },
234                                             "text": "Show JSON",
235                                             "xtype": "Item",
236                                             "|xns": "Roo.menu"
237                                         }
238                                     ]
239                                 }
240                             ]
241                         },
242                         {
243                             "|xns": "Roo.Toolbar",
244                             "xtype": "Separator"
245                         },
246                         {
247                             "listeners": {
248                                 "click": "function (_self, e)\n{\n   Pman.Tab.BuilderView.panel.redraw();\n}"
249                             },
250                             "text": "Redraw",
251                             "xtype": "SplitButton",
252                             "|xns": "Roo.Toolbar",
253                             "items": [
254                                 {
255                                     "|xns": "Roo.menu",
256                                     "xtype": "Menu",
257                                     "*prop": "menu",
258                                     "items": [
259                                         {
260                                             "listeners": {
261                                                 "click": "function (_self, e)\n{\n _this.redrawBtn.setText(\"Redraw (AUTO OFF)\");\n    _this.redrawBtn.auto = 0;\n\n}"
262                                             },
263                                             "text": "Auto redraw - OFF",
264                                             "xtype": "Item",
265                                             "|xns": "Roo.menu"
266                                         },
267                                         {
268                                             "listeners": {
269                                                 "click": "function (_self, e)\n{\n \n    _this.redrawBtn.setText(\"Redraw\");\n     _this.redrawBtn.auto = 1;\n    var bp = Pman.Tab.BuilderPanel;\n    bp.redraw.defer(100,bp,[true]);\n    \n\n}"
270                                             },
271                                             "text": "Auto redraw - On",
272                                             "xtype": "Item",
273                                             "|xns": "Roo.menu"
274                                         }
275                                     ]
276                                 }
277                             ]
278                         }
279                     ]
280                 }
281             ]
282         }
283     ],
284     "permname": "",
285     "modOrder": "001"
286 }