Add layer only mode for user layouts

This commit is contained in:
Pieter Vander Vennet 2022-02-08 00:56:47 +01:00
parent 77e686d9be
commit 62272774bc
2 changed files with 20 additions and 1 deletions

View file

@ -17,6 +17,8 @@ import * as known_layers from "../assets/generated/known_layers.json"
import {LayoutConfigJson} from "../Models/ThemeConfig/Json/LayoutConfigJson";
import {PrepareTheme} from "../Models/ThemeConfig/Conversion/PrepareTheme";
import * as licenses from "../assets/generated/license_info.json"
import TagRenderingConfig from "../Models/ThemeConfig/TagRenderingConfig";
export default class DetermineLayout {
private static readonly _knownImages =new Set( Array.from(licenses).map(l => l.path))
@ -135,6 +137,23 @@ export default class DetermineLayout {
}
private static prepCustomTheme(json: any): LayoutConfigJson {
if(json.layers === undefined && json.tagRenderings !== undefined){
const iconTr = json.mapRendering.map(mr => mr.icon).find(icon => icon !== undefined)
const icon = new TagRenderingConfig(iconTr).render.txt
json = {
id: json.id,
description: json.description,
descriptionTail: {
en: "<div class='alert'>Layer only mode.</div> The loaded custom theme actually isn't a custom theme, but only contains a layer."
},
icon,
title: json.name,
layers: [json],
}
}
const knownLayersDict = new Map<string, LayerConfigJson>()
for (const key in known_layers.layers) {
const layer = known_layers.layers[key]

View file

@ -64,7 +64,7 @@ export class OnEvery<X, T> extends DesugaringStep<T> {
private readonly step: DesugaringStep<X>;
constructor(key: string, step: DesugaringStep<X>) {
super("Applies " + step.constructor.name + " onto every object of the list `key`", [key]);
super("Applies " + step.name + " onto every object of the list `key`", [key], "OnEvery("+step.name+")");
this.step = step;
this.key = key;
}