From d91ccbe6243809c2506294ec800fd1177d16798a Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Sat, 13 Jan 2024 01:51:19 +0100 Subject: [PATCH] Improvements to studio and layer handling --- package.json | 3 ++- src/Models/ThemeConfig/Conversion/PrepareTheme.ts | 3 +++ src/Models/ThemeConfig/Conversion/Validation.ts | 8 ++++++-- .../Json/QuestionableTagRenderingConfigJson.ts | 6 +++++- src/UI/Studio/EditLayerState.ts | 1 + src/UI/Studio/SchemaBasedField.svelte | 3 +++ 6 files changed, 20 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 73bccaf02..2baddc4c8 100644 --- a/package.json +++ b/package.json @@ -78,9 +78,10 @@ "generate:charging-stations": "cd ./assets/layers/charging_station && vite-node csvToJson.ts && cd -", "prepare-deploy": "npm run generate:service-worker && ./scripts/prepare-build.sh && npm run build", "build": "./scripts/build.sh", - "lint": "npm run lint:prettier && npm run lint:eslint", + "lint": "npm run lint:prettier && npm run lint:eslint && npm run lint:themes", "lint:eslint": "eslint ./src", "lint:prettier": "prettier --check '**/*.ts' '**/*.svelte'", + "lint:themes": "vite-node scripts/lint.ts", "format": "prettier --write '**/*.ts' '**/*.svelte'", "clean:tests": "find . -type f -name \"*.doctest.ts\" | xargs -r rm", "clean": "rm -rf .cache/ && (find *.html | grep -v \"^\\(404\\|index\\|land\\|privacy\\|test\\|studio\\|theme\\|style_test\\|statistics\\|leaderboard\\).html\" | xargs -r rm) && (ls | grep \"^index_[a-zA-Z_-]\\+\\.ts$\" | xargs -r rm)", diff --git a/src/Models/ThemeConfig/Conversion/PrepareTheme.ts b/src/Models/ThemeConfig/Conversion/PrepareTheme.ts index 0da7d76c2..e55e9b4fa 100644 --- a/src/Models/ThemeConfig/Conversion/PrepareTheme.ts +++ b/src/Models/ThemeConfig/Conversion/PrepareTheme.ts @@ -95,6 +95,9 @@ class SubstituteLayer extends Conversion = new Set(json["hideTagRenderingsWithLabels"]) // These labels caused at least one deletion const usedLabels: Set = new Set() diff --git a/src/Models/ThemeConfig/Conversion/Validation.ts b/src/Models/ThemeConfig/Conversion/Validation.ts index 2f46cc3c1..4cbb22e9d 100644 --- a/src/Models/ThemeConfig/Conversion/Validation.ts +++ b/src/Models/ThemeConfig/Conversion/Validation.ts @@ -177,6 +177,9 @@ export class ValidateTheme extends DesugaringStep { if (!json.title) { context.enter("title").err(`The theme ${json.id} does not have a title defined.`) } + if(!json.icon){ + context.enter("icon").err("A theme should have an icon") + } if (this._isBuiltin && this._extractImages !== undefined) { // Check images: are they local, are the licenses there, is the theme icon square, ... const images = this._extractImages.convert(json, context.inOperation("ValidateTheme")) @@ -243,7 +246,8 @@ export class ValidateTheme extends DesugaringStep { new ValidateLanguageCompleteness("en").convert(theme, context) } } catch (e) { - context.err(e) + console.error(e) + context.err("Could not validate the theme due to: " + e) } if (theme.id !== "personal") { @@ -411,7 +415,7 @@ export class DetectConflictingAddExtraTags extends DesugaringStepnot be set if the option is chosen! + * + * ifunset: No other cases when this text is shown */ alsoShowIf?: TagConfigJson diff --git a/src/UI/Studio/EditLayerState.ts b/src/UI/Studio/EditLayerState.ts index 7bc7aad1b..557ec2109 100644 --- a/src/UI/Studio/EditLayerState.ts +++ b/src/UI/Studio/EditLayerState.ts @@ -172,6 +172,7 @@ export abstract class EditJsonState { public setValueAt(path: ReadonlyArray, v: any) { let entry = this.configuration.data + console.trace("Setting value at", path,"to",v) const isUndefined = v === undefined || v === null || diff --git a/src/UI/Studio/SchemaBasedField.svelte b/src/UI/Studio/SchemaBasedField.svelte index dd87e9af8..c3dfd08e7 100644 --- a/src/UI/Studio/SchemaBasedField.svelte +++ b/src/UI/Studio/SchemaBasedField.svelte @@ -147,6 +147,9 @@ return { ...v } } if (schema.type === "boolean") { + if(v === null || v === undefined){ + return v + } return v === "true" || v === "yes" || v === "1" } if (mightBeBoolean(schema.type)) {