diff --git a/Customizations/JSON/LayoutConfig.ts b/Customizations/JSON/LayoutConfig.ts index 00764d490f..4bf3ae2a29 100644 --- a/Customizations/JSON/LayoutConfig.ts +++ b/Customizations/JSON/LayoutConfig.ts @@ -152,11 +152,10 @@ export default class LayoutConfig { ); } - const defaultClustering = { + this.clustering = { maxZoom: 16, minNeededElements: 500 }; - this.clustering = defaultClustering; if (json.clustering) { this.clustering = { maxZoom: json.clustering.maxZoom ?? 18, @@ -164,7 +163,7 @@ export default class LayoutConfig { } for (const layer of this.layers) { if (layer.wayHandling !== LayerConfig.WAYHANDLING_CENTER_ONLY) { - console.error("WARNING: In order to allow clustering, every layer must be set to CENTER_ONLY. Layer", layer.id, "does not respect this for layout", this.id); + console.debug("WARNING: In order to allow clustering, every layer must be set to CENTER_ONLY. Layer", layer.id, "does not respect this for layout", this.id); } } } diff --git a/UI/BaseUIElement.ts b/UI/BaseUIElement.ts index 8bafff884f..1570dd3ead 100644 --- a/UI/BaseUIElement.ts +++ b/UI/BaseUIElement.ts @@ -86,6 +86,7 @@ export default abstract class BaseUIElement { } return this; } + /** * The same as 'Render', but creates a HTML element instead of the HTML representation */ diff --git a/UI/BigComponents/ShareButton.ts b/UI/BigComponents/ShareButton.ts index 474abe7cd8..7b3d0255be 100644 --- a/UI/BigComponents/ShareButton.ts +++ b/UI/BigComponents/ShareButton.ts @@ -2,16 +2,16 @@ import BaseUIElement from "../BaseUIElement"; export default class ShareButton extends BaseUIElement{ private _embedded: BaseUIElement; - private _shareData: { text: string; title: string; url: string }; + private _shareData: () => { text: string; title: string; url: string }; - constructor(embedded: BaseUIElement, shareData: { + constructor(embedded: BaseUIElement, generateShareData: () => { text: string, title: string, url: string }) { super(); this._embedded = embedded; - this._shareData = shareData; + this._shareData = generateShareData; this.SetClass("share-button") } @@ -22,7 +22,7 @@ export default class ShareButton extends BaseUIElement{ e.addEventListener('click', () => { if (navigator.share) { - navigator.share(this._shareData).then(() => { + navigator.share(this._shareData()).then(() => { console.log('Thanks for sharing!'); }) .catch(err => { diff --git a/UI/Image/SlideShow.ts b/UI/Image/SlideShow.ts index 692bb87488..01b6cbe5e3 100644 --- a/UI/Image/SlideShow.ts +++ b/UI/Image/SlideShow.ts @@ -16,36 +16,6 @@ export class SlideShow extends BaseUIElement { const el = document.createElement("div") el.classList.add("slic-carousel") - el.onchange = () => { - console.log("Parent is now ", el.parentElement) - } - - const mutationObserver = new MutationObserver(mutations => { - console.log("Mutations are: ", mutations) - - - mutationObserver.disconnect() - require("slick-carousel") - // @ts-ignore - el.slick({ - autoplay: true, - arrows: true, - dots: true, - lazyLoad: 'progressive', - variableWidth: true, - centerMode: true, - centerPadding: "60px", - adaptive: true - }); - }) - - mutationObserver.observe(el, { - childList: true, - characterData: true, - subtree: true - }) - - this.embeddedElements.addCallbackAndRun(elements => { for (const element of elements ?? []) { element.SetClass("slick-carousel-content") diff --git a/UI/Popup/TagRenderingAnswer.ts b/UI/Popup/TagRenderingAnswer.ts index 86db6437ef..6c8fd257ec 100644 --- a/UI/Popup/TagRenderingAnswer.ts +++ b/UI/Popup/TagRenderingAnswer.ts @@ -19,6 +19,13 @@ export default class TagRenderingAnswer extends VariableUiElement { if(tags === undefined){ return undefined; } + + if(configuration.condition){ + if(!configuration.condition.matchesProperties(tags)){ + return undefined; + } + } + const trs = Utils.NoNull(configuration.GetRenderValues(tags)); if(trs.length === 0){ return undefined; diff --git a/UI/SpecialVisualizations.ts b/UI/SpecialVisualizations.ts index 5ee4591c52..b1f1a5559d 100644 --- a/UI/SpecialVisualizations.ts +++ b/UI/SpecialVisualizations.ts @@ -17,10 +17,10 @@ import OpeningHoursVisualization from "./OpeningHours/OhVisualization"; import State from "../State"; import {ImageSearcher} from "../Logic/Actors/ImageSearcher"; import BaseUIElement from "./BaseUIElement"; +import LayerConfig from "../Customizations/JSON/LayerConfig"; export default class SpecialVisualizations { - - + public static specialVisualizations: { funcName: string, @@ -38,7 +38,7 @@ export default class SpecialVisualizations { return new VariableUiElement(tags.map(tags => { const parts = []; for (const key in tags) { - if(!tags.hasOwnProperty(key)){ + if (!tags.hasOwnProperty(key)) { continue; } parts.push(key + "=" + tags[key]); @@ -160,22 +160,36 @@ export default class SpecialVisualizations { ], constr: (state: State, tagSource: UIEventSource, args) => { if (window.navigator.share) { - const title = state?.layoutToUse?.data?.title?.txt ?? "MapComplete"; - let name = tagSource.data.name; - if (name) { - name = `${name} (${title})` - } else { - name = title; + + const generateShareData = () => { + + + const title = state?.layoutToUse?.data?.title?.txt ?? "MapComplete"; + + let matchingLayer: LayerConfig = undefined; + for (const layer of (state?.layoutToUse?.data?.layers ?? [])) { + if (layer.source.osmTags.matchesProperties(tagSource?.data)) { + matchingLayer = layer + } + } + let name = matchingLayer?.title?.GetRenderValue(tagSource.data)?.txt ?? tagSource.data?.name ?? "POI"; + if (name) { + name = `${name} (${title})` + } else { + name = title; + } + let url = args[0] ?? "" + if (url === "") { + url = window.location.href + } + return { + title: name, + url: url, + text: state?.layoutToUse?.data?.shortDescription?.txt ?? "MapComplete" + } } - let url = args[0] ?? "" - if (url === "") { - url = window.location.href - } - return new ShareButton(Svg.share_ui(), { - title: name, - url: url, - text: state?.layoutToUse?.data?.shortDescription?.txt ?? "MapComplete" - }) + + return new ShareButton(Svg.share_ui(), generateShareData) } else { return new FixedUiElement("") } diff --git a/UI/SubstitutedTranslation.ts b/UI/SubstitutedTranslation.ts index d48e56cb99..2a51d15e47 100644 --- a/UI/SubstitutedTranslation.ts +++ b/UI/SubstitutedTranslation.ts @@ -13,14 +13,14 @@ export class SubstitutedTranslation extends VariableUiElement { public constructor( translation: Translation, - tags: UIEventSource) { + tagsSource: UIEventSource) { super( - tags.map(tags => { + tagsSource.map(tags => { const txt = Utils.SubstituteKeys(translation.txt, tags) if (txt === undefined) { - return "no tags subs tr" + return undefined } - return new Combine(SubstitutedTranslation.EvaluateSpecialComponents(txt, tags)) + return new Combine(SubstitutedTranslation.EvaluateSpecialComponents(txt, tagsSource)) }, [Locale.language]) ) @@ -59,6 +59,7 @@ export class SubstitutedTranslation extends VariableUiElement { try{ element = knownSpecial.constr(State.state, tags, args); }catch(e){ + console.error("SPECIALRENDERING FAILED for", tags.data.id, e) element = new FixedUiElement(`Could not generate special renering for ${knownSpecial}(${args.join(", ")}) ${e}`).SetClass("alert") }