diff --git a/langs/en.json b/langs/en.json
index 7b0c0f97c..220bc4806 100644
--- a/langs/en.json
+++ b/langs/en.json
@@ -216,7 +216,6 @@
"panoramaxHelp": "Panoramax is an online service which gathers street-level pictures and offers them under a free license. Contributors are allowed to use these pictures to improve OpenStreetMap",
"panoramaxLicenseCCBYSA": "Your pictures are published under CC-BY-SA - everyone can reuse your image if they mention your name",
"seeOnMapillary": "See this image on Mapillary",
-
"themeBy": "Theme maintained by {author}",
"title": "Copyright and attribution",
"translatedBy": "MapComplete has been translated by {contributors} and {hiddenCount} more contributors"
@@ -942,4 +941,4 @@
"startsWithQ": "A wikidata identifier starts with Q and is followed by a number"
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Models/ThemeConfig/Conversion/PrepareLayer.ts b/src/Models/ThemeConfig/Conversion/PrepareLayer.ts
index 8073b2687..d9fb39481 100644
--- a/src/Models/ThemeConfig/Conversion/PrepareLayer.ts
+++ b/src/Models/ThemeConfig/Conversion/PrepareLayer.ts
@@ -1092,15 +1092,47 @@ class DeriveSource extends DesugaringStep {
}
}
-export class OrderLayer extends DesugaringStep {
+export class OrderTagRendering extends DesugaringStep {
+ constructor() {
+ super("OrderTagRendering", "Places all components of a tagRendering in a fixed order")
+ }
+
+ private static readonly tagRenderingAttributesOrder: ReadonlyArray = [
+ "id", "labels", "description", "question", "questionHint", "render", "icon", "freeform", "mappings",
+ "condition", "metacondition", "filter",
+
+ ]
+
+ convert(json: TagRenderingConfigJson, context: ConversionContext): TagRenderingConfigJson {
+ if (typeof json !== "object") {
+ return json
+ }
+ console.log("Ordering", json.id, OrderTagRendering.tagRenderingAttributesOrder)
+ return Utils.reorder(json, OrderTagRendering.tagRenderingAttributesOrder)
+ }
+
+}
+
+export class OrderLayer extends DesugaringStep {
private static readonly layerAttributesOrder: ReadonlyArray = Utils.Dedup(
(layerconfig).filter((c) => c.path.length === 1).map((c) => c.path[0])
)
+
constructor() {
- super("OrderLayer", "Reorders the layer to the default order")
+ super("OrderLayer", "Reorders a tagRendering to the default order")
}
- public convert(json: LayerConfigJson, context: ConversionContext): LayerConfigJson {
+ public convert(json: LayerConfigJson | string, context: ConversionContext): LayerConfigJson | string {
+ if (typeof json !== "object") {
+ return json
+ }
+ if (typeof json === "string") {
+ return json
+ }
+ // @ts-ignore
+ json = new On<"tagRenderings", TagRenderingConfigJson[], LayerConfigJson>("tagRenderings", new Each(
+ new OrderTagRendering(),
+ )).convert(json, context)
return Utils.reorder(json, OrderLayer.layerAttributesOrder)
}
}
diff --git a/src/Models/ThemeConfig/Conversion/PrepareTheme.ts b/src/Models/ThemeConfig/Conversion/PrepareTheme.ts
index bf4213014..22becf17c 100644
--- a/src/Models/ThemeConfig/Conversion/PrepareTheme.ts
+++ b/src/Models/ThemeConfig/Conversion/PrepareTheme.ts
@@ -10,7 +10,7 @@ import {
SetDefault,
} from "./Conversion"
import { ThemeConfigJson } from "../Json/ThemeConfigJson"
-import { PrepareLayer, RewriteSpecial } from "./PrepareLayer"
+import { OrderLayer, PrepareLayer, RewriteSpecial } from "./PrepareLayer"
import { LayerConfigJson } from "../Json/LayerConfigJson"
import { Utils } from "../../../Utils"
import Constants from "../../Constants"
@@ -611,13 +611,15 @@ class PostvalidateTheme extends DesugaringStep {
return json
}
}
-export class OrderTheme extends DesugaringStep {
+export class OrderTheme extends Fuse {
private static readonly themeAttributesOrder: ReadonlyArray = Utils.Dedup(
(themeconfig).filter((c) => c.path.length === 1).map((c) => c.path[0])
)
constructor() {
- super("OrderLayer", "Reorders the layer to the default order")
+ super("Reorders the layer to the default order",
+ new On("layers", new Each(new OrderLayer()))
+ )
}
public convert(json: ThemeConfigJson, context: ConversionContext): ThemeConfigJson {
diff --git a/src/UI/i18n/Translations.ts b/src/UI/i18n/Translations.ts
index 98a53715c..3d8515615 100644
--- a/src/UI/i18n/Translations.ts
+++ b/src/UI/i18n/Translations.ts
@@ -174,7 +174,7 @@ export default class Translations {
/**
* Creates the url to Hosted weblate
*
- * LinkToWeblate.hrefToWeblate("nl", "category:some.context") // => "https://translate.mapcomplete.org/translate/mapcomplete/category/nl/?offset=1&q=context%3A%3D%22some.context%22"
+ * Translations.hrefToWeblate("nl", "category:some.context") // => "https://translate.mapcomplete.org/translate/mapcomplete/category/nl/?offset=1&q=context%3A%3D%22some.context%22"
*/
public static hrefToWeblate(language: string, contextKey: string): string {
if (contextKey === undefined || contextKey.indexOf(":") < 0) {
diff --git a/src/Utils.ts b/src/Utils.ts
index 6105e3796..eb60d2848 100644
--- a/src/Utils.ts
+++ b/src/Utils.ts
@@ -1882,7 +1882,15 @@ In the case that MapComplete is pointed to the testing grounds, the edit will be
return [].concat(...param)
}
+ /**
+ *
+ * JSON.stringify(Utils.reorder({b: "0", a: "1"}, ["a", "b"])) // => '{"a":"1","b":"0"}'
+ * Utils.reorder("test", []) // => "test"
+ */
public static reorder(object: T, order: ReadonlyArray): T {
+ if(typeof object !== "object"){
+ return object
+ }
const allKeys = new Set(Object.keys(object))
const copy = {}
for (const key of order) {