Remove 'language' as field from the layoutConfigJson as it is now calculated based on the title
This commit is contained in:
parent
8b46a7e052
commit
0f47b84229
11 changed files with 40 additions and 37 deletions
|
@ -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': ... }) ")
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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: {
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -22,7 +22,8 @@ import {InputElement} from "../Input/InputElement";
|
|||
import {DropDown} from "../Input/DropDown";
|
||||
|
||||
export default class FilterView extends VariableUiElement {
|
||||
constructor(filteredLayer: UIEventSource<FilteredLayer[]>, tileLayers: { config: TilesourceConfig, isDisplayed: UIEventSource<boolean> }[]) {
|
||||
constructor(filteredLayer: UIEventSource<FilteredLayer[]>,
|
||||
tileLayers: { config: TilesourceConfig, isDisplayed: UIEventSource<boolean> }[]) {
|
||||
const backgroundSelector = new Toggle(
|
||||
new BackgroundSelector(),
|
||||
undefined,
|
||||
|
@ -30,8 +31,11 @@ export default class FilterView extends VariableUiElement {
|
|||
)
|
||||
super(
|
||||
filteredLayer.map((filteredLayers) => {
|
||||
// Create the views which toggle layers (and filters them) ...
|
||||
let elements = filteredLayers?.map(l => FilterView.createOneFilteredLayerElement(l))
|
||||
// ... create views for non-interactive layers ...
|
||||
elements = elements.concat(tileLayers.map(tl => FilterView.createOverlayToggle(tl)))
|
||||
// ... and add the dropdown to select a different background
|
||||
return elements.concat(backgroundSelector);
|
||||
}
|
||||
)
|
||||
|
@ -93,11 +97,6 @@ export default class FilterView extends VariableUiElement {
|
|||
iconStyle
|
||||
);
|
||||
|
||||
if (filteredLayer.layerDef.name === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const name: Translation = Translations.WT(
|
||||
filteredLayer.layerDef.name
|
||||
);
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
{
|
||||
"id": "notes",
|
||||
"language": [
|
||||
"en"
|
||||
],
|
||||
"maintainer": "MapComplete",
|
||||
"startLat": 0,
|
||||
"startLon": 0,
|
||||
"startZoom": 0,
|
||||
"title": "Notes on OpenStreetMap",
|
||||
"title": {
|
||||
"en": "Notes on OpenStreetMap"
|
||||
},
|
||||
"version": "0.1",
|
||||
"description": "A note is a pin on the map with some text to indicate something wrong.<br/><br/>Make sure to checkout the <a href='#filters'>filter view</a> to search for users and text.",
|
||||
"description": {
|
||||
"en": "A note is a pin on the map with some text to indicate something wrong.<br/><br/>Make sure to checkout the <a href='#filters'>filter view</a> to search for users and text."
|
||||
},
|
||||
"icon": "./assets/svg/resolved.svg",
|
||||
"clustering": false,
|
||||
"enableDownload": true,
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
"hu": "WC-térkép"
|
||||
},
|
||||
"description": {
|
||||
"en": "A map of public toilets",
|
||||
"en": "OpenStreetMap has the biggest dataset of toilets. Worldwide, over 300.000 toilets are known in this map. And, best of all, if one is missing, you can easily add it yourself! <br/><br/> So, if you need to pee or poo, find a loo!",
|
||||
"de": "Eine Karte mit öffentlich zugänglichen Toiletten",
|
||||
"fr": "Carte affichant les WC et toilettes publiques",
|
||||
"nl": "Een kaart met openbare toiletten",
|
||||
|
|
|
@ -196,4 +196,10 @@ class LayerOverviewUtils {
|
|||
}
|
||||
}
|
||||
|
||||
try{
|
||||
new LayerOverviewUtils().main(process.argv)
|
||||
|
||||
}catch(e){
|
||||
console.error("ERROR WHILE GENERATING THE LAYERS:", e)
|
||||
console.log("If a weird error persists, 'npm run reset:layeroverview'")
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import ScriptUtils from "./ScriptUtils";
|
||||
import {writeFileSync} from "fs";
|
||||
import {FixLegacyTheme, UpdateLegacyLayer} from "../Models/ThemeConfig/LegacyJsonConvert";
|
||||
import {FixLegacyTheme, UpdateLegacyLayer} from "../Models/ThemeConfig/Conversion/LegacyJsonConvert";
|
||||
|
||||
/*
|
||||
* This script reads all theme and layer files and reformats them inplace
|
||||
|
|
|
@ -16,7 +16,6 @@ export default class ThemeSpec extends T {
|
|||
let themeConfigJson: LayoutConfigJson = {
|
||||
description: "Descr",
|
||||
icon: "",
|
||||
language: ["en"],
|
||||
layers: [
|
||||
{
|
||||
builtin: "public_bookcase",
|
||||
|
|
Loading…
Add table
Reference in a new issue