diff --git a/Customizations/JSON/CustomLayoutFromJSON.ts b/Customizations/JSON/CustomLayoutFromJSON.ts
index e298394..0eea134 100644
--- a/Customizations/JSON/CustomLayoutFromJSON.ts
+++ b/Customizations/JSON/CustomLayoutFromJSON.ts
@@ -234,7 +234,7 @@ export class CustomLayoutFromJSON {
name: t(json.title),
icon: json.icon,
minzoom: json.minzoom,
- title: tr(json.title),
+ title: tr(json.title) ,
presets: json.presets.map((preset) => {
return CustomLayoutFromJSON.PresetFromJson(json, preset)
}),
diff --git a/UI/ShareScreen.ts b/UI/ShareScreen.ts
index eaccc84..97a69ea 100644
--- a/UI/ShareScreen.ts
+++ b/UI/ShareScreen.ts
@@ -126,6 +126,7 @@ export class ShareScreen extends UIElement {
this._options = new VerticalCombine(optionCheckboxes)
const url = currentLocation.map(() => {
+
let literalText = "https://pietervdvn.github.io/MapComplete/" + layout.name + ".html"
const parts = Utils.NoNull(optionParts.map((eventSource) => eventSource.data));
@@ -133,6 +134,8 @@ export class ShareScreen extends UIElement {
let hash = "";
if (State.state.layoutDefinition !== undefined) {
hash = ("#" + State.state.layoutDefinition)
+ literalText = "https://pietervdvn.github.io/MapComplete/index.html"
+ parts.push("userlayout=true");
}
if (parts.length === 0) {
@@ -160,7 +163,7 @@ export class ShareScreen extends UIElement {
if(State.state.layoutDefinition !== undefined){
this._editLayout =
new FixedUiElement(`
Edit this theme
`+
- `Click here to edit`)
+ `Click here to edit`)
}
diff --git a/customGenerator.ts b/customGenerator.ts
index 5c8309b..0e65737 100644
--- a/customGenerator.ts
+++ b/customGenerator.ts
@@ -17,4 +17,4 @@ new VariableUiElement(connection.userDetails.map((userdetails : UserDeta
const themeGenerator = new ThemeGenerator(connection, window.location.hash?.substr(1));
themeGenerator.AttachTo("layoutCreator")
-new Preview(themeGenerator.url).AttachTo("preview");
\ No newline at end of file
+new Preview(themeGenerator.url, themeGenerator.themeObject).AttachTo("preview");
\ No newline at end of file
diff --git a/index.ts b/index.ts
index 14a0c55..a562dde 100644
--- a/index.ts
+++ b/index.ts
@@ -88,6 +88,7 @@ TagRendering.injectFunction();
State.state = new State(layoutToUse);
if(layoutFromBase64 !== "false"){
State.state.layoutDefinition = hash.substr(1);
+ console.log(State.state.layoutDefinition)
}
InitUiElements.InitBaseMap();
diff --git a/themeGenerator.ts b/themeGenerator.ts
index df9176d..569f4e4 100644
--- a/themeGenerator.ts
+++ b/themeGenerator.ts
@@ -33,15 +33,17 @@ function TagsToString(tags: string | string [] | { k: string, v: string }[]) {
export class Preview extends UIElement {
private url: UIEventSource;
+ private config: UIEventSource;
- constructor(url: UIEventSource) {
+ constructor(url: UIEventSource, config: UIEventSource) {
super(url);
+ this.config = config;
this.url = url;
}
InnerRender(): string {
const url = this.url.data;
- return ""; // ``
+ return JSON.stringify(this.config.data, null, 2)
}
}
@@ -66,7 +68,6 @@ class MappingGenerator extends UIElement {
{
const self = this;
this.elements = [
- new FixedUiElement("Mapping
"),
generateField(fullConfig, "If these tags apply", "if", mapping),
generateField(fullConfig, "Then: show this text", "then", mapping),
new Button("Remove this mapping", () => {
@@ -123,6 +124,9 @@ class TagRenderingGenerator
generateField)
}),
new Button("Add mapping", () => {
+ if(tagRendering.mappings === undefined){
+ tagRendering.mappings = []
+ }
tagRendering.mappings.push({if: "", then: ""});
self.CreateElements(fullConfig, layerConfig, tagRendering, generateField, isTitle);
self.Update();
@@ -213,8 +217,7 @@ class LayerGenerator extends UIElement {
private CreateElements(fullConfig: UIEventSource, layerConfig: LayerConfigJson, generateField: (src: UIEventSource, label: string, key: string, root: any, deflt?: string) => UIElement) {
const self = this;
this.uielements = [
- generateField(fullConfig, "id", "id", layerConfig),
- generateField(fullConfig, "The title of this layer", "title", layerConfig),
+ generateField(fullConfig, "The name of this layer", "id", layerConfig),
generateField(fullConfig, "A description of objects for this layer", "description", layerConfig),
generateField(fullConfig, "The icon of this layer, either a URL or a base64-encoded svg", "icon", layerConfig),
generateField(fullConfig, "The default stroke color", "color", layerConfig),
@@ -231,7 +234,14 @@ class LayerGenerator extends UIElement {
self.CreateElements(fullConfig, layerConfig, generateField);
self.Update();
}),
- new TagRenderingGenerator(fullConfig, layerConfig, layerConfig.title, generateField, true),
+ new TagRenderingGenerator(fullConfig, layerConfig, layerConfig.title ?? {
+ key: "",
+ addExtraTags: "",
+ mappings: [],
+ question: "",
+ render: "Title",
+ type: "text"
+ }, generateField, true),
...layerConfig.tagRenderings.map(tr => new TagRenderingGenerator(fullConfig, layerConfig, tr, generateField)),
new Button("Add a tag rendering", () => {
layerConfig.tagRenderings.push({
@@ -327,7 +337,7 @@ export class ThemeGenerator extends UIElement {
private readonly userDetails: UIEventSource;
- private readonly themeObject: UIEventSource;
+ public readonly themeObject: UIEventSource;
private readonly allQuestionFields: UIElement[];
public url: UIEventSource;