forked from MapComplete/MapComplete
Refactoring: fix download buttons
This commit is contained in:
parent
8a1f0599d9
commit
ef0ec5160d
10 changed files with 142 additions and 134 deletions
|
@ -8,6 +8,7 @@ import { TagsFilter } from "../Logic/Tags/TagsFilter"
|
|||
import { Utils } from "../Utils"
|
||||
import { TagUtils } from "../Logic/Tags/TagUtils"
|
||||
import { And } from "../Logic/Tags/And"
|
||||
import { GlobalFilter } from "./GlobalFilter"
|
||||
|
||||
export default class FilteredLayer {
|
||||
/**
|
||||
|
@ -62,7 +63,7 @@ export default class FilteredLayer {
|
|||
return JSON.stringify(values)
|
||||
}
|
||||
|
||||
public static stringToFieldProperties(value: string): Record<string, string> {
|
||||
private static stringToFieldProperties(value: string): Record<string, string> {
|
||||
const values = JSON.parse(value)
|
||||
for (const key in values) {
|
||||
if (values[key] === "") {
|
||||
|
@ -208,4 +209,34 @@ export default class FilteredLayer {
|
|||
}
|
||||
return optimized
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given tags match the current filters (and the specified 'global filters')
|
||||
*/
|
||||
public isShown(properties: Record<string, string>, globalFilters?: GlobalFilter[]): boolean {
|
||||
if (properties._deleted === "yes") {
|
||||
return false
|
||||
}
|
||||
{
|
||||
const isShown: TagsFilter = this.layerDef.isShown
|
||||
if (isShown !== undefined && !isShown.matchesProperties(properties)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
let neededTags: TagsFilter = this.currentFilter.data
|
||||
if (neededTags !== undefined && !neededTags.matchesProperties(properties)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
for (const globalFilter of globalFilters ?? []) {
|
||||
const neededTags = globalFilter.osmTags
|
||||
if (neededTags !== undefined && !neededTags.matchesProperties(properties)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import { Utils } from "../Utils"
|
|||
* Some convenience methods are provided for this as well
|
||||
*/
|
||||
export class MenuState {
|
||||
private static readonly _themeviewTabs = ["intro", "filters"] as const
|
||||
private static readonly _themeviewTabs = ["intro", "filters", "download", "copyright"] as const
|
||||
public readonly themeIsOpened = new UIEventSource(true)
|
||||
public readonly themeViewTabIndex: UIEventSource<number>
|
||||
public readonly themeViewTab: UIEventSource<typeof MenuState._themeviewTabs[number]>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue