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 (e)
122 Roo.log("Node Drop");
125 _this.configToText(e.dropNode.elConfig)
127 var bp = Pman.Tab.BuilderPanel;
128 bp.redraw.defer(1000, bp, [true]);
131 click : function (node, e)
134 // console.log(e.button);
135 this.setCurrentNode(node);
138 contextmenu : function (node, e)
142 this.getSelectionModel().select(node);
143 _this.setCurrentNode(node);
144 var xt = node.elConfig.xtype;
146 if (typeof(node.elConfig['*prop']) != 'undefined') {
147 altx = node.parentNode.elConfig.xtype +'.' + node.elConfig['*prop'];
149 var mn = Pman.Tab.BuilderPalete.getMenu(xt,altx);
153 mn.show(e.getTarget());
159 nodedragover : function (e)
161 Roo.log('nodedragover');
164 // if we have within the same tree:
165 // dropNode (the node being dragged !!important!!)
166 // point: below, append
170 // grid = the grid...
171 // source.dragData.selections[..]
174 // we can only check parents... (we in theory can check dupe properties.. but let's ignore that for the time being.)
179 // drag from palete..
180 if (!e.source.dragData.selections.length) {
184 var drop_rec = e.source.dragData.selections[0];
185 var drop_xtype = drop_rec.data.name;
186 var ok_parents = drop_rec.json.parents;
187 Roo.log("TEST PARENTS: " + ok_parents.join(', '));
188 var new_parent = this.nodeXtype((e.point == 'append') ? e.target.parentNode : e.target);
189 Roo.log("NEW PARENT: " + new_parent);
191 // see if the new_parent is actually in the list of ok_parents
193 Roo.each(ok_parents,function(n) {
194 if (n == new_parent || n.split(':').shift() == new_parent) {
199 // done all the checks...
206 dragdrop : function (_self, node, dd, e)
208 Roo.log("Drag Drop");
213 containerScroll : true,
214 ddGroup : 'component',
217 appendNode : function(parent, inConfig, markUndo) {
222 if (inConfig.items) { // loading!
223 items = inConfig.items;
224 delete inConfig.items;
226 var config = this.cloneConfig(inConfig);
233 //var canAppend = this.canAppend(parent,config);
234 //if (canAppend !== true) {
235 // console.log("Unable to add element " + canAppend);
236 // Roo.Msg.alert("Unable to add element", canAppend);
240 var newNode = new Roo.tree.TreeNode({
241 text: this.configToText(config)
245 newNode.elConfig = config;
246 //if (markUndo === true) {
247 //Pman.Tab.Builder.markUndo("Add " + newNode.text);
249 // appends to our tree...
250 parent.appendChild(newNode);
254 Roo.each(items, function(i) {
255 this.appendNode(newNode, i);
262 -- panels with panes...
263 if (items && items.length) {
264 for (var i = 0; i < items.length; i++) {
265 this.appendConfig(items[i], newNode, false);
268 if (opts.doUpdate !== false) {
269 this.updateForm(false, newNode);
276 clearAll : function() {
278 if (rt.childNodes.length) {
279 rt.removeChild(rt.childNodes[0]);
282 this.root.elConfig = Roo.apply({ }, this.defaultElConfig());
283 //var btop = Pman.Tab.BuilderTop;
284 //if (btop.modsel && btop.modsel.lastData) {
285 // this.tree.root.elConfig.app = btop.modsel.lastData.app;
288 this.setCurrentNode(this.root,true);
291 cloneConfig : function(config) {
292 if (!config) { return null; }
295 for (var i in config) {
296 if (typeof config[i] == 'object') {
297 newConfig[i] = this.cloneConfig(config[i]);
298 } else if (typeof config[i] != 'function') { // should this happen?
299 newConfig[i] = config[i];
304 configToText : function(c) {
308 var sr = (typeof(c['+buildershow']) != 'undefined') && !c['+buildershow'] ? true : false;
309 if (sr) txt.push('<s>');
310 if (typeof(c['*prop']) != 'undefined') { txt.push(c['*prop']+ ':'); }
311 if (c.xtype) { txt.push(c.xtype); }
312 if (c.fieldLabel) { txt.push('[' + c.fieldLabel + ']'); }
313 if (c.boxLabel) { txt.push('[' + c.boxLabel + ']'); }
316 if (c.layout) { txt.push('<i>' + c.layout + '</i>'); }
317 if (c.title) { txt.push('<b>' + c.title + '</b>'); }
318 if (c.header) { txt.push('<b>' + c.header + '</b>'); }
319 if (c.legend) { txt.push('<b>' + c.legend + '</b>'); }
320 if (c.text) { txt.push('<b>' + c.text + '</b>'); }
321 if (c.name) { txt.push('<b>' + c.name+ '</b>'); }
322 if (c.region) { txt.push('<i>(' + c.region + ')</i>'); }
323 if (c.dataIndex) { txt.push('[' + c.dataIndex+ ']'); }
324 if (sr) txt.push('</s>');
325 return (txt.length == 0 ? "Element" : txt.join(" "));
329 currentNodeType : function() {
330 return this.nodeXtype(this.currentNode);
333 defaultElConfig : function() {
342 name : 'Module Name',
346 loadBJS : function(module, part) {
349 url : baseURL + '/Roo/Builder_part.php',
354 success : function(res)
358 _t.loadTree(JSON.parse(res.data.json));
368 loadTree : function(o) {
370 this.root.elConfig = o;
371 this.root.setText(this.configToText(this.root.elConfig));
372 this.appendNode(this.root, o.items[0]);
373 this.root.expand(true);
374 Pman.Tab.BuilderView.panel.redraw();
375 this.setCurrentNode(this.root,true);
377 nodeXtype : function(n) {
378 if (!n) {return ''; }
379 var xt = n.elConfig.xtype || '';
380 var xns= n.elConfig['|xns'] || '';
381 xns += xns.length ? '.' : '';
384 renderer : function(n) { return n.text; },
385 setCurrentNode : function(node,select) {
386 this.currentNode = node || this.root;
388 //Pman.Tab.BuilderView.highlightElement(this.currentNode);
390 var p = Pman.Tab.BuilderProps.grid;
391 if (p) { //may not be ready yet..
392 p.setCurrrentNode(this.currentNode);
396 this.currentNode.setText(this.configToText(this.currentNode.elConfig));
398 if (select) { //&& node !== this.tree.root) {
399 if (this.currentNode !== this.root) {
400 this.currentNode.ensureVisible();
402 this.currentNode.expand(false,false);
403 this.currentNode.select();
406 Pman.Tab.BuilderPalette.grid.getSelectionModel().clearSelections();
407 Pman.Tab.BuilderPalette.grid.view.refresh();
411 xtype: 'DefaultSelectionModel',
418 elConfig : function() {
429 name : "Module Name",
440 xtype: 'LayoutRegion',
444 xtype: 'LayoutRegion',
451 this.layout = this.panel.layout;