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

compassinformatics / cpsi-mapview / 15022980938

14 May 2025 02:11PM UTC coverage: 26.333% (+0.04%) from 26.29%
15022980938

push

github

geographika
Move describe to test globals

492 of 2344 branches covered (20.99%)

Branch coverage included in aggregate %.

1464 of 5084 relevant lines covered (28.8%)

1.17 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
        const lower = Math.min(values[0], values[1]);
×
36
        const 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
        const slider = thumb.slider;
×
46
        const draggedValue = thumb.value;
×
47
        const thumbIdx = thumb.index;
×
48
        const otherThumb = slider.thumbs[thumbIdx == 0 ? 1 : 0];
×
49
        const lowerThumb =
50
            otherThumb.value <= draggedValue ? otherThumb : thumb;
×
51
        const upperThumb = lowerThumb === thumb ? otherThumb : thumb;
×
52
        let lower = lowerThumb.value;
×
53
        let upper = upperThumb.value;
×
54
        if (lower === draggedValue) {
×
55
            lower = '<strong>' + lower + '</strong>';
×
56
        }
57
        if (upper === draggedValue) {
×
58
            upper = '<strong>' + upper + '</strong>';
×
59
        }
60
        return lower + ' - ' + upper;
×
61
    },
62

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

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

109
        Ext.each(layers, function (layer) {
×
110
            let source = layer.getSource();
×
111
            if (source instanceof ol.source.Cluster) {
×
112
                source = source.getSource();
×
113
            }
114
            if (layer.get('isWfs')) {
×
115
                source.set('numericFilters', combined);
×
116
                source.clear();
×
117
                source.refresh();
×
118
            } else if (layer.get('isWms')) {
×
119
                // What about existing FILTER in params?
120
                // same goes for the case when we remove the filter, see below.
121
                // …Replace any existing filters for now
122
                source.updateParams({
×
123
                    FILTER: combined
124
                });
125
            }
126
        });
127
    },
128

129
    /**
130
     * Removes the effects of the slider, e.g. unfilters by the numeric values.
131
     */
132
    removeSliderEffects: function () {
133
        this.getAffectedLayers();
×
134
        const layers = this.getAffectedLayers();
×
135
        Ext.each(layers, function (layer) {
×
136
            let source = layer.getSource();
×
137
            if (source instanceof ol.source.Cluster) {
×
138
                source = source.getSource();
×
139
            }
140
            if (layer.get('isWfs')) {
×
141
                source.set('numericFilters', null);
×
142
                source.clear();
×
143
                source.refresh();
×
144
            } else if (layer.get('isWms')) {
×
145
                // …unset any existing filters for now
146
                source.updateParams({
×
147
                    FILTER: undefined
148
                });
149
            }
150
        });
151
    }
152
});
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