Improve the precise input element, normalize 'and' to check if it is empty (and to check if no filter is active)
This commit is contained in:
parent
475b89a794
commit
a4f4365d71
10 changed files with 262 additions and 28 deletions
|
@ -5,7 +5,19 @@ export class And extends TagsFilter {
|
|||
|
||||
constructor(and: TagsFilter[]) {
|
||||
super();
|
||||
this.and = and;
|
||||
this.and = and
|
||||
}
|
||||
|
||||
normalize(){
|
||||
const ands = []
|
||||
for (const c of this.and) {
|
||||
if(c instanceof And){
|
||||
ands.push(...c.and)
|
||||
}else{
|
||||
ands.push(c)
|
||||
}
|
||||
}
|
||||
return new And(ands)
|
||||
}
|
||||
|
||||
private static combine(filter: string, choices: string[]): string[] {
|
||||
|
@ -64,17 +76,6 @@ export class And extends TagsFilter {
|
|||
return false;
|
||||
}
|
||||
|
||||
for (const selfTag of this.and) {
|
||||
let matchFound = false;
|
||||
for (let i = 0; i < other.and.length && !matchFound; i++) {
|
||||
let otherTag = other.and[i];
|
||||
matchFound = selfTag.isEquivalent(otherTag);
|
||||
}
|
||||
if (!matchFound) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (const selfTag of this.and) {
|
||||
let matchFound = false;
|
||||
for (const otherTag of other.and) {
|
||||
|
|
|
@ -2,7 +2,7 @@ import { Utils } from "../Utils";
|
|||
|
||||
export default class Constants {
|
||||
|
||||
public static vNumber = "0.9.5";
|
||||
public static vNumber = "0.9.6";
|
||||
|
||||
// The user journey states thresholds when a new feature gets unlocked
|
||||
public static userJourney = {
|
||||
|
|
|
@ -18,7 +18,7 @@ export default class Minimap extends BaseUIElement {
|
|||
private _allowMoving: boolean;
|
||||
private readonly _leafletoptions: any;
|
||||
private readonly _onFullyLoaded: (leaflet: L.Map) => void
|
||||
private readonly _attribution: BaseUIElement;
|
||||
private readonly _attribution: BaseUIElement | boolean;
|
||||
private readonly _lastClickLocation: UIEventSource<{ lat: number; lon: number }>;
|
||||
|
||||
constructor(options?: {
|
||||
|
@ -26,7 +26,7 @@ export default class Minimap extends BaseUIElement {
|
|||
location?: UIEventSource<Loc>,
|
||||
allowMoving?: boolean,
|
||||
leafletOptions?: any,
|
||||
attribution?: BaseUIElement,
|
||||
attribution?: BaseUIElement | boolean,
|
||||
onFullyLoaded?: (leaflet: L.Map) => void,
|
||||
leafletMap?: UIEventSource<Map>,
|
||||
lastClickLocation?: UIEventSource<{ lat: number, lon: number }>
|
||||
|
@ -122,8 +122,12 @@ export default class Minimap extends BaseUIElement {
|
|||
);
|
||||
|
||||
if (this._attribution !== undefined) {
|
||||
if(this._attribution === true){
|
||||
map.attributionControl.setPrefix(false)
|
||||
}else{
|
||||
map.attributionControl.setPrefix(
|
||||
"<span id='leaflet-attribution'>A</span>");
|
||||
"<span id='leaflet-attribution'></span>");
|
||||
}
|
||||
}
|
||||
|
||||
this._background.addCallbackAndRun(layer => {
|
||||
|
@ -141,7 +145,9 @@ export default class Minimap extends BaseUIElement {
|
|||
}
|
||||
map.addLayer(newLayer);
|
||||
map.setMaxZoom(layer.max_zoom ?? map.getMaxZoom())
|
||||
self._attribution?.AttachTo('leaflet-attribution')
|
||||
if (self._attribution !== true && self._attribution !== false) {
|
||||
self._attribution?.AttachTo('leaflet-attribution')
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
|
|
@ -215,7 +215,10 @@ export default class SimpleAddUI extends Toggle {
|
|||
const disableFiltersOrConfirm = new Toggle(
|
||||
openLayerOrConfirm,
|
||||
disableFilter,
|
||||
preset.layerToAddTo.appliedFilters.map(filters => filters === undefined || filters.and.length === 0)
|
||||
preset.layerToAddTo.appliedFilters.map(filters => {
|
||||
console.log("Current filters are ", filters)
|
||||
return filters === undefined || filters.normalize().and.length === 0;
|
||||
})
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@ export default class ExportPDF {
|
|||
private _screenhotTaken = false;
|
||||
|
||||
public isRunning = new UIEventSource(true)
|
||||
public loadedTiles = new UIEventSource(0)
|
||||
|
||||
constructor(
|
||||
options: {
|
||||
|
|
|
@ -10,6 +10,7 @@ import AvailableBaseLayers from "../../Logic/Actors/AvailableBaseLayers";
|
|||
import {GeoOperations} from "../../Logic/GeoOperations";
|
||||
import ShowDataLayer from "../ShowDataLayer";
|
||||
import LayoutConfig from "../../Models/ThemeConfig/LayoutConfig";
|
||||
import * as L from "leaflet";
|
||||
|
||||
export default class LocationInput extends InputElement<Loc> {
|
||||
|
||||
|
@ -103,7 +104,7 @@ export default class LocationInput extends InputElement<Loc> {
|
|||
this._value = this._snappedPoint.map(f => {
|
||||
const [lon, lat] = f.geometry.coordinates;
|
||||
return {
|
||||
lon: lon, lat: lat, zoom: undefined
|
||||
lon: lon, lat: lat, zoom: undefined
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -122,16 +123,59 @@ export default class LocationInput extends InputElement<Loc> {
|
|||
|
||||
protected InnerConstructElement(): HTMLElement {
|
||||
try {
|
||||
const clickLocation = new UIEventSource<Loc>(undefined);
|
||||
const map = new Minimap(
|
||||
{
|
||||
location: this._centerLocation,
|
||||
background: this.mapBackground
|
||||
background: this.mapBackground,
|
||||
attribution: this.mapBackground !== State.state.backgroundLayer,
|
||||
lastClickLocation: clickLocation
|
||||
}
|
||||
)
|
||||
clickLocation.addCallbackAndRunD(location => this._centerLocation.setData(location))
|
||||
map.leafletMap.addCallbackAndRunD(leaflet => {
|
||||
leaflet.setMaxBounds(
|
||||
leaflet.getBounds().pad(0.15)
|
||||
)
|
||||
const bounds = leaflet.getBounds()
|
||||
leaflet.setMaxBounds(bounds.pad(0.15))
|
||||
const data = {
|
||||
type: "FeatureCollection",
|
||||
features: [{
|
||||
"type": "Feature",
|
||||
"geometry": {
|
||||
"type": "LineString",
|
||||
"coordinates": [
|
||||
[
|
||||
bounds.getEast(),
|
||||
bounds.getNorth()
|
||||
],
|
||||
[
|
||||
bounds.getWest(),
|
||||
bounds.getNorth()
|
||||
],
|
||||
[
|
||||
bounds.getWest(),
|
||||
bounds.getSouth()
|
||||
],
|
||||
|
||||
[
|
||||
bounds.getEast(),
|
||||
bounds.getSouth()
|
||||
],
|
||||
[
|
||||
bounds.getEast(),
|
||||
bounds.getNorth()
|
||||
]
|
||||
]
|
||||
}
|
||||
}]
|
||||
}
|
||||
// @ts-ignore
|
||||
L.geoJSON(data, {
|
||||
style: {
|
||||
color: "#f00",
|
||||
weight: 2,
|
||||
opacity: 0.4
|
||||
}
|
||||
}).addTo(leaflet)
|
||||
})
|
||||
|
||||
if (this._snapTo !== undefined) {
|
||||
|
@ -164,15 +208,15 @@ export default class LocationInput extends InputElement<Loc> {
|
|||
}
|
||||
|
||||
leaflet.setMaxZoom(layer.max_zoom)
|
||||
leaflet.setMinZoom(layer.max_zoom - 3)
|
||||
leaflet.setMinZoom(layer.max_zoom - 2)
|
||||
leaflet.setZoom(layer.max_zoom - 1)
|
||||
|
||||
}, [map.leafletMap])
|
||||
return new Combine([
|
||||
new Combine([
|
||||
Svg.crosshair_empty_ui()
|
||||
.SetClass("block relative")
|
||||
.SetStyle("left: -1.25rem; top: -1.25rem; width: 2.5rem; height: 2.5rem")
|
||||
Svg.move_arrows_ui()
|
||||
.SetClass("block relative pointer-events-none")
|
||||
.SetStyle("left: -2.5rem; top: -2.5rem; width: 5rem; height: 5rem")
|
||||
]).SetClass("block w-0 h-0 z-10 relative")
|
||||
.SetStyle("background: rgba(255, 128, 128, 0.21); left: 50%; top: 50%"),
|
||||
map
|
||||
|
|
54
assets/svg/hand.svg
Normal file
54
assets/svg/hand.svg
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.1"
|
||||
width="28.561806"
|
||||
height="39.557907"
|
||||
id="svg6"
|
||||
sodipodi:docname="Right-pointing_hand_in_green_octagon.svg"
|
||||
inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)">
|
||||
<metadata
|
||||
id="metadata12">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs
|
||||
id="defs10" />
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1003"
|
||||
id="namedview8"
|
||||
showgrid="false"
|
||||
inkscape:zoom="3.6875"
|
||||
inkscape:cx="-15.38013"
|
||||
inkscape:cy="19.778954"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg6" />
|
||||
<path
|
||||
d="m 7.931404,38.692909 h 16.078583 l 3.686819,-10.34355 V 16.367203 c 0,-1.666145 -5.427816,-2.851496 -5.427816,-1.945801 V 18.1082 12.782817 c 0,-0.971193 -5.398869,-1.707156 -5.398869,0 v 3.994037 -4.406807 c -0.573718,-0.956195 -5.354332,-1.343658 -5.354332,0 V 17.084093 2.6404066 c -0.191239,-2.28522003 -4.938353,-2.44771503 -5.416439,0 V 24.048061 18.20547 c 0.02267,-1.537788 -5.14447599,-1.703651 -5.23434999,0 v 6.14983 z"
|
||||
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1.73000002;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1"
|
||||
id="path4"
|
||||
inkscape:connector-curvature="0" />
|
||||
</svg>
|
After Width: | Height: | Size: 2.1 KiB |
|
@ -1350,5 +1350,15 @@
|
|||
"path": "loading.svg",
|
||||
"license": "CC0; trivial",
|
||||
"sources": []
|
||||
},
|
||||
{
|
||||
"path": "hand.svg",
|
||||
"license": "CC0",
|
||||
"authors": [
|
||||
"Anomie"
|
||||
],
|
||||
"sources": [
|
||||
"https://commons.wikimedia.org/wiki/File:Right-pointing_hand_in_green_octagon.svg"
|
||||
]
|
||||
}
|
||||
]
|
109
assets/svg/move-arrows.svg
Normal file
109
assets/svg/move-arrows.svg
Normal file
|
@ -0,0 +1,109 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="150.52238"
|
||||
height="150"
|
||||
viewBox="0 0 39.825713 39.687501"
|
||||
version="1.1"
|
||||
id="svg8"
|
||||
inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)"
|
||||
sodipodi:docname="move-arrows.svg">
|
||||
<defs
|
||||
id="defs2" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="2.8284271"
|
||||
inkscape:cx="40.728103"
|
||||
inkscape:cy="29.654191"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
units="px"
|
||||
showguides="true"
|
||||
inkscape:guide-bbox="true"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1003"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:snap-others="false"
|
||||
inkscape:snap-global="false">
|
||||
<sodipodi:guide
|
||||
position="19.84375,33.023307"
|
||||
orientation="1,0"
|
||||
id="guide815"
|
||||
inkscape:locked="false" />
|
||||
<sodipodi:guide
|
||||
position="-4.9812358,19.843092"
|
||||
orientation="0,1"
|
||||
id="guide817"
|
||||
inkscape:locked="false" />
|
||||
</sodipodi:namedview>
|
||||
<metadata
|
||||
id="metadata5">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(4.2274751,-261.31776)">
|
||||
<path
|
||||
id="path852"
|
||||
d="m 5.1003857,274.72419 c 1.2361,2.16965 2.51794,4.28288 3.76534,6.43775 -0.92442,1.56909 -1.84645,3.14163 -2.77028,4.71072 -0.32773,0.58146 -0.68754,1.12387 -0.99506,1.72789 -0.006,-1.2905 -0.005,-2.58187 -0.002,-3.87236 -5.38085,0.007 -0.16437,0.008 -5.54464,-8.6e-4 0.002,1.29135 0.006,2.58272 -0.002,3.87322 -1.23494,-2.16964 -2.51676,-4.28199 -3.76416,-6.43687 1.22898,-2.08111 2.44848,-4.17524 3.68102,-6.2529 0.0279,-0.0642 0.0545,-0.12935 0.0819,-0.1935 0.014,1.29397 0.005,2.58793 0.005,3.8819 5.38085,-0.006 0.16438,-0.006 5.54461,0 -0.001,-1.29136 -0.005,-2.5836 0.002,-3.87497 z"
|
||||
inkscape:connector-curvature="0"
|
||||
style="opacity:1;fill:#ff0000;fill-opacity:1;stroke:none;stroke-width:0.71549845;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
sodipodi:nodetypes="cccccccccccccc" />
|
||||
<path
|
||||
style="fill:none;fill-opacity:1;stroke:#ff0000;stroke-width:2.64583332;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
||||
id="path818"
|
||||
sodipodi:type="arc"
|
||||
sodipodi:cx="15.616275"
|
||||
sodipodi:cy="281.16217"
|
||||
sodipodi:rx="11.045696"
|
||||
sodipodi:ry="11.045696"
|
||||
sodipodi:start="0"
|
||||
sodipodi:end="6.2828013"
|
||||
sodipodi:open="true"
|
||||
d="M 26.661971,281.16217 A 11.045696,11.045696 0 0 1 15.617335,292.20787 11.045696,11.045696 0 0 1 4.5705788,281.16429 11.045696,11.045696 0 0 1 15.613094,270.11647 11.045696,11.045696 0 0 1 26.66197,281.15793" />
|
||||
<path
|
||||
sodipodi:nodetypes="cccccccccccccc"
|
||||
style="opacity:1;fill:#ff0000;fill-opacity:1;stroke:none;stroke-width:0.71549845;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
inkscape:connector-curvature="0"
|
||||
d="m 31.94761,274.72419 c 1.2361,2.16965 2.51794,4.28288 3.76534,6.43775 -0.92442,1.56909 -1.84645,3.14163 -2.77028,4.71072 -0.32773,0.58146 -0.68754,1.12387 -0.99506,1.72789 -0.006,-1.2905 -0.005,-2.58187 -0.002,-3.87236 -5.38085,0.007 -0.16437,0.008 -5.54464,-8.6e-4 0.002,1.29135 0.006,2.58272 -0.002,3.87322 -1.23494,-2.16964 -2.51676,-4.28199 -3.76416,-6.43687 1.22898,-2.08111 2.44848,-4.17524 3.68102,-6.2529 0.0279,-0.0642 0.0545,-0.12935 0.0819,-0.1935 0.014,1.29397 0.005,2.58793 0.005,3.8819 5.38085,-0.006 0.16438,-0.006 5.54461,0 -0.001,-1.29136 -0.005,-2.5836 0.002,-3.87497 z"
|
||||
id="path822" />
|
||||
<path
|
||||
sodipodi:nodetypes="cccccccccccccc"
|
||||
style="opacity:1;fill:#ff0000;fill-opacity:1;stroke:none;stroke-width:0.71549845;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
inkscape:connector-curvature="0"
|
||||
d="m 22.184993,270.50903 c -2.16965,1.2361 -4.28288,2.51794 -6.43775,3.76534 -1.56909,-0.92442 -3.14163,-1.84645 -4.71072,-2.77028 -0.58146,-0.32773 -1.1238701,-0.68754 -1.7278901,-0.99506 1.2905001,-0.006 2.5818701,-0.005 3.8723601,-0.002 -0.007,-5.38085 -0.008,-0.16437 8.6e-4,-5.54464 -1.29135,0.002 -2.58272,0.006 -3.8732201,-0.002 2.1696401,-1.23494 4.2819901,-2.51676 6.4368701,-3.76416 2.08111,1.22898 4.17524,2.44848 6.2529,3.68102 0.0642,0.0279 0.12935,0.0545 0.1935,0.0819 -1.29397,0.014 -2.58793,0.005 -3.8819,0.005 0.006,5.38085 0.006,0.16438 0,5.54461 1.29136,-10e-4 2.5836,-0.005 3.87497,0.002 z"
|
||||
id="path824" />
|
||||
<path
|
||||
id="path826"
|
||||
d="m 22.184993,297.35626 c -2.16965,1.2361 -4.28288,2.51794 -6.43775,3.76534 -1.56909,-0.92442 -3.14163,-1.84645 -4.71072,-2.77028 -0.58146,-0.32773 -1.1238701,-0.68754 -1.7278901,-0.99506 1.2905001,-0.006 2.5818701,-0.005 3.8723601,-0.002 -0.007,-5.38085 -0.008,-0.16437 8.6e-4,-5.54464 -1.29135,0.002 -2.58272,0.006 -3.8732201,-0.002 2.1696401,-1.23494 4.2819901,-2.51676 6.4368701,-3.76416 2.08111,1.22898 4.17524,2.44848 6.2529,3.68102 0.0642,0.0279 0.12935,0.0545 0.1935,0.0819 -1.29397,0.014 -2.58793,0.005 -3.8819,0.005 0.006,5.38085 0.006,0.16438 0,5.54461 1.29136,-0.001 2.5836,-0.005 3.87497,0.002 z"
|
||||
inkscape:connector-curvature="0"
|
||||
style="opacity:1;fill:#ff0000;fill-opacity:1;stroke:none;stroke-width:0.71549845;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
sodipodi:nodetypes="cccccccccccccc" />
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 6.1 KiB |
8
assets/svg/move-arrows.svg.license_info.json
Normal file
8
assets/svg/move-arrows.svg.license_info.json
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"authors": [
|
||||
"Pieter Vander Vennet"
|
||||
],
|
||||
"path": "move-arrows.svg",
|
||||
"license": "CC0",
|
||||
"sources": []
|
||||
}
|
Loading…
Reference in a new issue