Improvements to studio and layer handling

This commit is contained in:
Pieter Vander Vennet 2024-01-13 01:51:19 +01:00
parent d6a55a5ee9
commit d91ccbe624
6 changed files with 20 additions and 4 deletions

View file

@ -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)",

View file

@ -95,6 +95,9 @@ class SubstituteLayer extends Conversion<string | LayerConfigJson, LayerConfigJs
}
if (json["hideTagRenderingsWithLabels"]) {
if(typeof json["hideTagRenderingsWithLabels"] === "string"){
throw "At "+context+".hideTagRenderingsWithLabels should be a list containing strings, you specified a string"
}
const hideLabels: Set<string> = new Set(json["hideTagRenderingsWithLabels"])
// These labels caused at least one deletion
const usedLabels: Set<string> = new Set<string>()

View file

@ -177,6 +177,9 @@ export class ValidateTheme extends DesugaringStep<LayoutConfigJson> {
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<LayoutConfigJson> {
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 DesugaringStep<TagRenderingCo
return json
} catch (e) {
context.err(e)
context.err("Could not check for conflicting extra tags due to: " + e)
return undefined
}
}

View file

@ -106,8 +106,12 @@ export interface MappingConfigJson {
hideInAnswer?: boolean | TagConfigJson
/**
* question: In what other cases should this item be rendered?
*
* Also show this 'then'-option if the feature matches these tags.
* Ideal for outdated tags.
* Ideal for outdated tags or default assumptions. The tags from this options will <b>not</b> be set if the option is chosen!
*
* ifunset: No other cases when this text is shown
*/
alsoShowIf?: TagConfigJson

View file

@ -172,6 +172,7 @@ export abstract class EditJsonState<T> {
public setValueAt(path: ReadonlyArray<string | number>, v: any) {
let entry = this.configuration.data
console.trace("Setting value at", path,"to",v)
const isUndefined =
v === undefined ||
v === null ||

View file

@ -147,6 +147,9 @@
return { ...<object>v }
}
if (schema.type === "boolean") {
if(v === null || v === undefined){
return v
}
return v === "true" || v === "yes" || v === "1"
}
if (mightBeBoolean(schema.type)) {