Giter Site home page Giter Site logo

Comments (7)

afawcett avatar afawcett commented on July 30, 2024

I have reproduced this and will look into it.

from apex-mdapi.

afawcett avatar afawcett commented on July 30, 2024

I've upload a fix to the MetadataDeployController.cls file, please take a look at the latest and try it.

from apex-mdapi.

parthv4u avatar parthv4u commented on July 30, 2024

Thanks Andrew ! It worked and everything works fine now . I'm working on placing a search field in Metadatabrowser page where you have used ExtJs . I'm getting runtime exception there . Could you please help me.?

from apex-mdapi.

afawcett avatar afawcett commented on July 30, 2024

I can try

from apex-mdapi.

parthv4u avatar parthv4u commented on July 30, 2024

Have referred to link : http://try.sencha.com/extjs/4.1.1/community/treefilter/ which is a tree filter and have integrated this tree filter in my code. The search functionality is working but there are issues that i'm facing are

  1. It gives me an error "Developer script exception from Gmail : MetadataDataController : Attempt to de-reference a null object " in my inbox. Example , when i try to search 'weblink ' it does search it but fires me the above error.

Now this search field sometimes work or sometimes doesn't work.Tried in with Google chrome and Firefox but there is no permanent sols that i'm getting.

  1. While i search 'weblink ' and again backspace it , it should give the full list but the same scenario , it shows me sometimes and sometime it doesn't. Below is my code

<apex:page sidebar="false" controller="MetadataDataController">

<script type="text/javascript" src="{!URLFOR($Resource.extjs, 'ext-all-debug.js')}"></script>
<script>

    Ext.onReady(function() {
     Ext.define('TreeFilter', {
    extend: 'Ext.AbstractPlugin'
        , alias: 'plugin.treefilter'
        , collapseOnClear: true                                                 // collapse all nodes when  clearing/resetting the filter
        , allowParentFolders: false                                             // allow nodes not designated as 'leaf' (and their child items) to  be matched by the filter
        , init: function (tree) {
            var me = this;
            me.tree = tree;

            tree.filter = Ext.Function.bind(me.filter, me);
            tree.clearFilter = Ext.Function.bind(me.clearFilter, me);
        }
        , filter: function (value, property, re) {
            var me = this
                , tree = me.tree
                , matches = []                                                  // array of nodes matching the search criteria
                , root = tree.getRootNode()                                     // root node of the tree
                , property = property || 'text'                                 // property is optional - will be set to the 'text' propert of the  treeStore record by default
                , re = re || new RegExp(value, "ig")                            // the regExp could be modified to allow for case-sensitive, starts  with, etc.
                , visibleNodes = []                                             // array of nodes matching the search criteria + each parent non-leaf  node up to root
                , viewNode;

            if (Ext.isEmpty(value)) {                                           // if the search field is empty
                me.clearFilter();
                return;
            }
            tree.expandAll();                                                   // expand all nodes for the the following iterative routines

            // iterate over all nodes in the tree in order to evalute them against the search criteria
            root.cascadeBy(function (node) {
                if (node.get(property).match(re)) {                             // if the node matches the search criteria and is a leaf (could be  modified to searh non-leaf nodes)
                    matches.push(node);                                         // add the node to the matches array
                }
            });

            if (me.allowParentFolders === false) {                              // if me.allowParentFolders is false (default) then remove any  non-leaf nodes from the regex match
                Ext.each(matches, function (match)
                 {
                    if (!match.isLeaf()) 
                    {
                        System.debug("Matches leaf");
                        Ext.Array.remove(matches, match);
                        Console.log(match);
                    }
                });
            }

            Ext.each(matches, function (item, i, arr) {                         // loop through all matching leaf nodes
                root.cascadeBy(function (node) {                                // find each parent node containing the node from the matches array
                    if (node.contains(item) == true) {
                        visibleNodes.push(node);                                // if it's an ancestor of the evaluated node add it to the visibleNodes  array
                    }
                });
                if (me.allowParentFolders === true && !item.isLeaf()) {        // if me.allowParentFolders is true and the item is  a non-leaf item
                    item.cascadeBy(function (node) {                            // iterate over its children and set them as visible
                        visibleNodes.push(node);
                    });
                }
                visibleNodes.push(item);                                        // also add the evaluated node itself to the visibleNodes array
            });

            root.cascadeBy(function (node) {                                    // finally loop to hide/show each node
                viewNode = Ext.fly(tree.getView().getNode(node));               // get the dom element assocaited with each node
                if (viewNode) {                                                 // the first one is undefined ? escape it with a conditional
                    viewNode.setVisibilityMode(Ext.Element.DISPLAY);            // set the visibility mode of the dom node to display (vs offsets)
                    viewNode.setVisible(Ext.Array.contains(visibleNodes, node));
                }
            });
        }

        , clearFilter: function () {
            var me = this
                , tree = this.tree
                , root = tree.getRootNode();

            if (me.collapseOnClear) {
                tree.collapseAll();                                             // collapse the tree nodes
            }
            root.cascadeBy(function (node) {                                    // final loop to hide/show each node
                viewNode = Ext.fly(tree.getView().getNode(node));               // get the dom element assocaited with each node
                if (viewNode) {                                                 // the first one is undefined ? escape it with a conditional and show  all nodes
                    viewNode.show();
                }
            });
        }
});
        var store = Ext.create('Ext.data.TreeStore', {
            proxy: {
                type: 'ajax',
                url: '{!$Page.metadatadata}'
            },
            sorters: [{
                property: 'leaf',
                direction: 'ASC'
            }, {
                property: 'text',
                direction: 'ASC'
            }]
        });

        var tree = Ext.create('Ext.tree.Panel', {
            store: store,
            rootVisible: false,
            useArrows: true,
            frame: true,
            title: 'Metadata Components',
            renderTo: Ext.getBody(),
            width: 500,
            height: 500,
           plugins: [{
             ptype: 'treefilter',
         allowParentFolders: true
    }]
    , dockedItems: [{
        xtype: 'toolbar'
        , dock: 'top'
        , items: [{
            xtype: 'trigger'
            , triggerCls: 'x-form-clear-trigger'
            , onTriggerClick: function () {
                this.reset();
                this.focus();
            }
            , listeners: {
                change: function (field, newVal) {
                    var tree = field.up('treepanel');
                    tree.filter(newVal);
                }
                , buffer: 250
            }
        }]
    }]
        });
            tree.on('checkchange', 
            function(node, checked, eOpts) 
            {
                Ext.each(node.childNodes, 
                    function(child) 
                    {
                        child.set('checked', checked); 
                    });
            });
    });
</script>
<apex:outputPanel id="appcanvas">
 </apex:outputPanel>  

/apex:page

I'm learning lot from these.Please help.

from apex-mdapi.

afawcett avatar afawcett commented on July 30, 2024

Ah you've reached the extend of my Sencha skills on this without putting in a ton of time to research it to help, which i'd love to do if i had the time at the moment, so sorry i cannot help further. Maybe one of the Sencha forums?

from apex-mdapi.

parthv4u avatar parthv4u commented on July 30, 2024

I got this error solved . Many thanks to you Andrew , got to learn a lot about Metadata API from you .Thanks again !

from apex-mdapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.