forked from MapComplete/MapComplete
Merge branch 'master' into feature/studio
This commit is contained in:
commit
6ff2c629f0
994 changed files with 5917 additions and 4262 deletions
|
|
@ -21,11 +21,9 @@ import questions from "../assets/generated/layers/questions.json"
|
|||
import {
|
||||
DoesImageExist,
|
||||
PrevalidateTheme,
|
||||
ValidateTagRenderings,
|
||||
ValidateThemeAndLayers,
|
||||
} from "../Models/ThemeConfig/Conversion/Validation"
|
||||
import { DesugaringContext } from "../Models/ThemeConfig/Conversion/Conversion"
|
||||
import { RewriteSpecial } from "../Models/ThemeConfig/Conversion/PrepareLayer"
|
||||
import { TagRenderingConfigJson } from "../Models/ThemeConfig/Json/TagRenderingConfigJson"
|
||||
import Hash from "./Web/Hash"
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,12 @@ import { Utils } from "../../Utils"
|
|||
class FeatureSwitchUtils {
|
||||
static initSwitch(key: string, deflt: boolean, documentation: string): UIEventSource<boolean> {
|
||||
const defaultValue = deflt
|
||||
const queryParam = QueryParameters.GetQueryParameter(key, "" + defaultValue, documentation)
|
||||
const queryParam = QueryParameters.GetQueryParameter(
|
||||
key,
|
||||
"" + defaultValue,
|
||||
documentation,
|
||||
{ stackOffset: -1 }
|
||||
)
|
||||
|
||||
// It takes the current layout, extracts the default value for this query parameter. A query parameter event source is then retrieved and flattened
|
||||
return queryParam.sync(
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
import { UIEventSource } from "../UIEventSource"
|
||||
import Hash from "./Hash"
|
||||
import { Utils } from "../../Utils"
|
||||
import doc = Mocha.reporters.doc
|
||||
|
||||
export class QueryParameters {
|
||||
static defaults: Record<string, string> = {}
|
||||
|
|
@ -16,11 +17,27 @@ export class QueryParameters {
|
|||
public static GetQueryParameter(
|
||||
key: string,
|
||||
deflt: string,
|
||||
documentation?: string
|
||||
documentation?: string,
|
||||
options?: {
|
||||
stackOffset?: number
|
||||
}
|
||||
): UIEventSource<string> {
|
||||
if (!this.initialized) {
|
||||
this.init()
|
||||
}
|
||||
|
||||
if (Utils.runningFromConsole) {
|
||||
const location = Utils.getLocationInCode(-1 + (options?.stackOffset ?? 0))
|
||||
|
||||
documentation +=
|
||||
"\n\nThis documentation is defined in the source code at [" +
|
||||
location.filename +
|
||||
"](" +
|
||||
location.markdownLocation +
|
||||
")" +
|
||||
"\n\n"
|
||||
}
|
||||
|
||||
QueryParameters.documentation.set(key, documentation)
|
||||
if (deflt !== undefined) {
|
||||
QueryParameters.defaults[key] = deflt
|
||||
|
|
@ -49,7 +66,7 @@ export class QueryParameters {
|
|||
documentation?: string
|
||||
): UIEventSource<boolean> {
|
||||
return UIEventSource.asBoolean(
|
||||
QueryParameters.GetQueryParameter(key, "" + deflt, documentation)
|
||||
QueryParameters.GetQueryParameter(key, "" + deflt, documentation, { stackOffset: -1 })
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue