smas1 / geoext-viewer

Automatically exported from code.google.com/p/geoext-viewer
GNU General Public License v3.0
0 stars 0 forks source link

LayerNodeMenuItem: right mouse click error on non-layer-node nodes #368

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
From: Gergely Padányi-Gulyás:

"Dear Developers and Users,

I recently found a bug in the LayerNodeMenuItem class. When you right-click on 
a node that is not a layer (a folder, for instance), Firebug throws an error: 
TypeError: node.layer is undefined

The following modifications should take into consideration:

1. Heron.widgets.LayerNodeMenuItem.Style
Instead of
    isApplicable: function (node) {
        return node.layer.CLASS_NAME == 'OpenLayers.Layer.Vector';
    }

This
    isApplicable: function (node) {
        return typeof node.layer !== 'undefined' && node.layer.CLASS_NAME == 'OpenLayers.Layer.Vector';
    }

2. Heron.widgets.LayerNodeMenuItem.ZoomExtent
Instead of
    isApplicable: function (node) {
        // Layer: assume fixed maxExtent when set AND different from Map maxExtent
        this.hasMaxExtent = node.layer.maxExtent && !node.layer.maxExtent.equals(node.layer.map.maxExtent);
        return node.layer.getDataExtent() || this.hasMaxExtent;
    }

This
    isApplicable: function (node) {
        // Layer: assume fixed maxExtent when set AND different from Map maxExtent
        this.hasMaxExtent = typeof node.layer !== 'undefined' && node.layer.maxExtent && !node.layer.maxExtent.equals(node.layer.map.maxExtent);
        return typeof node.layer !== 'undefined' && (node.layer.getDataExtent() || this.hasMaxExtent);
    }

3. Heron.widgets.LayerNodeMenuItem.LayerInfo
Add the missing isApplicable method like this:
    isApplicable: function (node) {
        return typeof node.layer !== 'undefined';
    }

4. Heron.widgets.LayerNodeMenuItem.OpacitySlider
Add the missing isApplicable method like this:
    isApplicable: function (node) {
        return typeof node.layer !== 'undefined';
    }
"

Original issue reported on code.google.com by jus...@gmail.com on 30 Apr 2014 at 12:24