AEM CQ 56 - Working with siteadmin tree nodes

Goal


Disable Geometrixx site nodes in the left tree of siteadmin Websites console. Package available for install

This post is for demonstration purposes only. Ideally, on production systems, the Geometrixx nodes should be completely uninstalled




Solution


1) Login to CRXDE Lite, create folder (nt:folder) /apps/sadisabletreenodes

2) Create clientlib (type cq:ClientLibraryFolder/apps/sadisabletreenodes/clientlib and set a property categories of String type to cq.widgets

3) Create file ( type nt:file ) /apps/sadisabletreenodes/clientlib/js.txt, add the following

                         disabletreenodes.js

4) Create file ( type nt:file ) /apps/sadisabletreenodes/clientlib/disabletreenodes.js, add the following code

CQ.Ext.ns("MyClientLib");

MyClientLib.SiteAdmin = {
    SA_TREE: "cq-siteadmin-tree",

    disableGeometrixx: function(tree){
        if(!tree){
            return;
        }

        var node = tree.getRootNode();

        node.on('expand',function(){
            CQ.Ext.each(this.childNodes, function(cNode){
                var disable = cNode.attributes["name"].indexOf("geometrixx") == 0;

                if(disable === true){
                    cNode.setCls("x-item-disabled");
                    var disableFn = function(){
                        return false;
                    };
                    cNode.on('beforeclick', disableFn);
                    cNode.on('beforedblclick', disableFn);
                    cNode.on('beforeexpand', disableFn);
                    cNode.on('beforecollapse', disableFn);
                    cNode.on('beforeinsert', disableFn);
                    cNode.on('beforemove', disableFn);
                    cNode.on('beforeremove', disableFn);
                }
            });
        });

        //collapse and expand to fire the expand event,
        node.collapse();
        node.expand();
    }
};

(function(){
    if(window.location.pathname == "/siteadmin"){
        var INTERVAL = setInterval(function(){
            var s = MyClientLib.SiteAdmin;
            var tree = CQ.Ext.getCmp(s.SA_TREE);

            if(tree){
                clearInterval(INTERVAL);
                s.disableGeometrixx(tree);
            }
        }, 250);
    }
})();


1 comment: