• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

geographika / cpsi-mapview / 6275612987

22 Sep 2023 02:33PM UTC coverage: 19.833%. Remained the same
6275612987

push

github

geographika
Remove raf.polyfill.js as only required for IE9 or less

372 of 2475 branches covered (0.0%)

Branch coverage included in aggregate %.

1176 of 5330 relevant lines covered (22.06%)

1.93 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

1.18
/app/controller/panel/NumericAttributeSlider.js
1
/**
2
 * This is the controller for the {@link CpsiMapview.view.panel.NumericAttributeSlider} component
3
 *
4
 * @class CpsiMapview.controller.panel.NumericAttributeSlider
5
 */
6
Ext.define('CpsiMapview.controller.panel.NumericAttributeSlider', {
1✔
7
    extend: 'Ext.app.ViewController',
8

9
    requires: ['BasiGX.util.Layer'],
10

11
    alias: 'controller.cmv_numericattributeslider',
12

13
    /**
14
     * Initially filter if enabled.
15
     */
16
    initSlider: function() {
17
        if (this.getView().getEnabled()) {
×
18
            this.applySliderEffects();
×
19
        }
20
    },
21

22
    /**
23
     * Returns those layers that the slider will affect.
24
     */
25
    getAffectedLayers: function() {
26
        return BasiGX.util.Layer.getLayersBy('isNumericDependent', true);
×
27
    },
28

29
    /**
30
     * Orders the values of the slider so that the first index always is the
31
     * lower value, and the second is at least equally big.
32
     * @param {number[]} values
33
     */
34
    orderValues: function(values) {
35
        var lower = Math.min(values[0], values[1]);
×
36
        var upper = Math.max(values[0], values[1]);
×
37
        return [lower, upper];
×
38
    },
39

40
    /**
41
     * Returns the current range of the slider as tooltip.
42
     * @param {Ext.slider.Thumb} thumb
43
     */
44
    getTipText: function(thumb) {
45
        var slider = thumb.slider;
×
46
        var draggedValue = thumb.value;
×
47
        var thumbIdx = thumb.index;
×
48
        var otherThumb = slider.thumbs[thumbIdx == 0 ? 1 : 0];
×
49
        var lowerThumb = otherThumb.value <= draggedValue ? otherThumb : thumb;
×
50
        var upperThumb = lowerThumb === thumb ? otherThumb : thumb;
×
51
        var lower = lowerThumb.value;
×
52
        var upper = upperThumb.value;
×
53
        if (lower === draggedValue) {
×
54
            lower = '<strong>' + lower + '</strong>';
×
55
        }
56
        if (upper === draggedValue) {
×
57
            upper = '<strong>' + upper + '</strong>';
×
58
        }
59
        return lower + ' - ' + upper;
×
60
    },
61

62
    /**
63
     * Handles the changing of the checked state of the active-checkbox.
64
     * @param {Ext.form.field.Checkbox} cb
65
     * @param {boolean} checked
66
     */
67
    onCheckChange: function(cb, checked) {
68
        var slider = cb.up().down('multislider');
×
69
        if(slider) {
×
70
            slider.setDisabled(!checked);
×
71
        }
72
        if(checked) {
×
73
            this.applySliderEffects();
×
74
        } else {
75
            this.removeSliderEffects();
×
76
        }
77
    },
78

79
    /**
80
     * Applies the effect of the slider, e.g. filters by the numeric values.
81
     */
82
    applySliderEffects: function() {
83
        var me = this;
×
84
        var view = me.getView();
×
85
        var slider = view.down('multislider');
×
86
        var orderedVals = me.orderValues(slider.getValues());
×
87
        var layers = me.getAffectedLayers();
×
88
        var fieldName = view.getNumericField();
×
89
        // between-filter is also inclusive
90
        var gteFilter = GeoExt.util.OGCFilter.getOgcFilter(
×
91
            fieldName, 'gte', orderedVals[0], '2.0.0'
92
        );
93
        var lteFilter = GeoExt.util.OGCFilter.getOgcFilter(
×
94
            fieldName, 'lte', orderedVals[1], '2.0.0'
95
        );
96
        var combined = GeoExt.util.OGCFilter.combineFilters(
×
97
            [gteFilter, lteFilter], 'And', false
98
        );
99

100
        Ext.each(layers, function(layer) {
×
101
            var source = layer.getSource();
×
102
            if (source instanceof ol.source.Cluster) {
×
103
                source = source.getSource();
×
104
            }
105
            if (layer.get('isWfs')) {
×
106
                source.set('numericFilters', combined);
×
107
                source.clear();
×
108
                source.refresh();
×
109
            } else if (layer.get('isWms')) {
×
110
                // What about existing FILTER in params?
111
                // same goes for the case when we remove the filter, see below.
112
                // …Replace any existing filters for now
113
                source.updateParams({
×
114
                    'FILTER': combined
115
                });
116
            }
117
        });
118
    },
119

120
    /**
121
     * Removes the effects of the slider, e.g. unfilters by the numeric values.
122
     */
123
    removeSliderEffects: function () {
124
        this.getAffectedLayers();
×
125
        var layers = this.getAffectedLayers();
×
126
        Ext.each(layers, function(layer) {
×
127
            var source = layer.getSource();
×
128
            if (source instanceof ol.source.Cluster) {
×
129
                source = source.getSource();
×
130
            }
131
            if (layer.get('isWfs')) {
×
132
                source.set('numericFilters', null);
×
133
                source.clear();
×
134
                source.refresh();
×
135
            } else if (layer.get('isWms')) {
×
136
                // …unset any existing filters for now
137
                source.updateParams({
×
138
                    'FILTER': undefined
139
                });
140
            }
141
        });
142
    }
143
});
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc