php7 fixes
[Pman.Builder] / Pman.Tab.BuilderTree.bjs
index cadb60b..b2e3448 100644 (file)
@@ -1,9 +1,9 @@
 {
-    "id": "roo-file-38",
+    "id": "roo-file-200",
     "name": "Pman.Tab.BuilderTree",
     "parent": "Pman.Tab.BuilderTab",
     "title": "Pman.Tab.BuilderTree",
-    "path": "/home/alan/gitlive/Pman.Builder/Pman.Tab.BuilderTree.bjs",
+    "path": "/home/edward/gitlive/Pman.Builder/Pman.Tab.BuilderTree.bjs",
     "items": [
         {
             "region": "west",
@@ -29,7 +29,7 @@
                         },
                         {
                             "listeners": {
-                                "activate": "function (_self)\n{\n    \n    _this.tree = _self.tree;\n    if (_this.hasMouseEvent) {\n        return;\n    }\n    \n    _this.hasMouseEvent = true;\n     this.el.on('mouseover', function() { _this.isMouseOver= true; });\n    this.el.on('mouseout', function() { _this.isMouseOver = false; });\n\n}"
+                                "activate": "function (_self)\n{\n    \n    _this.tree = _self.tree;\n    _this.menu = _self.menu;\n\n    if (_this.hasMouseEvent) {\n        return;\n    }\n    \n    _this.hasMouseEvent = true;\n  //   this.el.on('mouseover', function() { _this.isMouseOver= true; });\n     // this.el.on('mouseout', function() { _this.isMouseOver = false; });\n\n}"
                             },
                             "region": "center",
                             "xtype": "TreePanel",
                             "items": [
                                 {
                                     "listeners": {
-                                        "beforenodedrop": "function (e)\n{\n    // nodedragover handles the allow/disallow..\n    \n    /*\n    tree - The TreePanel\n    target - The node being targeted for the drop\n    data - The drag data from the drag source\n    point - The point of the drop - append, above or below\n    source - The drag source\n    rawEvent - Raw mouse event\n    dropNode - Drop node(s) provided by the source OR you can supply node(s) to be inserted by setting them on this object.\n    cancel - Set this to true to cancel the drop.\n    */\n    var np = e.point == 'append' ? e.target : e.target.parentNode ; // new parent\n      \n    if (!e.tree || !e.dropNode) {\n    \n        // form palete...\n        var data  = e.source.dragData.selections[0].data;\n\n        var xar = data.name.split('.');\n\n        var cfg = {\n            '|xns' : xar.shift(),\n            'xtype' : xar.join('.')\n        };\n        if (_this.dragProp.length > 1) {\n            cfg['*prop'] = _this.dragProp;\n        }\n        // at this point it should of a set of options...\n        this.appendNode(e.target, cfg, e.point);\n     \n        return; // fixme drop of elements from palete..\n    }\n\n    // always drop onto own parent\n    if (np == e.dropNode.parentNode) {\n        if (e.rawEvent.ctrlKey) {\n            e.dropNode = this.dupeNode(e.dropNode);\n        }\n        return true;\n    }\n    // can append has to use palete...\n    // this code should be in nodedragover.\n    \n    Roo.log(\"move checks need moving\");\n    return;\n    \n    if (_this.canAppend(np, e.dropNode.elConfig)) {\n        if (e.rawEvent.ctrlKey) {\n            e.dropNode = _this.dupeNode(e.dropNode);\n              \n            if (np.elConfig.xtype == 'GridEditor') {\n                e.dropNode.elConfig['*prop'] = 'field';\n            }\n            \n        }\n        return true;\n    }  \n    Roo.log('can not drop ' + e.dropNode.elConfig.xtype + ' ontop of ' + np.elConfig.xtype);\n    \n    \n    \n    return false;\n                        \n\n}",
-                                        "nodedrop": "function (e)\n{\n    \n    Roo.log(\"Node Drop\");\n    return;\n    e.dropNode.setText(\n        _this.configToText(e.dropNode.elConfig)\n        );\n        var bp = Pman.Tab.BuilderPanel;\n        bp.redraw.defer(1000, bp, [true]);\n\n}",
-                                        "click": "function (node, e)\n{\n      e.preventDefault();\n                       // console.log(e.button);\n        this.setCurrentNode(node);\n\n}",
-                                        "contextmenu": "function (node, e)\n{\n    e.stopEvent();\n        \n        this.getSelectionModel().select(node);\n         _this.setCurrentNode(node);\n        var xt = node.elConfig.xtype;\n        var altx= false;\n        if (typeof(node.elConfig['*prop']) != 'undefined') {\n            altx = node.parentNode.elConfig.xtype +'.' + node.elConfig['*prop'];\n        }\n        var mn = Pman.Tab.BuilderPalete.getMenu(xt,altx);\n        \n        \n        if (mn) {\n            mn.show(e.getTarget());\n        }\n        \n\n\n}",
-                                        "nodedragover": "function (e)\n{\n    Roo.log('nodedragover');\n     Roo.log(e);\n     // e.cancel..\n     // if we have within the same tree:\n       // dropNode (the node being dragged !!important!!) \n       // point: below, append\n       // target - node \n    // for palete\n        // dropNode = false;\n        // grid = the grid...\n        // source.dragData.selections[..] \n   \n    \n    // we can only check parents... (we in theory can check dupe properties.. but let's ignore that for the time being.)\n    \n    // ok off we go.\n    \n    if (!e.dropNode) {\n        // drag from palete..\n        if (!e.source.dragData.selections.length) {\n            e.cancel = true;\n            return;\n        }\n        var drop_rec = e.source.dragData.selections[0];\n        var drop_xtype = drop_rec.data.name;\n        var ok_parents = drop_rec.json.parents;\n        Roo.log(\"TEST PARENTS: \" + ok_parents.join(', '));\n        var new_parent = this.nodeXtype((e.point == 'append') ? e.target :  e.target.parentNode);\n        Roo.log(\"NEW PARENT: \" + e.point + \" = \" + new_parent);\n        \n        // see if the new_parent is actually in the list of ok_parents\n        e.cancel = true;\n        _this.dragProp = '';\n        Roo.each(ok_parents,function(n) {\n            if (n == new_parent || n.split(':').shift() == new_parent) {\n                e.cancel = false;\n                _this.dragProp = (n == new_parent) ?  '' : n.split(':').pop();\n                return true;\n            }\n        });\n        // done all the checks...\n        return;\n        \n    }\n     \n   \n}   \n    "
+                                        "beforenodedrop": "function (e)\n{\n    \n    return Pman.Builder.Tree.handleDropNode(e);      \n\n}",
+                                        "click": "function (node, e)\n{\n      e.preventDefault();\n                       // console.log(e.button);\n        Pman.Builder.Tree.setCurrentNode(node);\n        \n    \n        \n\n}",
+                                        "contextmenu": "function (node, e)\n{\n    e.stopEvent();\n        \n    this.getSelectionModel().select(node);\n     Pman.Builder.Tree.setCurrentNode(node);\n     \n          _this.menu = Roo.factory(_this.menu);\n\n        _this.menu.show(node.ui.textNode, 'tr');\n     return;\n     \n     /*\n    var xt = node.elConfig.xtype;\n    var altx= false;\n    if (typeof(node.elConfig['*prop']) != 'undefined') {\n        altx = node.parentNode.elConfig.xtype +'.' + node.elConfig['*prop'];\n    }\n    var mn = Pman.Tab.BuilderPalete.getMenu(xt,altx);\n    \n    \n    if (mn) {\n        mn.show(e.getTarget());\n    }\n    \n */\n\n}",
+                                        "nodedragover": "function (e)\n{\n    \n        return Pman.Builder.Tree.handleDragOver(e);      \n \n     \n   \n}   \n    "
                                     },
                                     "*prop": "tree",
                                     "animate": false,
                                     "enableDD": true,
                                     "rootVisible": true,
                                     "xtype": "TreePanel",
-                                    "|appendNode": "function(parent, inConfig, point) {\n    \n        \n \n    var items = [];\n    if (inConfig.items) { // loading!\n        items = inConfig.items;\n        delete inConfig.items;\n    }\n    \n    var config = this.cloneConfig(inConfig);\n    \n    if (!parent) {\n\tparent = this.root;\n    }\n          \n    var newNode = new Roo.tree.TreeNode({\n            text: this.configToText(config)\n    });\n            \n    \n    newNode.elConfig = config;\n    //if (markUndo === true) {\n    //Pman.Tab.Builder.markUndo(\"Add \" + newNode.text);\n    //\n        // appends to our tree...\n    console.log(\"APPEND NODE: \" + point);    \n    switch(point) {\n        case 'before':\n            parent.parentNode.insertBefore(newNode, parent);\n            break;\n        case 'after':\n            // if it's the last node.. then we append..\n            var ix = parent.parentNode.indexOf(parent) + 1;\n            if (parent.parentNode.childNodes.length == ix) {\n                 parent.parentNode.appendChild(newNode);\n                 break;\n            }\n            var bef = parent.parentNode.childNodes[ix];\n            parent.parentNode.insertBefore(newNode, bef);\n            break;\n        \n        case 'append':\n        default:    \n            parent.appendChild(newNode);\n            break;\n    }\n        \n    if (items.length) {\n        Roo.each(items, function(i) {\n            this.appendNode(newNode, i);\n        },this);\n        \n    }\n        \n        \n        /*\n        -- panels with panes...\n\t\tif (items && items.length) {\n\t\t\tfor (var i = 0; i < items.length; i++) {\n\t\t\t\t\tthis.appendConfig(items[i], newNode, false);\n\t\t\t}\n\t\t}\n\t\tif (opts.doUpdate !== false) {\n\t\t\tthis.updateForm(false, newNode);\n\t\t}\n        */\n    return newNode;\n\n\t \n}\n",
-                                    "|clearAll": "function() {\n    var rt = this.root;\n     if (rt.childNodes.length) {\n        rt.removeChild(rt.childNodes[0]);\n    }\n   \n    this.root.elConfig  = Roo.apply({ }, this.defaultElConfig());  \n    //var btop = Pman.Tab.BuilderTop;\n    //if (btop.modsel && btop.modsel.lastData) {\n    //    this.tree.root.elConfig.app = btop.modsel.lastData.app;\n    //}\n    \n    this.setCurrentNode(this.root,true);\n\n}\n",
-                                    "|cloneConfig": "function(config) {\n    if (!config) { return null; }\n    var newConfig = {};\n    \n    for (var i in config) {\n        if (typeof config[i] == 'object') {\n             newConfig[i] = this.cloneConfig(config[i]);\n        } else if (typeof config[i] != 'function') { // should this happen?\n             newConfig[i] = config[i];\n        }\n    }\n    return newConfig;\n}\n",
-                                    "|configToText": "function(c) {\n     \n\tvar txt = [];\n\tc = c || {};\n          var sr = (typeof(c['+buildershow']) != 'undefined') &&  !c['+buildershow'] ? true : false;\n        if (sr) txt.push('<s>');\n        if (typeof(c['*prop']) != 'undefined')   { txt.push(c['*prop']+ ':'); }\n\tif (c.xtype)      { txt.push(c.xtype); }\n\tif (c.fieldLabel) { txt.push('[' + c.fieldLabel + ']'); }\n\tif (c.boxLabel)   { txt.push('[' + c.boxLabel + ']'); }\n    \n    \n\tif (c.layout)     { txt.push('<i>' + c.layout + '</i>'); }\n\tif (c.title)      { txt.push('<b>' + c.title + '</b>'); }\n        if (c.header)    { txt.push('<b>' + c.header + '</b>'); }\n        if (c.legend)      { txt.push('<b>' + c.legend + '</b>'); }\n\tif (c.text)       { txt.push('<b>' + c.text + '</b>'); }\n        if (c.name)       { txt.push('<b>' + c.name+ '</b>'); }\n\tif (c.region)     { txt.push('<i>(' + c.region + ')</i>'); }\n        if (c.dataIndex) { txt.push('[' + c.dataIndex+ ']'); }\n        if (sr) txt.push('</s>');\n\treturn (txt.length == 0 ? \"Element\" : txt.join(\" \"));\n \n  \n}\n",
-                                    "|currentNodeType": "function() {\n    return this.nodeXtype(this.currentNode);\n \n}\n",
-                                    "|defaultElConfig": "function() {\n    return {\n       xtype : '*Module',\n        \n        module : 'TestApp',\n        part:   'Partname',\n        modkey : 0,\n        region : 'center',\n        parent : 'Pman',\n        name : 'Module Name',\n        items: [] \n    };\n}\n",
-                                    "|dupeNode": " function(node)\n    {\n        var cfg = this.cloneConfig(node.elConfig);\n        \n        var newNode = new Roo.tree.TreeNode(\n        {\n                id: Roo.id(),\n                text: this.configToText(cfg)\n        });\n        \n        newNode.elConfig = cfg;\n        node.eachChild(function(n) {\n            newNode.appendChild(this.dupeNode(n));\n        },this);\n        \n        return newNode;\n            \n    }",
-                                    "|loadBJS": "function(module, part) {\n    var _t = this;\n    new Pman.Request({\n        url : baseURL + '/Roo/Builder_part.php',\n        method : 'GET',\n        params : {\n           _id : part\n        },\n        success : function(res)         \n        {\n            // data is in.. \n            Roo.log(res);\n            _t.loadTree(JSON.parse(res.data.json));\n            \n         \n        },\n\n     })  \n        \n    \n    \n}\n",
-                                    "|loadTree": "function(o) {\n    this.clearAll();\n    this.root.elConfig = o;\n    this.root.setText(this.configToText(this.root.elConfig));\n    this.appendNode(this.root, o.items[0]);\n    this.root.expand(true);\n    Pman.Tab.BuilderView.panel.redraw();\n    this.setCurrentNode(this.root,true);\n}\n",
-                                    "|nodeXtype": "function(n) {\n     if (!n) {return ''; }\n    var xt = n.elConfig.xtype ||  '';\n    var xns= n.elConfig['|xns'] ||   '';\n    xns += xns.length ? '.' : '';\n    return xns + xt;\n}\n",
                                     "|renderer": "function(n) { return n.text; }",
-                                    "|setCurrentNode": "function(node,select) {\n        this.currentNode = node || this.root;\n        \n        //Pman.Tab.BuilderView.highlightElement(this.currentNode);\n\n        var p = Pman.Tab.BuilderProps.grid;\n        if (p) { //may not be ready yet..\n            p.setCurrrentNode(this.currentNode);\n        }\n        \n      \n        this.currentNode.setText(this.configToText(this.currentNode.elConfig));\n        \n        if (select) { //&& node !== this.tree.root) {\n            if (this.currentNode !== this.root)  {\n                     this.currentNode.ensureVisible();\n              }   \n             this.currentNode.expand(false,false);\n            this.currentNode.select();\n\t}\n\t// update palete..\n\tPman.Tab.BuilderPalette.grid.getSelectionModel().clearSelections();\n\tPman.Tab.BuilderPalette.grid.view.refresh();\n\n}\n",
                                     "|xns": "Roo.tree",
                                     "items": [
                                         {
                                             "*prop": "root",
                                             "text": "Part",
                                             "xtype": "TreeNode",
-                                            "|elConfig": "function() {\n    return  {\n         xtype : '*Module',\n            \n            app : 'TestApp',\n            // perm\n            // permtype\n            modkey : 0,\n            '|module' :  '',\n            region : 'center',\n            '|parent' : 'Pman',\n            name : \"Module Name\",\n            items: [] \n\n    \n    }\n}\n",
+                                            "|elConfig": "function() {\n    return  {\n         xtype : '*top',\n            \n            app : 'TestApp',\n            // perm\n            // permtype\n            modkey : 0,\n            '|module' :  '',\n            region : 'center',\n            '|parent' : 'Pman',\n            name : \"Module Name\",\n            items: [] \n\n    \n    }\n}\n",
                                             "|xns": "Roo.tree"
                                         }
                                     ]
+                                },
+                                {
+                                    "|xns": "Roo.menu",
+                                    "xtype": "Menu",
+                                    "*prop": "menu",
+                                    "items": [
+                                        {
+                                            "listeners": {
+                                                "click": "function (_self)\n{\n    \n    var str = Pman.Builder.Tree.currentNodeType();\n    if (typeof(Pman.Builder.Wizard[str]) == 'undefined') {\n        Roo.MessageBox.alert(\"Sorry\", \"No wizard exists for \" + str);\n        return;\n    }\n    var cn = Pman.Builder.Tree.currentNode;\n    if (typeof(cn.elConfig['.builderCfg']) == 'undefined') {\n        Roo.MessageBox.alert(\"Sorry\", \"No configuration exists for \" + str);\n        return;\n    }\n    \n    \n    var cfg = Roo.decode(cn.elConfig['.builderCfg']);\n    \n    Roo.log(cfg);\n    Pman.Dialog.BuilderAddTable.show( \n        cfg,  \n        function(data) {\n\n             \n            var res = Pman.Builder.Wizard[str](data); // with old..\n             Pman.Builder.Tree.replaceCurrentNode( res );\n             Pman.Tab.BuilderView.panel.redraw();\n \n       }\n    );\n\n   \n    // otherwise, call back with template??\n    \n   \n   \n        \n}"
+                                            },
+                                            "text": "Edit Using Wizard",
+                                            "xtype": "Item",
+                                            "|xns": "Roo.menu"
+                                        },
+                                        {
+                                            "|xns": "Roo.menu",
+                                            "xtype": "Separator"
+                                        },
+                                        {
+                                            "listeners": {
+                                                "click": "function (_self)\n{\n    \n      \n    Pman.Builder.Tree.collapseToggle();\n        \n}"
+                                            },
+                                            "text": "Toggle Collapse",
+                                            "xtype": "Item",
+                                            "|xns": "Roo.menu"
+                                        },
+                                        {
+                                            "listeners": {
+                                                "click": "function (_self)\n{\n    \n      \n    Pman.Builder.Tree.createSharedPart();\n        \n}"
+                                            },
+                                            "text": "Create shared part from this node",
+                                            "xtype": "Item",
+                                            "|xns": "Roo.menu"
+                                        },
+                                        {
+                                            "|xns": "Roo.menu",
+                                            "xtype": "Separator"
+                                        },
+                                        {
+                                            "listeners": {
+                                                "click": "function (_self)\n{\n    Roo.MessageBox.confirm(\"Confirm\", \"Are you sure you want to delete that node?\",\n        function(r) {\n            if (r!='yes') {\n                return;\n            }\n           Pman.Builder.Tree.deleteCurrent();\n        }\n    );\n        \n}"
+                                            },
+                                            "text": "Delete Node",
+                                            "xtype": "Item",
+                                            "|xns": "Roo.menu"
+                                        },
+                                        {
+                                            "text": "Save as template",
+                                            "xtype": "Item",
+                                            "|xns": "Roo.menu"
+                                        }
+                                    ]
                                 }
                             ]
                         }