Remove 'language' as field from the layoutConfigJson as it is now calculated based on the title

This commit is contained in:
Pieter Vander Vennet 2022-01-27 01:23:04 +01:00
parent 8b46a7e052
commit 0f47b84229
11 changed files with 40 additions and 37 deletions

View file

@ -344,9 +344,6 @@ class ValidateTheme extends DesugaringStep<LayoutConfigJson> {
{
// Legacy format checks
if (this._isBuiltin) {
if (typeof json.language === "string") {
errors.push("The theme " + json.id + " has a string as language. Please use a list of strings")
}
if (json["units"] !== undefined) {
errors.push("The theme " + json.id + " has units defined - these should be defined on the layer instead. (Hint: use overrideAll: { '+units': ... }) ")
}

View file

@ -41,20 +41,16 @@ export interface LayoutConfigJson {
* Should be sortable, where the higher value is the later version
*/
version: string;
/**
* The supported language(s).
* This should be a two-letter, lowercase code which identifies the language, e.g. "en", "nl", ...
* If the theme supports multiple languages, use a list: `["en","nl","fr"]` to allow the user to pick any of them
*/
language: string | string[];
/**
* Only used in 'generateLayerOverview': if present, every translation will be checked to make sure it is fully translated
* Only used in 'generateLayerOverview': if present, every translation will be checked to make sure it is fully translated.
*
* This must be a list of two-letter, lowercase codes which identifies the language, e.g. "en", "nl", ...
*/
mustHaveLanguage?: string[]
/**
* The title, as shown in the welcome message and the more-screen
* The title, as shown in the welcome message and the more-screen.
*/
title: string | any;

View file

@ -301,8 +301,9 @@ export default class LayerConfig extends WithContextLoader {
if (mapRendering === undefined) {
return undefined
}
const defaultTags = new UIEventSource(TagUtils.changeAsProperties(this.source.osmTags.asChange({id: "node/-1"})))
return mapRendering.GenerateLeafletStyle(defaultTags, false, {noSize: true}).html
const baseTags = TagUtils.changeAsProperties(this.source.osmTags.asChange({id: "node/-1"}))
return mapRendering.GenerateLeafletStyle(new UIEventSource(baseTags), false,
{noSize: true, includeBadges: false}).html
}
public GenerateDocumentation(usedInThemes: string[], layerIsNeededBy: Map<string, string[]>, dependencies: {

View file

@ -66,14 +66,13 @@ export default class LayoutConfig {
this.maintainer = json.maintainer;
this.credits = json.credits;
this.version = json.version;
this.language = [];
this.language = Array.from(Object.keys(json.title));
if (typeof json.language === "string") {
this.language = [json.language];
} else {
this.language = json.language;
}
{
if (typeof json.title === "string") {
console.error("The title is not a translation, it instead is ", json.title, "("+typeof json.title+")")
throw `The title of a theme should always be a translation, as it sets the corresponding languages (${context}.title)`
}
if (this.language.length == 0) {
throw `No languages defined. Define at least one language. (${context}.languages)`
}
@ -120,7 +119,7 @@ export default class LayoutConfig {
this.clustering = {
maxZoom: 16,
minNeededElements: 25,
minNeededElements: 250,
};
if (json.clustering === false) {
this.clustering = {
@ -130,7 +129,7 @@ export default class LayoutConfig {
} else if (json.clustering) {
this.clustering = {
maxZoom: json.clustering.maxZoom ?? 18,
minNeededElements: json.clustering.minNeededElements ?? 25,
minNeededElements: json.clustering.minNeededElements ?? 250,
}
}

View file

@ -150,7 +150,8 @@ export default class PointRenderingConfig extends WithContextLoader {
tags: UIEventSource<any>,
clickable: boolean,
options?: {
noSize: false | boolean
noSize: false | boolean,
includeBadges: true | boolean
}
):
{
@ -201,7 +202,11 @@ export default class PointRenderingConfig extends WithContextLoader {
const icon = this.GetSimpleIcon(tags)
const iconAndBadges = new Combine([icon, this.GetBadges(tags)])
let badges = undefined;
if( options?.includeBadges ?? true){
badges = this.GetBadges(tags)
}
const iconAndBadges = new Combine([icon,badges ])
.SetClass("block relative")
if (!options?.noSize) {