forked from MapComplete/MapComplete
chore: automated housekeeping...
This commit is contained in:
parent
a2dd79c4ec
commit
7b792af261
101 changed files with 2196 additions and 22043 deletions
|
|
@ -36,7 +36,7 @@ export default class FilteredLayer {
|
|||
constructor(
|
||||
layer: LayerConfig,
|
||||
appliedFilters?: ReadonlyMap<string, UIEventSource<undefined | number | string>>,
|
||||
isDisplayed?: UIEventSource<boolean>,
|
||||
isDisplayed?: UIEventSource<boolean>
|
||||
) {
|
||||
this.layerDef = layer
|
||||
this.isDisplayed = isDisplayed ?? new UIEventSource(true)
|
||||
|
|
@ -82,25 +82,25 @@ export default class FilteredLayer {
|
|||
layer: LayerConfig,
|
||||
context: string,
|
||||
osmConnection: OsmConnection,
|
||||
enabledByDefault?: Store<boolean>,
|
||||
enabledByDefault?: Store<boolean>
|
||||
) {
|
||||
let isDisplayed: UIEventSource<boolean>
|
||||
if (layer.syncSelection === "local") {
|
||||
isDisplayed = LocalStorageSource.getParsed(
|
||||
context + "-layer-" + layer.id + "-enabled",
|
||||
layer.shownByDefault,
|
||||
layer.shownByDefault
|
||||
)
|
||||
} else if (layer.syncSelection === "theme-only") {
|
||||
isDisplayed = FilteredLayer.getPref(
|
||||
osmConnection,
|
||||
context + "-layer-" + layer.id + "-enabled",
|
||||
layer,
|
||||
layer
|
||||
)
|
||||
} else if (layer.syncSelection === "global") {
|
||||
isDisplayed = FilteredLayer.getPref(
|
||||
osmConnection,
|
||||
"layer-" + layer.id + "-enabled",
|
||||
layer,
|
||||
layer
|
||||
)
|
||||
} else {
|
||||
let isShown = layer.shownByDefault
|
||||
|
|
@ -110,7 +110,7 @@ export default class FilteredLayer {
|
|||
isDisplayed = QueryParameters.GetBooleanQueryParameter(
|
||||
FilteredLayer.queryParameterKey(layer),
|
||||
isShown,
|
||||
"Whether or not layer " + layer.id + " is shown",
|
||||
"Whether or not layer " + layer.id + " is shown"
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -145,7 +145,7 @@ export default class FilteredLayer {
|
|||
*/
|
||||
private static fieldsToTags(
|
||||
option: FilterConfigOption,
|
||||
fieldstate: string | Record<string, string>,
|
||||
fieldstate: string | Record<string, string>
|
||||
): TagsFilter | undefined {
|
||||
let properties: Record<string, string>
|
||||
if (typeof fieldstate === "string") {
|
||||
|
|
@ -181,7 +181,7 @@ export default class FilteredLayer {
|
|||
private static getPref(
|
||||
osmConnection: OsmConnection,
|
||||
key: string,
|
||||
layer: LayerConfig,
|
||||
layer: LayerConfig
|
||||
): UIEventSource<boolean> {
|
||||
return osmConnection.GetPreference(key, layer.shownByDefault + "").sync(
|
||||
(v) => {
|
||||
|
|
@ -196,7 +196,7 @@ export default class FilteredLayer {
|
|||
return undefined
|
||||
}
|
||||
return "" + b
|
||||
},
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ export interface GlobalFilter {
|
|||
/**
|
||||
* If set, this object will be shown instead of hidden, even if the layer is not displayed
|
||||
*/
|
||||
forceShowOnMatch?: boolean,
|
||||
forceShowOnMatch?: boolean
|
||||
state: number | string | undefined
|
||||
id: string
|
||||
onNewPoint: {
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ class ExpandFilter extends DesugaringStep<LayerConfigJson> {
|
|||
"Found a matching tagRendering to base a filter on, but this tagRendering does not contain any mappings"
|
||||
)
|
||||
}
|
||||
const qtr = (<QuestionableTagRenderingConfigJson>tr)
|
||||
const qtr = <QuestionableTagRenderingConfigJson>tr
|
||||
const options = qtr.mappings.map((mapping) => {
|
||||
let icon: string = mapping.icon?.["path"] ?? mapping.icon
|
||||
let emoji: string = undefined
|
||||
|
|
@ -149,12 +149,15 @@ class ExpandFilter extends DesugaringStep<LayerConfigJson> {
|
|||
emoji = icon
|
||||
icon = undefined
|
||||
}
|
||||
let osmTags = TagUtils.Tag( mapping.if)
|
||||
if(qtr.multiAnswer && osmTags instanceof Tag){
|
||||
osmTags = new RegexTag(osmTags.key, new RegExp("^(.+;)?"+osmTags.value+"(;.+)$","is"))
|
||||
let osmTags = TagUtils.Tag(mapping.if)
|
||||
if (qtr.multiAnswer && osmTags instanceof Tag) {
|
||||
osmTags = new RegexTag(
|
||||
osmTags.key,
|
||||
new RegExp("^(.+;)?" + osmTags.value + "(;.+)$", "is")
|
||||
)
|
||||
}
|
||||
if(mapping.alsoShowIf){
|
||||
osmTags= new Or([osmTags, TagUtils.Tag(mapping.alsoShowIf)])
|
||||
if (mapping.alsoShowIf) {
|
||||
osmTags = new Or([osmTags, TagUtils.Tag(mapping.alsoShowIf)])
|
||||
}
|
||||
|
||||
return <FilterConfigOptionJson>{
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ export default class DeleteConfig {
|
|||
} else if (json.omitDefaultDeleteReasons) {
|
||||
const forbidden = <string[]>json.omitDefaultDeleteReasons
|
||||
deleteReasons = deleteReasons.filter(
|
||||
(dl) => forbidden.indexOf(dl.changesetMessage) < 0,
|
||||
(dl) => forbidden.indexOf(dl.changesetMessage) < 0
|
||||
)
|
||||
}
|
||||
for (const defaultDeleteReason of deleteReasons) {
|
||||
|
|
@ -90,7 +90,7 @@ export default class DeleteConfig {
|
|||
if (json.softDeletionTags !== undefined) {
|
||||
this.softDeletionTags = TagUtils.Tag(
|
||||
json.softDeletionTags,
|
||||
`${context}.softDeletionTags`,
|
||||
`${context}.softDeletionTags`
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -445,10 +445,13 @@ export default class ThemeViewState implements SpecialVisualizationState {
|
|||
this.perLayer.forEach((fs, layerName) => {
|
||||
const doShowLayer = this.mapProperties.zoom.map(
|
||||
(z) => {
|
||||
if ((fs.layer.isDisplayed?.data ?? true) && z >= (fs.layer.layerDef?.minzoom ?? 0)){
|
||||
if (
|
||||
(fs.layer.isDisplayed?.data ?? true) &&
|
||||
z >= (fs.layer.layerDef?.minzoom ?? 0)
|
||||
) {
|
||||
return true
|
||||
}
|
||||
if(this.layerState.globalFilters.data.some(f => f.forceShowOnMatch)){
|
||||
if (this.layerState.globalFilters.data.some((f) => f.forceShowOnMatch)) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
|
@ -993,22 +996,26 @@ export default class ThemeViewState implements SpecialVisualizationState {
|
|||
this.mapProperties.showScale.set(showScale)
|
||||
})
|
||||
|
||||
|
||||
this.layerState.filteredLayers.get("favourite")?.isDisplayed?.addCallbackAndRunD(favouritesShown => {
|
||||
const oldGlobal = this.layerState.globalFilters.data
|
||||
const key = "show-favourite"
|
||||
if(favouritesShown){
|
||||
this.layerState.globalFilters.set([...oldGlobal, {
|
||||
forceShowOnMatch: true,
|
||||
id:key,
|
||||
osmTags: new Tag("_favourite","yes"),
|
||||
state: 0,
|
||||
onNewPoint: undefined
|
||||
}])
|
||||
}else{
|
||||
this.layerState.globalFilters.set(oldGlobal.filter(gl => gl.id !== key))
|
||||
}
|
||||
})
|
||||
this.layerState.filteredLayers
|
||||
.get("favourite")
|
||||
?.isDisplayed?.addCallbackAndRunD((favouritesShown) => {
|
||||
const oldGlobal = this.layerState.globalFilters.data
|
||||
const key = "show-favourite"
|
||||
if (favouritesShown) {
|
||||
this.layerState.globalFilters.set([
|
||||
...oldGlobal,
|
||||
{
|
||||
forceShowOnMatch: true,
|
||||
id: key,
|
||||
osmTags: new Tag("_favourite", "yes"),
|
||||
state: 0,
|
||||
onNewPoint: undefined,
|
||||
},
|
||||
])
|
||||
} else {
|
||||
this.layerState.globalFilters.set(oldGlobal.filter((gl) => gl.id !== key))
|
||||
}
|
||||
})
|
||||
|
||||
new ThemeViewStateHashActor(this)
|
||||
new MetaTagging(this)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue