// Auto generated file - created by app.Builder.js- do not edit directly (at present!)
-
-
-// register the module first
-Pman.on('beforeload', function()
-{
- Pman.register({
- part : ["Builder","Database"],
- modKey : '999-Pman.Tab.BuilderDatabase',
- module : Pman.Tab.BuilderDatabase,
- region : 'center',
- parent : Pman.Tab.Builder,
- name : "Pman.Tab.BuilderDatabase",
- disabled : false,
- permname: ''
- });
-});
-
-Pman.Tab.BuilderDatabase = new Roo.util.Observable({
-
- panel : false,
- disabled : false,
- parentLayout: false,
-
- add : function(parentLayout, region)
+Pman.Tab.BuilderDatabase = new Roo.XComponent({
+ part : ["Builder","Database"],
+ order : '999-Pman.Tab.BuilderDatabase',
+ region : 'center',
+ parent : 'Pman.Tab.Builder',
+ name : "Pman.Tab.BuilderDatabase",
+ disabled : false,
+ permname : '',
+ _tree : function()
{
-
var _this = this;
- this.parentLayout = parentLayout;
-
- this.panel = parentLayout.addxtype({
+ var MODULE = this;
+ return {
xtype: 'NestedLayoutPanel',
xns: Roo,
+ listeners : {
+ activate : function (_self)
+ {
+ _this.treepanel.tree.root.reload();
+ }
+ },
+ background : true,
region : 'center',
title : "Manage Database",
layout : {
}
},
text : "Sync Tables"
+ },
+ {
+ xtype: 'Separator',
+ xns: Roo.menu
+ },
+ {
+ xtype: 'Item',
+ xns: Roo.menu,
+ listeners : {
+ click : function (_self, e)
+ {
+ /*
+ var node = _this.treepanel.tree.getSelectionModel().getSelectedNode();
+
+ if(!node){
+ Roo.MessageBox.alert('Error', 'Please select a table');
+ return;
+ }
+
+ Roo.log(node.attributes.name);
+ */
+ new Pman.Download({
+ url : baseURL + '/Roo/Builder_tables.php',
+ timeout : 900000,
+ params : {
+ _dumpDatabase : 1
+ },
+ method : 'GET',
+ success : function() {
+
+ }
+ });
+ }
+ },
+ text : "Export Data"
}
]
}
tree : {
xtype: 'TreePanel',
xns: Roo.tree,
+ listeners : {
+ beforeload : function (node)
+ {
+ if (!_this.panel.active) {
+ return false;
+ }
+ },
+ contextmenu : function (node, e)
+ {
+ if (!node.expanded || node.leaf) {
+ return;
+ }
+
+ _this.treepanel.menu = Roo.factory(_this.treepanel.menu);
+ _this.treepanel.menu.show(node.ui.anchor,'tr');
+ _this.cxnode = node;
+ },
+ beforenodedrop : function (dropEvent)
+ {
+ Roo.log(dropEvent);
+ var node = dropEvent.dropNode;
+ var targ = dropEvent.target;
+ var parent = dropEvent.target;
+ switch(dropEvent.point) {
+ case 'below':
+ case 'above':
+ parent = dropEvent.target.parentNode;
+ break;
+ default:
+ break;
+ }
+ // technically you should not be able to drag tables into other modules..
+ if (parent.attributes.id < 1) {
+ dropEvent.cancel = 1;
+ }
+ new Pman.Request({
+ url : baseURL + '/Roo/Builder_tables',
+ params : {
+ id : node.attributes.id,
+ parent_id : parent.attributes.id
+ }
+ });
+
+
+ }
+ },
+ containerScroll : true,
ddGroup : 'dbtree',
- enableDrag : true,
- enableDrop : true,
+ enableDD : true,
rootVisible : false,
loader : {
xtype: 'TreeLoader',
xns: Roo.tree,
+ listeners : {
+ create : function (_self, attr)
+ {
+ Roo.log("CREATE");
+ try {
+ attr.text = attr.name.length ? attr.name : attr.descrip;
+
+ attr.leaf = attr.name.length ? true : false;
+ attr.html = String.format('<B>{0}</B><i>{1}</i>',
+ attr.name,
+ attr.descrip
+ );
+ } catch(e) {
+ Roo.log(e);
+ }
+ Roo.log(attr);
+
+ }
+ },
queryParam : 'parent_id',
requestMethod : 'GET',
root : 'data',
- baseParams : { _tree: 1, 'sort': 'name', dir: 'ASC' },
+ baseParams : { _tree: 1, 'sort': 'name', dir: 'ASC', limit : 9999 },
dataUrl : baseURL + '/Roo/Builder_tables.php'
},
+ sm : {
+ xtype: 'MultiSelectionModel',
+ xns: Roo.tree
+ },
root : {
xtype: 'AsyncTreeNode',
xns: Roo.tree,
text : "TOP LEVEL"
+ },
+ editor : {
+ xtype: 'TreeEditor',
+ xns: Roo.tree,
+ listeners : {
+ beforenodeedit : function (_self,node)
+ {
+ Roo.log('before start edit');
+ Roo.log(this.editNode);
+ if (node.attributes.name.length) {
+ return false;
+ }
+ return true;
+
+ },
+ complete : function (_self, value, startValue)
+ {
+ Roo.log(this.editNode);
+
+ var attr = this.editNode.attributes;
+
+ var pa = this.editNode.parentNode.attributes;
+ Roo.log(pa);
+ var pr = {
+
+ parent_id : pa.id,
+ descrip : value,
+ name : '',
+ dbschema : ''
+ };
+
+ if (attr.id > 0) {
+ pr.id = attr.id;
+ }
+
+ new Pman.Request({
+ url : baseURL + '/Roo/Builder_tables',
+ method : 'POST',
+ params : pr
+ });
+
+
+
+ }
+ }
}
+ },
+ menu : {
+ xtype: 'Menu',
+ xns: Roo.menu,
+ items : [
+ {
+ xtype: 'Item',
+ xns: Roo.menu,
+ listeners : {
+ click : function (_self, e)
+ {
+ _this.nIndex = _this.nIndex || 0;
+
+ var m = _this.cxnode.firstChild ? 'insertBefore' : 'appendChild';
+ var tree = _this.treepanel.tree;
+
+ var n = tree.loader.createNode({
+ id : -1,
+ descrip :'New Group ' + (++_this.nIndex),
+ name : ''
+ });
+
+ var node = _this.cxnode[m]( n , _this.cxnode.firstChild);
+ setTimeout(function(){
+ tree.editor.editNode = node;
+ tree.editor.startEdit(node.ui.textNode);
+ }, 10);
+ }
+ },
+ text : "Add Group"
+ },
+ {
+ xtype: 'Separator',
+ xns: Roo.menu
+ },
+ {
+ xtype: 'Item',
+ xns: Roo.menu,
+ listeners : {
+ click : function (_self, e)
+ {
+ _this.nIndex = _this.nIndex || 0;
+
+ _this.cxnode;
+ // try and delete it..
+ new Pman.Request({
+ url : baseURL + '/Roo/Builder_tables',
+ params : {
+ _delete : _this.cxnode.attributes.id
+ },
+ success : function() {
+ _this.cxnode.parentNode.removeChild(_this.cxnode);
+ _this.cxnode = false;
+
+ }
+ });
+
+ }
+ },
+ text : "Remove Group"
+ }
+ ]
}
},
{
xns: Roo
}
}
- });
- this.layout = this.panel.layout;
-
+ };
}
});