From a8314b39e6d4b1d0fd7e5ab309152949467572e0 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Fri, 17 Jul 2020 14:24:31 +0200 Subject: [PATCH] New dependency system for TagDependantUIElement --- Customizations/Layers/Map.ts | 4 ++++ Customizations/OnlyShowIf.ts | 6 +++--- Customizations/TagRendering.ts | 10 +++++----- Customizations/UIElementConstructor.ts | 2 +- UI/FeatureInfoBox.ts | 9 +++++---- UI/Image/ImageCarouselWithUpload.ts | 6 ++++-- 6 files changed, 22 insertions(+), 15 deletions(-) diff --git a/Customizations/Layers/Map.ts b/Customizations/Layers/Map.ts index f284490..aeadf29 100644 --- a/Customizations/Layers/Map.ts +++ b/Customizations/Layers/Map.ts @@ -83,6 +83,10 @@ export class Map extends LayerDefinition { k: new Tag("map_source:attribution", "no"), txt: "There is no attribution at all" }, + { + k: new Tag("map_source:attribution", "none"), + txt: "There is no attribution at all" + } ] }).OnlyShowIf(new Tag("map_source", "OpenStreetMap")) ] diff --git a/Customizations/OnlyShowIf.ts b/Customizations/OnlyShowIf.ts index c6f6eaf..4d629f0 100644 --- a/Customizations/OnlyShowIf.ts +++ b/Customizations/OnlyShowIf.ts @@ -17,9 +17,9 @@ export class OnlyShowIfConstructor implements TagDependantUIElementConstructor{ this._embedded = embedded; } - construct(tags: UIEventSource, changes: Changes): TagDependantUIElement { - return new OnlyShowIf(tags, - this._embedded.construct(tags, changes), + construct(dependencies): TagDependantUIElement { + return new OnlyShowIf(dependencies.tags, + this._embedded.construct(dependencies), this._tagsFilter); } diff --git a/Customizations/TagRendering.ts b/Customizations/TagRendering.ts index c5f8d63..432872d 100644 --- a/Customizations/TagRendering.ts +++ b/Customizations/TagRendering.ts @@ -86,9 +86,9 @@ export class TagRenderingOptions implements TagDependantUIElementConstructor { }) { this.options = options; } - - OnlyShowIf(tagsFilter: TagsFilter) : TagDependantUIElementConstructor{ - return new OnlyShowIfConstructor(tagsFilter, this); + + OnlyShowIf(dependencies): TagDependantUIElementConstructor { + return new OnlyShowIfConstructor(dependencies, this); } @@ -111,8 +111,8 @@ export class TagRenderingOptions implements TagDependantUIElementConstructor { } - construct(tags: UIEventSource, changes: Changes): TagDependantUIElement { - return new TagRendering(tags, changes, this.options); + construct(dependencies: { tags: UIEventSource, changes: Changes }): TagDependantUIElement { + return new TagRendering(dependencies.tags, dependencies.changes, this.options); } IsKnown(properties: any): boolean { diff --git a/Customizations/UIElementConstructor.ts b/Customizations/UIElementConstructor.ts index d90ce0c..61f16ae 100644 --- a/Customizations/UIElementConstructor.ts +++ b/Customizations/UIElementConstructor.ts @@ -5,7 +5,7 @@ import {UIElement} from "../UI/UIElement"; export interface TagDependantUIElementConstructor { - construct(tags: UIEventSource, changes: Changes): TagDependantUIElement; + construct(dependencies: {tags: UIEventSource, changes: Changes}): TagDependantUIElement; IsKnown(properties: any): boolean; IsQuestioning(properties: any): boolean; Priority(): number; diff --git a/UI/FeatureInfoBox.ts b/UI/FeatureInfoBox.ts index 2c7832c..ee9058f 100644 --- a/UI/FeatureInfoBox.ts +++ b/UI/FeatureInfoBox.ts @@ -41,12 +41,13 @@ export class FeatureInfoBox extends UIElement { this._userDetails = userDetails; this.ListenTo(userDetails); + const deps = {tags:this._tagsES , changes:this._changes} this._infoboxes = []; elementsToShow = elementsToShow ?? [] for (const tagRenderingOption of elementsToShow) { this._infoboxes.push( - tagRenderingOption.construct(this._tagsES, this._changes)); + tagRenderingOption.construct(deps)); } title = title ?? new TagRenderingOptions( @@ -55,9 +56,9 @@ export class FeatureInfoBox extends UIElement { } ) - this._title = new TagRenderingOptions(title.options).construct(this._tagsES, this._changes); - this._osmLink =new OsmLink().construct(this._tagsES, this._changes); - this._wikipedialink = new WikipediaLink().construct(this._tagsES, this._changes); + this._title = new TagRenderingOptions(title.options).construct(deps); + this._osmLink =new OsmLink().construct(deps); + this._wikipedialink = new WikipediaLink().construct(deps); } diff --git a/UI/Image/ImageCarouselWithUpload.ts b/UI/Image/ImageCarouselWithUpload.ts index 231044a..05b6609 100644 --- a/UI/Image/ImageCarouselWithUpload.ts +++ b/UI/Image/ImageCarouselWithUpload.ts @@ -28,8 +28,10 @@ class ImageCarouselWithUpload extends TagDependantUIElement { private _imageElement: ImageCarousel; private _pictureUploader: ImageUploadFlow; - constructor(tags: UIEventSource, changes: Changes) { - super(tags); + constructor(dependencies: {tags: UIEventSource, changes: Changes}) { + super(dependencies.tags); + const tags = dependencies.tags; + const changes = dependencies.changes; this._imageElement = new ImageCarousel(tags, changes); const userDetails = changes.login.userDetails; const license = changes.login.GetPreference( "mapcomplete-pictures-license");