From c25e039a915388219f99bd64e552888cd86084fd Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Mon, 21 Jun 2021 03:14:03 +0200 Subject: [PATCH] Update to climbing theme --- assets/themes/climbing/climbing.json | 35 ++++++++++++++++------------ test.ts | 9 ++++--- test/Tag.spec.ts | 6 +++++ 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/assets/themes/climbing/climbing.json b/assets/themes/climbing/climbing.json index 1cea94407c..c1fd463062 100644 --- a/assets/themes/climbing/climbing.json +++ b/assets/themes/climbing/climbing.json @@ -505,22 +505,27 @@ "images", "questions", { - "#": "Contained routes", - "render": "

Contains the following routes

", - "condition": "_contained_climbing_routes~*" - }, { "#": "Contained routes length hist", "render": { "en": "

Length overview

{histogram(_length_hist)}" - } + }, + "condition": "_length_hist!~\\[\\]" }, { "#": "Contained routes hist", "render": { - "en": "

Difficulties overview

{histogram(_difficulty_hist)}" - } + "en": "

Difficulties overview

{histogram(_difficulty_hist, , , 3[a-zA-Z+-]*:#56bd56, 4[a-zA-Z+-]*:#ffff59,5[a-zA-Z+-]*:#ffad48, 6[a-zA-Z+-]*:#63a9ff, 7[a-zA-Z+-]*:#ff5858, 8[a-zA-Z+-]*:#000000, .*:#aaa )}" + + }, + "condition": "_difficulty_hist!~\\[\\]" + }, + { + "#": "Containe {_contained_climbing_routes_count} routes", + "render": { + "en": "

Contains {_contained_climbing_routes_count} routes

" + }, + "condition": "_contained_climbing_routes~*" }, - { "#": "name", "render": { @@ -622,7 +627,8 @@ "_contained_climbing_routes_properties=feat.overlapWith('climbing_route').map(f => f.feat.properties).map(p => {return {id: p.id, name: p.name, 'climbing:grade:french': p['climbing:grade:french'], 'climbing:length': p['climbing:length']} })", "_contained_climbing_routes=JSON.parse(feat.properties._contained_climbing_routes_properties ?? '[]').map(p => `
  • ${p.name ?? 'climbing route'} (${p['climbing:grade:french'] ?? 'unknown difficulty'}, ${p['climbing:length'] ?? 'unkown length'} meter)
  • `).join('')", "_difficulty_hist=JSON.parse(feat.properties._contained_climbing_routes_properties ?? '[]').map(p => p['climbing:grade:french'])", - "_length_hist=JSON.parse(feat.properties._contained_climbing_routes_properties ?? '[]').map(p => p['climbing:length'])" + "_length_hist=JSON.parse(feat.properties._contained_climbing_routes_properties ?? '[]').map(p => p['climbing:length'])", + "_contained_climbing_routes_count=JSON.parse(_contained_climbing_routes).length" ] }, { @@ -654,15 +660,15 @@ }, "title": { "render": { - "en": "Climbing opportunity?", - "nl": "Klimgelegenheid?", + "en": "Possible climbing opportunity", + "nl": "Mogelijke klimgelegenheid", "de": "Klettermöglichkeit?", "ja": "登坂教室?", "nb_NO": "Klatremulighet?" } }, "description": { - "nl": "Een klimgelegenheid?", + "nl": "Een mogelijke klimgelegenheid?", "de": "Eine Klettergelegenheit?", "en": "A climbing opportunity?", "ja": "登坂教室?", @@ -1226,13 +1232,12 @@ } ], "overrideAll": { - "calculatedTags+": [ + "+calculatedTags": [ "_embedding_feature_properties=feat.overlapWith('climbing').map(f => f.feat.properties).filter(p => p !== undefined).map(p => {return{access: p.access, id: p.id, name: p.name, climbing: p.climbing, 'access:description': p['access:description']}})", "_embedding_features_with_access=JSON.parse(feat.properties._embedding_feature_properties ?? '[]').filter(p => p.access !== undefined)[0]", "_embedding_feature:access=JSON.parse(feat.properties._embedding_features_with_access ?? '{}').access", "_embedding_feature:access:description=JSON.parse(feat.properties._embedding_features_with_access ?? '{}')['access:description']", - "_embedding_feature:id=JSON.parse(feat.properties._embedding_features_with_access ?? '{}').id", - "_layer=feat._layer_id" + "_embedding_feature:id=JSON.parse(feat.properties._embedding_features_with_access ?? '{}').id" ] } } \ No newline at end of file diff --git a/test.ts b/test.ts index 4bf602cf73..1736e2aa98 100644 --- a/test.ts +++ b/test.ts @@ -10,6 +10,8 @@ import {FixedUiElement} from "./UI/Base/FixedUiElement"; import Img from "./UI/Base/Img"; import {AttributedImage} from "./UI/Image/AttributedImage"; import {Imgur} from "./Logic/Web/Imgur"; +import ReviewForm from "./UI/Reviews/ReviewForm"; +import {OsmConnection} from "./Logic/Osm/OsmConnection"; function TestSlideshow(){ @@ -17,7 +19,7 @@ function TestSlideshow(){ new FixedUiElement("A"), new FixedUiElement("qmsldkfjqmlsdkjfmqlskdjfmqlksdf").SetClass("text-xl"), new Img("https://i.imgur.com/8lIQ5Hv.jpg"), - new AttributedImage("https://i.imgur.com/y5XudzW.jpg", new Imgur()), + new AttributedImage("https://i.imgur.com/y5XudzW.jpg", Imgur.singleton), new Img("https://www.grunge.com/img/gallery/the-real-reason-your-cat-sleeps-so-much/intro-1601496900.webp") ]) new SlideShow(elems).AttachTo("maindiv") @@ -62,5 +64,6 @@ function TestAllInputMethods(){ })).AttachTo("maindiv") } - -TestSlideshow() \ No newline at end of file +new ReviewForm(() => { + return undefined; +}, new OsmConnection(true, new UIEventSource(undefined), "test")).AttachTo("maindiv"); \ No newline at end of file diff --git a/test/Tag.spec.ts b/test/Tag.spec.ts index 70f3b19055..4c32dc2e72 100644 --- a/test/Tag.spec.ts +++ b/test/Tag.spec.ts @@ -88,6 +88,12 @@ export default class TagSpec extends T{ equal(assign.matchesProperties({"survey:date": "2021-03-29"}), false); equal(assign.matchesProperties({"_date:now": "2021-03-29"}), false); equal(assign.matchesProperties({"some_key": "2021-03-29"}), false); + + const notEmptyList = FromJSON.Tag("xyz!~\\[\\]") + equal(notEmptyList.matchesProperties({"xyz":undefined}), true); + equal(notEmptyList.matchesProperties({"xyz":"[]"}), false); + equal(notEmptyList.matchesProperties({"xyz":"[\"abc\"]"}), true); + })], ["Is equivalent test", (() => {