forked from MapComplete/MapComplete
Merge master
This commit is contained in:
commit
470e9acc64
66 changed files with 10798 additions and 414 deletions
|
@ -2,7 +2,7 @@ import {Utils} from "../Utils";
|
|||
|
||||
export default class Constants {
|
||||
|
||||
public static vNumber = "0.20.1";
|
||||
public static vNumber = "0.21.0";
|
||||
|
||||
public static ImgurApiKey = '7070e7167f0a25a'
|
||||
public static readonly mapillary_client_token_v4 = "MLY|4441509239301885|b40ad2d3ea105435bd40c7e76993ae85"
|
||||
|
@ -23,7 +23,7 @@ export default class Constants {
|
|||
/**
|
||||
* Layer IDs of layers which have special properties through built-in hooks
|
||||
*/
|
||||
public static readonly priviliged_layers: string[] = [...Constants.added_by_default, "type_node", "note", "import_candidate", ...Constants.no_include]
|
||||
public static readonly priviliged_layers: string[] = [...Constants.added_by_default, "type_node", "note", "import_candidate", "direction", ...Constants.no_include]
|
||||
|
||||
|
||||
// The user journey states thresholds when a new feature gets unlocked
|
||||
|
|
|
@ -4,7 +4,8 @@ import {Utils} from "../../../Utils";
|
|||
|
||||
export interface DesugaringContext {
|
||||
tagRenderings: Map<string, TagRenderingConfigJson>
|
||||
sharedLayers: Map<string, LayerConfigJson>
|
||||
sharedLayers: Map<string, LayerConfigJson>,
|
||||
publicLayers?: Set<string>
|
||||
}
|
||||
|
||||
export abstract class Conversion<TIn, TOut> {
|
||||
|
@ -226,7 +227,7 @@ export class Fuse<T> extends DesugaringStep<T> {
|
|||
break;
|
||||
}
|
||||
}catch(e){
|
||||
console.error("Step "+step.name+" failed due to "+e);
|
||||
console.error("Step "+step.name+" failed due to ",e,e.stack);
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
|
|
@ -453,9 +453,16 @@ class PreparePersonalTheme extends DesugaringStep<LayoutConfigJson> {
|
|||
if (json.id !== "personal") {
|
||||
return {result: json}
|
||||
}
|
||||
|
||||
// The only thing this _really_ does, is adding the layer-ids into 'layers'
|
||||
// All other preparations are done by the 'override-all'-block in personal.json
|
||||
|
||||
json.layers = Array.from(this._state.sharedLayers.keys()).filter(l => Constants.priviliged_layers.indexOf(l) < 0)
|
||||
return {result: json};
|
||||
json.layers = Array.from(this._state.sharedLayers.keys())
|
||||
.filter(l => Constants.priviliged_layers.indexOf(l) < 0)
|
||||
.filter(l => this._state.publicLayers.has(l))
|
||||
return {result: json, information: [
|
||||
"The personal theme has "+json.layers.length+" public layers"
|
||||
]};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -321,8 +321,9 @@ export class DetectShadowedMappings extends DesugaringStep<QuestionableTagRender
|
|||
for (const calculatedTagName of this._calculatedTagNames) {
|
||||
defaultProperties[calculatedTagName] = "some_calculated_tag_value_for_"+calculatedTagName
|
||||
}
|
||||
const parsedConditions = json.mappings.map(m => {
|
||||
const ifTags = TagUtils.Tag(m.if);
|
||||
const parsedConditions = json.mappings.map((m,i) => {
|
||||
const ctx = `${context}.mappings[${i}]`
|
||||
const ifTags = TagUtils.Tag(m.if, ctx);
|
||||
if(m.hideInAnswer !== undefined && m.hideInAnswer !== false && m.hideInAnswer !== true){
|
||||
let conditionTags = TagUtils.Tag( m.hideInAnswer)
|
||||
// Merge the condition too!
|
||||
|
@ -407,7 +408,7 @@ export class DetectMappingsWithImages extends DesugaringStep<TagRenderingConfigJ
|
|||
|
||||
const mapping = json.mappings[i]
|
||||
const ignore = mapping["#"]?.indexOf(ignoreToken) >=0
|
||||
const images = Utils.Dedup(Translations.T(mapping.then).ExtractImages())
|
||||
const images = Utils.Dedup(Translations.T(mapping.then)?.ExtractImages() ?? [])
|
||||
const ctx = `${context}.mappings[${i}]`
|
||||
if (images.length > 0) {
|
||||
if(!ignore){
|
||||
|
|
|
@ -41,7 +41,7 @@ export interface DeleteConfigJson {
|
|||
* The tags that will be given to the object.
|
||||
* This must remove tags so that the 'source/osmTags' won't match anymore
|
||||
*/
|
||||
if: AndOrTagConfigJson,
|
||||
if: string | AndOrTagConfigJson,
|
||||
/**
|
||||
* The human explanation for the options
|
||||
*/
|
||||
|
|
|
@ -287,7 +287,7 @@ export interface LayerConfigJson {
|
|||
*/
|
||||
tagRenderings?:
|
||||
(string
|
||||
| { builtin: string, override: any }
|
||||
| { builtin: string | string[], override: any }
|
||||
| QuestionableTagRenderingConfigJson
|
||||
| RewritableConfigJson<(string | { builtin: string, override: any } | QuestionableTagRenderingConfigJson)[]>
|
||||
) [],
|
||||
|
@ -426,7 +426,7 @@ export interface LayerConfigJson {
|
|||
units?: UnitConfigJson[]
|
||||
|
||||
/**
|
||||
* If set, synchronizes wether or not this layer is selected.
|
||||
* If set, synchronizes whether or not this layer is enabled.
|
||||
*
|
||||
* no: Do not sync at all, always revert to default
|
||||
* local: keep selection on local storage
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
*
|
||||
* [
|
||||
* {
|
||||
* // The first pair: key --> X, a|b|c --> 0
|
||||
* # The first pair: key --> X, a|b|c --> 0
|
||||
* "X": 0
|
||||
* },
|
||||
* {
|
||||
|
|
|
@ -65,7 +65,8 @@ export default class LayerConfig extends WithContextLoader {
|
|||
public readonly filterIsSameAs: string;
|
||||
public readonly forceLoad: boolean;
|
||||
|
||||
public readonly syncSelection: "no" | "local" | "theme-only" | "global"
|
||||
public static readonly syncSelectionAllowed = ["no" , "local" , "theme-only" , "global"] as const;
|
||||
public readonly syncSelection: (typeof LayerConfig.syncSelectionAllowed)[number] // this is a trick to conver a constant array of strings into a type union of these values
|
||||
|
||||
constructor(
|
||||
json: LayerConfigJson,
|
||||
|
@ -97,7 +98,10 @@ export default class LayerConfig extends WithContextLoader {
|
|||
}
|
||||
|
||||
this.maxAgeOfCache = json.source.maxCacheAge ?? 24 * 60 * 60 * 30
|
||||
this.syncSelection = json.syncSelection;
|
||||
if(json.syncSelection !== undefined && LayerConfig.syncSelectionAllowed.indexOf(json.syncSelection) < 0){
|
||||
throw context+ " Invalid sync-selection: must be one of "+LayerConfig.syncSelectionAllowed.map(v => `'${v}'`).join(", ")+" but got '"+json.syncSelection+"'"
|
||||
}
|
||||
this.syncSelection = json.syncSelection ?? "no";
|
||||
const osmTags = TagUtils.Tag(
|
||||
json.source.osmTags,
|
||||
context + "source.osmTags"
|
||||
|
|
|
@ -109,7 +109,11 @@ export default class TagRenderingConfig {
|
|||
if (json.freeform.addExtraTags !== undefined && json.freeform.addExtraTags.map === undefined) {
|
||||
throw `Freeform.addExtraTags should be a list of strings - not a single string (at ${context})`
|
||||
}
|
||||
const type = json.freeform.type ?? "string"
|
||||
const type = json.freeform.type ?? "string"
|
||||
|
||||
if(ValidatedTextField.AvailableTypes().indexOf(type ) < 0){
|
||||
throw "At "+context+".freeform.type is an unknown type: "+type+"; try one of "+ValidatedTextField.AvailableTypes().join(", ")
|
||||
}
|
||||
|
||||
let placeholder: Translation = Translations.T(json.freeform.placeholder)
|
||||
if (placeholder === undefined) {
|
||||
|
@ -172,15 +176,21 @@ export default class TagRenderingConfig {
|
|||
this.mappings = json.mappings.map((mapping, i) => {
|
||||
|
||||
const ctx = `${translationKey}.mappings.${i}`
|
||||
if (mapping.if === undefined) {
|
||||
throw `${ctx}: Invalid mapping: "if" is not defined in ${JSON.stringify(mapping)}`
|
||||
}
|
||||
if (mapping.then === undefined) {
|
||||
throw `${ctx}: Invalid mapping: if without body`
|
||||
if(mapping["render"] !== undefined){
|
||||
throw `${ctx}: Invalid mapping: no 'then'-clause found. You might have typed 'render' instead of 'then', change it in ${JSON.stringify(mapping)}`
|
||||
}
|
||||
throw `${ctx}: Invalid mapping: no 'then'-clause found in ${JSON.stringify(mapping)}`
|
||||
}
|
||||
if (mapping.ifnot !== undefined && !this.multiAnswer) {
|
||||
throw `${ctx}: Invalid mapping: ifnot defined, but the tagrendering is not a multianswer`
|
||||
throw `${ctx}: Invalid mapping: 'ifnot' is defined, but the tagrendering is not a multianswer. Either remove ifnot or set 'multiAnswer:true' to enable checkboxes instead of radiobuttons`
|
||||
}
|
||||
|
||||
if (mapping.if === undefined) {
|
||||
throw `${ctx}: Invalid mapping: "if" is not defined, but the tagrendering is not a multianswer`
|
||||
if(mapping["render"] !== undefined){
|
||||
throw `${ctx}: Invalid mapping: a 'render'-key is present, this is probably a bug: ${JSON.stringify(mapping)}`
|
||||
}
|
||||
if (typeof mapping.if !== "string" && mapping.if["length"] !== undefined) {
|
||||
throw `${ctx}: Invalid mapping: "if" is defined as an array. Use {"and": <your conditions>} or {"or": <your conditions>} instead`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue