forked from MapComplete/MapComplete
Merge develop
This commit is contained in:
commit
ccf9c4b5f6
50 changed files with 1427 additions and 766 deletions
|
@ -2,7 +2,7 @@ import {Utils} from "../Utils";
|
|||
|
||||
export default class Constants {
|
||||
|
||||
public static vNumber = "0.18.1";
|
||||
public static vNumber = "0.18.2";
|
||||
|
||||
public static ImgurApiKey = '7070e7167f0a25a'
|
||||
public static readonly mapillary_client_token_v4 = "MLY|4441509239301885|b40ad2d3ea105435bd40c7e76993ae85"
|
||||
|
@ -62,6 +62,13 @@ export default class Constants {
|
|||
*/
|
||||
static distanceToChangeObjectBins = [25, 50, 100, 500, 1000, 5000, Number.MAX_VALUE]
|
||||
static themeOrder = ["personal", "cyclofix", "waste" , "etymology", "food","cafes_and_pubs", "playgrounds", "hailhydrant", "toilets", "aed", "bookcases"];
|
||||
/**
|
||||
* Upon initialization, the GPS will search the location.
|
||||
* If the location is found within the given timout, it'll automatically fly to it.
|
||||
*
|
||||
* In seconds
|
||||
*/
|
||||
static zoomToLocationTimeout = 60;
|
||||
|
||||
private static isRetina(): boolean {
|
||||
if (Utils.runningFromConsole) {
|
||||
|
|
|
@ -127,6 +127,7 @@ export default class LayerConfig extends WithContextLoader {
|
|||
idKey: json.source["idKey"]
|
||||
|
||||
},
|
||||
Constants.priviliged_layers.indexOf(this.id) > 0,
|
||||
json.id
|
||||
);
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import {TagsFilter} from "../../Logic/Tags/TagsFilter";
|
||||
import {RegexTag} from "../../Logic/Tags/RegexTag";
|
||||
import {param} from "jquery";
|
||||
|
||||
export default class SourceConfig {
|
||||
|
||||
|
@ -19,7 +20,7 @@ export default class SourceConfig {
|
|||
isOsmCache?: boolean,
|
||||
geojsonSourceLevel?: number,
|
||||
idKey?: string
|
||||
}, context?: string) {
|
||||
}, isSpecialLayer: boolean, context?: string) {
|
||||
|
||||
let defined = 0;
|
||||
if (params.osmTags) {
|
||||
|
@ -43,6 +44,15 @@ export default class SourceConfig {
|
|||
throw `Source defines a geojson-zoomLevel, but does not specify {x} nor {y} (or equivalent), this is probably a bug (in context ${context})`
|
||||
}
|
||||
}
|
||||
if(params.osmTags !== undefined && !isSpecialLayer){
|
||||
const optimized = params.osmTags.optimize()
|
||||
if(optimized === false){
|
||||
throw "Error at "+context+": the specified tags are conflicting with each other: they will never match anything at all"
|
||||
}
|
||||
if(optimized === true){
|
||||
throw "Error at "+context+": the specified tags are very wide: they will always match everything"
|
||||
}
|
||||
}
|
||||
this.osmTags = params.osmTags ?? new RegexTag("id", /.*/);
|
||||
this.overpassScript = params.overpassScript;
|
||||
this.geojsonSource = params.geojsonSource;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {Translation} from "../../UI/i18n/Translation";
|
||||
import {Translation, TypedTranslation} from "../../UI/i18n/Translation";
|
||||
import {TagsFilter} from "../../Logic/Tags/TagsFilter";
|
||||
import Translations from "../../UI/i18n/Translations";
|
||||
import {TagUtils} from "../../Logic/Tags/TagUtils";
|
||||
|
@ -22,8 +22,8 @@ export default class TagRenderingConfig {
|
|||
|
||||
public readonly id: string;
|
||||
public readonly group: string;
|
||||
public readonly render?: Translation;
|
||||
public readonly question?: Translation;
|
||||
public readonly render?: TypedTranslation<object>;
|
||||
public readonly question?: TypedTranslation<object>;
|
||||
public readonly condition?: TagsFilter;
|
||||
|
||||
public readonly configuration_warnings: string[] = []
|
||||
|
@ -43,7 +43,7 @@ export default class TagRenderingConfig {
|
|||
public readonly mappings?: {
|
||||
readonly if: TagsFilter,
|
||||
readonly ifnot?: TagsFilter,
|
||||
readonly then: Translation,
|
||||
readonly then: TypedTranslation<object>,
|
||||
readonly icon: string,
|
||||
readonly iconClass: string
|
||||
readonly hideInAnswer: boolean | TagsFilter
|
||||
|
@ -110,12 +110,13 @@ export default class TagRenderingConfig {
|
|||
}
|
||||
const type = json.freeform.type ?? "string"
|
||||
|
||||
let placeholder = Translations.T(json.freeform.placeholder)
|
||||
let placeholder: Translation = Translations.T(json.freeform.placeholder)
|
||||
if (placeholder === undefined) {
|
||||
const typeDescription = Translations.t.validation[type]?.description
|
||||
placeholder = Translations.T(json.freeform.key+" ("+type+")")
|
||||
if(typeDescription !== undefined){
|
||||
placeholder = placeholder.Subs({[type]: typeDescription})
|
||||
placeholder = Translations.T(json.freeform.key+" ("+type+")").Subs({[type]: typeDescription})
|
||||
}else{
|
||||
placeholder = Translations.T(json.freeform.key+" ("+type+")")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -383,7 +384,7 @@ export default class TagRenderingConfig {
|
|||
let freeformKeyDefined = this.freeform?.key !== undefined;
|
||||
let usedFreeformValues = new Set<string>()
|
||||
// We run over all the mappings first, to check if the mapping matches
|
||||
const applicableMappings: { then: Translation, img?: string }[] = Utils.NoNull((this.mappings ?? [])?.map(mapping => {
|
||||
const applicableMappings: { then: TypedTranslation<any>, img?: string }[] = Utils.NoNull((this.mappings ?? [])?.map(mapping => {
|
||||
if (mapping.if === undefined) {
|
||||
return mapping;
|
||||
}
|
||||
|
@ -404,7 +405,7 @@ export default class TagRenderingConfig {
|
|||
const leftovers = freeformValues.filter(v => !usedFreeformValues.has(v))
|
||||
for (const leftover of leftovers) {
|
||||
applicableMappings.push({then:
|
||||
this.render.replace("{"+this.freeform.key+"}", leftover)
|
||||
new TypedTranslation<object>(this.render.replace("{"+this.freeform.key+"}", leftover).translations)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -412,7 +413,7 @@ export default class TagRenderingConfig {
|
|||
return applicableMappings
|
||||
}
|
||||
|
||||
public GetRenderValue(tags: any, defltValue: any = undefined): Translation {
|
||||
public GetRenderValue(tags: any, defltValue: any = undefined): TypedTranslation<any> {
|
||||
return this.GetRenderValueWithImage(tags, defltValue).then
|
||||
}
|
||||
|
||||
|
@ -421,7 +422,7 @@ export default class TagRenderingConfig {
|
|||
* Not compatible with multiAnswer - use GetRenderValueS instead in that case
|
||||
* @constructor
|
||||
*/
|
||||
public GetRenderValueWithImage(tags: any, defltValue: any = undefined): { then: Translation, icon?: string } {
|
||||
public GetRenderValueWithImage(tags: any, defltValue: any = undefined): { then: TypedTranslation<any>, icon?: string } {
|
||||
if (this.mappings !== undefined && !this.multiAnswer) {
|
||||
for (const mapping of this.mappings) {
|
||||
if (mapping.if === undefined) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue