var tree = Pman.Tab.BuilderTree.tree;
-
+ if (typeof(inConfig) == 'undefined') {
+ return;
+ }
var items = [];
- if (inConfig.items) { // loading!
+ if (typeof(inConfig) !== 'undefined' && inConfig.items) { // loading!
items = inConfig.items;
delete inConfig.items;
}
var config = this.cloneConfig(inConfig);
+ var hidden = config['builder.hidden'] || false;
+
if (!parent) {
parent = tree.root;
}
var newNode = new Roo.tree.TreeNode({
- text: this.configToText(config)
+ text: this.configToText(config)
});
-
-
+
newNode.elConfig = config;
+
//if (markUndo === true) {
//Pman.Tab.Builder.markUndo("Add " + newNode.text);
//
switch(point) {
case 'above':
parent.parentNode.insertBefore(newNode, parent);
+ parent.parentNode.expand(true);
break;
case 'below':
// if it's the last node.. then we append..
}
var bef = parent.parentNode.childNodes[ix];
parent.parentNode.insertBefore(newNode, bef);
+ parent.parentNode.expand(true);
break;
case 'append':
default:
parent.appendChild(newNode);
+ parent.expand(true);
break;
}
-
+
+ newNode.ui.ctNode.style.display = hidden ? 'none' : '';
+
if (items.length) {
Roo.each(items, function(i) {
this.appendNode(newNode, i);
var newConfig = {};
for (var i in config) {
+ if (i.match(/^builder\./)) {
+ continue;
+ }
if (typeof config[i] == 'object') {
newConfig[i] = this.cloneConfig(config[i]);
} else if (typeof config[i] != 'function') { // should this happen?
var txt = [];
c = c || {};
var sr = (typeof(c['+buildershow']) != 'undefined') && !c['+buildershow'] ? true : false;
- if (sr) txt.push('<s>');
+ if (sr) {
+ txt.push('<s>');
+ }
if (typeof(c['*prop']) != 'undefined') { txt.push(c['*prop']+ ':'); }
if (c.xtype) { txt.push(c.xtype); }
if (c.fieldLabel) { txt.push('[' + c.fieldLabel + ']'); }
if (c.name) { txt.push('<b>' + c.name+ '</b>'); }
if (c.region) { txt.push('<i>(' + c.region + ')</i>'); }
if (c.dataIndex) { txt.push('[' + c.dataIndex+ ']'); }
- if (sr) txt.push('</s>');
+ if (sr) {
+ txt.push('</s>');
+ }
return (txt.length == 0 ? "Element" : txt.join(" "));
items: []
};
},
+
+ replaceCurrentNode : function(cfg)
+ {
+ var tree = Pman.Tab.BuilderTree.tree;
+
+ if (this.currentNode == tree.root) {
+ return false;
+ }
+ var pn = this.currentNode.parentNode;
+
+ var ix = pn.indexOf(this.currentNode);
+ pn.removeChild(this.currentNode);
+
+ if (!pn.childNodes.length) {
+ this.appendNode(pn, cfg, 'append');
+ return true;
+ }
+ if (!ix) {
+ // first..
+ this.appendNode(pn.childNodes[0], cfg, 'above');
+ return true;
+
+ }
+
+ this.appendNode(pn.childNodes[ix-1], cfg, 'below');
+
+
+ return true;
+ },
+
+ collapseToggle : function()
+ {
+ var tree = Pman.Tab.BuilderTree.tree;
+
+ if (this.currentNode == tree.root) {
+ return false;
+ }
+ var cfg = this.currentNode.elConfig;
+ // things that can not be deleted...
+ var hidden = cfg['builder.hidden'] || 0;
+ if (hidden) {
+ delete cfg['builder.hidden'];
+ } else {
+ cfg['builder.hidden'] = 1;
+ }
+
+
+ this.currentNode.ui.ctNode.style.display = !hidden ? 'none' : '';
+
+
+ //this.setCurrentNode(pn.childNodes.length ? pn.childNodes[ix] : pn ,true);
+ return true;
+ },
+
+
+
+
deleteCurrent : function()
{
+
+ var tree = Pman.Tab.BuilderTree.tree;
+
if (this.currentNode == tree.root) {
return false;
}
var pn = this.currentNode.parentNode;
-
+ // work out if we make the next or parent the 'current node'
var ix = pn.indexOf(this.currentNode);
// console.log(ix);
pn.removeChild(this.currentNode);
return true;
},
dupeNode : function(node)
- {
+ {
var cfg = this.cloneConfig(node.elConfig);
var newNode = new Roo.tree.TreeNode(
return newNode;
},
- loadBJS : function(module, part) {
+ loadBJS : function(module, part)
+ {
var _t = this;
new Pman.Request({
url : baseURL + '/Roo/Builder_part.php',
nodeXtype : function(n)
{
var tree = Pman.Tab.BuilderTree.tree;
- if (!n) {return ''; }
+ if (!n || !n.elConfig) {return ''; }
var xt = n.elConfig.xtype || '';
var xns= n.elConfig['|xns'] || '';
xns += xns.length ? '.' : '';
var cls = cfg['|xns'] + '.' + cfg['xtype'];
- if (typeof(Pman.Builder[cls]) != 'undefined') {
+ if (typeof(Pman.Builder.Wizard[cls]) != 'undefined') {
Pman.Dialog.BuilderAdd.show( cfg , function(fdata ) {
-
-
+
_t.appendNode(e.target, fdata , e.point);
-
+ Pman.Tab.BuilderView.panel.redraw();
+
});
return false;
}
}
// can append has to use palete...
// this code should be in nodedragover.
-
- Roo.log("move checks need moving");
- return false;
+ if (e.dropNode) {
+ var cfg = this.toJS(e.dropNode);
+ this.appendNode(e.target, cfg, e.point);
+ }
+ Roo.log('no e.dropNode?');
+ return false; // do not allow movement..
if (_this.canAppend(np, e.dropNode.elConfig)) {
if (e.rawEvent.ctrlKey) {
this.dragProp = '';
var _t = this;
Roo.each(ok_parents, function(n) {
- if (n == new_parent || n.split(':').shift() == new_parent) {
+ Roo.log("compare "+n+" ? " + new_parent);
+ if (n == new_parent || n.split(':').shift() == new_parent) {
Roo.log("got match!");
e.cancel = false;
_t.dragProp = (n == new_parent) ? '' : n.split(':').pop();
return true;
- }
- return false;
+ }
+ return null;
});
// done all the checks...
return;
- }
+ }
- }
-
+
+ // have a drop node - hence comming from the same object..
+ var drop_xtype = this.nodeXtype(e.dropNode);
+ // currently we can not determine validity..
+ e.cancel = false;
+ return ;
+
+
+
+ },
+ save : function()
+ {
+ // first see if first element has a name.. - we can not save otherwise..
+ var t = Pman.Tab.BuilderTree.tree;
+ if (!t.root.elConfig.name.length) {
+ Roo.MessageBox.alert("Error", "No name set for form");
+ return;
+ }
+
+ var sid = (typeof(sid) == 'undefined') ?
+ (Pman.Tab.BuilderTop.filesel.lastData ? Pman.Tab.BuilderTop.filesel.lastData.id : 0) : sid;
+
+
+ var js = this.toJS();
+ var render = new Pman.Builder.JsRender(js);
+
+ // console.log(js);
+ // console.log(json);
+
+ // check the select box to see if that has been set... - save it with that id..
+
+ //var _this = this;
+
+ Pman.request({
+ url: baseURL + '/Roo/Builder_part.php',
+ method : 'POST',
+ params : {
+ json : Roo.encode(js, null, 4),
+ jsource : render.toSource(),
+ name : js.name,
+ module_id : Pman.Tab.BuilderTop.modsel.getValue(),
+ id : sid
+ },
+ success : function(data) {
+ // set the fileSel!!
+ console.log(data);
+ //if (data) {
+ // _this.filesel.setFromData(data);
+// if (cb) {
+// cb.call(_this,data);
+ // }
+// _this.postCode(data);
+// }
+ }
+ });
+}
+
}
\ No newline at end of file