forked from MapComplete/MapComplete
Refactoring: introduce 'isPrivileged'
This commit is contained in:
parent
6ca055cf28
commit
f405116bb1
11 changed files with 29 additions and 28 deletions
|
|
@ -242,4 +242,16 @@ export default class Constants {
|
|||
(window.devicePixelRatio && window.devicePixelRatio >= 2)
|
||||
)
|
||||
}
|
||||
|
||||
private static priviligedLayerSet = new Set<string>(Constants.priviliged_layers)
|
||||
|
||||
public static isPriviliged(layer: string | { id: string }) {
|
||||
let id: string
|
||||
if (typeof layer === "string") {
|
||||
id = layer
|
||||
} else {
|
||||
id = layer.id
|
||||
}
|
||||
return this.priviligedLayerSet.has(id)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ export class PrevalidateLayer extends DesugaringStep<LayerConfigJson> {
|
|||
}
|
||||
|
||||
if (json.source === "special") {
|
||||
if (!Constants.priviliged_layers.find((x) => x == json.id)) {
|
||||
if (!Constants.isPriviliged(json)) {
|
||||
context.err(
|
||||
"Layer " +
|
||||
json.id +
|
||||
|
|
@ -150,7 +150,7 @@ export class PrevalidateLayer extends DesugaringStep<LayerConfigJson> {
|
|||
json.allowMove === undefined &&
|
||||
json.source["geoJson"] === undefined
|
||||
) {
|
||||
if (!Constants.priviliged_layers.find((x) => x == json.id)) {
|
||||
if (!Constants.isPriviliged(json)) {
|
||||
context.err("Layer " + json.id + " does not have an explicit 'allowMove'")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1128,7 +1128,7 @@ export class ValidateThemeEnsemble extends Conversion<
|
|||
if (typeof layer.source === "string") {
|
||||
continue
|
||||
}
|
||||
if (Constants.priviliged_layers.indexOf(<any>layer.id) >= 0) {
|
||||
if (Constants.isPriviliged(layer)) {
|
||||
continue
|
||||
}
|
||||
if (!layer.source) {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ import PointRenderingConfig from "./PointRenderingConfig"
|
|||
import WithContextLoader from "./WithContextLoader"
|
||||
import LineRenderingConfig from "./LineRenderingConfig"
|
||||
import { TagRenderingConfigJson } from "./Json/TagRenderingConfigJson"
|
||||
import BaseUIElement from "../../UI/BaseUIElement"
|
||||
import Link from "../../UI/Base/Link"
|
||||
import { Utils } from "../../Utils"
|
||||
import { TagsFilter } from "../../Logic/Tags/TagsFilter"
|
||||
|
|
@ -23,10 +22,6 @@ import Constants from "../Constants"
|
|||
import { QuestionableTagRenderingConfigJson } from "./Json/QuestionableTagRenderingConfigJson"
|
||||
import MarkdownUtils from "../../Utils/MarkdownUtils"
|
||||
import { And } from "../../Logic/Tags/And"
|
||||
import Combine from "../../UI/Base/Combine"
|
||||
import SvelteUIElement from "../../UI/Base/SvelteUIElement"
|
||||
import DynamicMarker from "../../UI/Map/DynamicMarker.svelte"
|
||||
import { ImmutableStore } from "../../Logic/UIEventSource"
|
||||
|
||||
export default class LayerConfig extends WithContextLoader {
|
||||
public static readonly syncSelectionAllowed = ["no", "local", "theme-only", "global"] as const
|
||||
|
|
@ -257,7 +252,7 @@ export default class LayerConfig extends WithContextLoader {
|
|||
} else if (
|
||||
!hasCenterRendering &&
|
||||
this.lineRendering.length === 0 &&
|
||||
Constants.priviliged_layers.indexOf(<any>this.id) < 0 &&
|
||||
!Constants.isPriviliged(this) &&
|
||||
this.source !== null /*library layer*/ &&
|
||||
!this.source?.geojsonSource?.startsWith(
|
||||
"https://api.openstreetmap.org/api/0.6/notes.json"
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import { Store, UIEventSource } from "../../Logic/UIEventSource"
|
|||
import NearbyFeatureSource from "../../Logic/FeatureSource/Sources/NearbyFeatureSource"
|
||||
import {
|
||||
SummaryTileSource,
|
||||
SummaryTileSourceRewriter,
|
||||
SummaryTileSourceRewriter
|
||||
} from "../../Logic/FeatureSource/TiledFeatureSource/SummaryTileSource"
|
||||
import { ShowDataLayerOptions } from "../../UI/Map/ShowDataLayerOptions"
|
||||
|
||||
|
|
@ -95,7 +95,7 @@ export class WithSpecialLayers extends WithChangesState {
|
|||
|
||||
const layers = this.theme.layers.filter(
|
||||
(l) =>
|
||||
(<string[]>(<unknown>Constants.priviliged_layers)).indexOf(l.id) < 0 &&
|
||||
!Constants.isPriviliged(l) &&
|
||||
l.source.geojsonSource === undefined &&
|
||||
l.doCount
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue