1 //<script type="text/javascript">
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
7 // register the module first
8 Pman.on('beforeload', function()
11 modKey : '001-Pman.Tab.BuilderTree',
12 module : Pman.Tab.BuilderTree,
14 parent : Pman.Tab.BuilderTab,
15 name : "Pman.Tab.BuilderTree",
21 Pman.Tab.BuilderTree = new Roo.util.Observable({
27 add : function(parentLayout, region)
31 this.parentLayout = parentLayout;
33 this.panel = parentLayout.addxtype({
34 xtype: 'NestedLayoutPanel',
38 xtype: 'BorderLayout',
45 activate : function (_self)
48 _this.tree = _self.tree;
49 if (_this.hasMouseEvent) {
53 _this.hasMouseEvent = true;
54 this.el.on('mouseover', function() { _this.isMouseOver= true; });
55 this.el.on('mouseout', function() { _this.isMouseOver = false; });
64 beforenodedrop : function (e)
68 target - The node being targeted for the drop
69 data - The drag data from the drag source
70 point - The point of the drop - append, above or below
71 source - The drag source
72 rawEvent - Raw mouse event
73 dropNode - Drop node(s) provided by the source OR you can supply node(s) to be inserted by setting them on this object.
74 cancel - Set this to true to cancel the drop.
77 if (!e.tree || !e.dropNode) {
78 console.log('no tree or dropNode');
79 return; // fixme drop of elements from palete..
81 var np = false; // new parent
86 np = e.target.parentNode;
93 // always drop onto own parent
94 if (np == e.dropNode.parentNode) {
95 if (e.rawEvent.ctrlKey) {
96 e.dropNode = _this.dupeNode(e.dropNode);
100 if (_this.canAppend(np, e.dropNode.elConfig)) {
101 if (e.rawEvent.ctrlKey) {
102 e.dropNode = _this.dupeNode(e.dropNode);
104 if (np.elConfig.xtype == 'GridEditor') {
105 e.dropNode.elConfig['*prop'] = 'field';
111 console.log('can not drop ' + e.dropNode.elConfig.xtype + ' ontop of ' + np.elConfig.xtype);
119 nodedrop : function (dropEvent)
122 _this.configToText(e.dropNode.elConfig)
124 var bp = Pman.Tab.BuilderPanel;
125 bp.redraw.defer(1000, bp, [true]);
128 click : function (node, e)
131 // console.log(e.button);
132 this.setCurrentNode(node);
135 contextmenu : function (node, e)
139 this.getSelectionModel().select(node);
140 _this.setCurrentNode(node);
141 var xt = node.elConfig.xtype;
143 if (typeof(node.elConfig['*prop']) != 'undefined') {
144 altx = node.parentNode.elConfig.xtype +'.' + node.elConfig['*prop'];
146 var mn = Pman.Tab.BuilderPalete.getMenu(xt,altx);
150 mn.show(e.getTarget());
156 nodedragover : function (e)
158 Roo.log('nodedragover');
161 // if we have within the same tree:
162 // dropNode (the node being dragged !!important!!)
163 // point: below, append
167 // grid = the grid...
168 // source.dragData.selection[..]
171 // we can only check parents... (we in theory can check dupe properties.. but let's ignore that for the time being.)
176 // drag from palete..
177 if (!e.target.source.dragData.selection.length) {
181 var drop_rec = e.target.source.dragData.selection[0];
182 var drop_xtype = drop_rec.data.name;
183 var ok_parents = drop_rec.json.parents;
185 var new_parent = this.nodeXtype((e.point == 'append') ? e.target.parentNode : e.target);
194 containerScroll : true,
195 ddGroup : 'component',
198 appendNode : function(parent, inConfig, markUndo) {
203 if (inConfig.items) { // loading!
204 items = inConfig.items;
205 delete inConfig.items;
207 var config = this.cloneConfig(inConfig);
214 //var canAppend = this.canAppend(parent,config);
215 //if (canAppend !== true) {
216 // console.log("Unable to add element " + canAppend);
217 // Roo.Msg.alert("Unable to add element", canAppend);
221 var newNode = new Roo.tree.TreeNode({
222 text: this.configToText(config)
226 newNode.elConfig = config;
227 //if (markUndo === true) {
228 //Pman.Tab.Builder.markUndo("Add " + newNode.text);
230 // appends to our tree...
231 parent.appendChild(newNode);
235 Roo.each(items, function(i) {
236 this.appendNode(newNode, i);
243 -- panels with panes...
244 if (items && items.length) {
245 for (var i = 0; i < items.length; i++) {
246 this.appendConfig(items[i], newNode, false);
249 if (opts.doUpdate !== false) {
250 this.updateForm(false, newNode);
257 clearAll : function() {
259 if (rt.childNodes.length) {
260 rt.removeChild(rt.childNodes[0]);
263 this.root.elConfig = Roo.apply({ }, this.defaultElConfig());
264 //var btop = Pman.Tab.BuilderTop;
265 //if (btop.modsel && btop.modsel.lastData) {
266 // this.tree.root.elConfig.app = btop.modsel.lastData.app;
269 this.setCurrentNode(this.root,true);
272 cloneConfig : function(config) {
273 if (!config) { return null; }
276 for (var i in config) {
277 if (typeof config[i] == 'object') {
278 newConfig[i] = this.cloneConfig(config[i]);
279 } else if (typeof config[i] != 'function') { // should this happen?
280 newConfig[i] = config[i];
285 configToText : function(c) {
289 var sr = (typeof(c['+buildershow']) != 'undefined') && !c['+buildershow'] ? true : false;
290 if (sr) txt.push('<s>');
291 if (typeof(c['*prop']) != 'undefined') { txt.push(c['*prop']+ ':'); }
292 if (c.xtype) { txt.push(c.xtype); }
293 if (c.fieldLabel) { txt.push('[' + c.fieldLabel + ']'); }
294 if (c.boxLabel) { txt.push('[' + c.boxLabel + ']'); }
297 if (c.layout) { txt.push('<i>' + c.layout + '</i>'); }
298 if (c.title) { txt.push('<b>' + c.title + '</b>'); }
299 if (c.header) { txt.push('<b>' + c.header + '</b>'); }
300 if (c.legend) { txt.push('<b>' + c.legend + '</b>'); }
301 if (c.text) { txt.push('<b>' + c.text + '</b>'); }
302 if (c.name) { txt.push('<b>' + c.name+ '</b>'); }
303 if (c.region) { txt.push('<i>(' + c.region + ')</i>'); }
304 if (c.dataIndex) { txt.push('[' + c.dataIndex+ ']'); }
305 if (sr) txt.push('</s>');
306 return (txt.length == 0 ? "Element" : txt.join(" "));
310 currentNodeType : function() {
311 if (!this.currentNode) {return ''; }
312 var xt = this.currentNode.elConfig.xtype || '';
313 var xns= this.currentNode.elConfig['|xns'] || '';
314 xns += xns.length ? '.' : '';
318 defaultElConfig : function() {
327 name : 'Module Name',
331 loadBJS : function(module, part) {
334 url : baseURL + '/Roo/Builder_part.php',
339 success : function(res)
343 _t.loadTree(JSON.parse(res.data.json));
353 loadTree : function(o) {
355 this.root.elConfig = o;
356 this.root.setText(this.configToText(this.root.elConfig));
357 this.appendNode(this.root, o.items[0]);
358 this.root.expand(true);
359 Pman.Tab.BuilderView.panel.redraw();
360 this.setCurrentNode(this.root,true);
362 renderer : function(n) { return n.text; },
363 setCurrentNode : function(node,select) {
364 this.currentNode = node || this.root;
366 //Pman.Tab.BuilderView.highlightElement(this.currentNode);
368 var p = Pman.Tab.BuilderProps.grid;
369 if (p) { //may not be ready yet..
370 p.setCurrrentNode(this.currentNode);
374 this.currentNode.setText(this.configToText(this.currentNode.elConfig));
376 if (select) { //&& node !== this.tree.root) {
377 if (this.currentNode !== this.root) {
378 this.currentNode.ensureVisible();
380 this.currentNode.expand(false,false);
381 this.currentNode.select();
384 Pman.Tab.BuilderPalette.grid.getSelectionModel().clearSelections();
385 Pman.Tab.BuilderPalette.grid.view.refresh();
389 xtype: 'DefaultSelectionModel',
396 elConfig : function() {
407 name : "Module Name",
418 xtype: 'LayoutRegion',
422 xtype: 'LayoutRegion',
429 this.layout = this.panel.layout;