New dependency system for TagDependantUIElement
This commit is contained in:
parent
d7809b88bc
commit
a8314b39e6
6 changed files with 22 additions and 15 deletions
|
@ -83,6 +83,10 @@ export class Map extends LayerDefinition {
|
||||||
k: new Tag("map_source:attribution", "no"),
|
k: new Tag("map_source:attribution", "no"),
|
||||||
txt: "There is no attribution at all"
|
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"))
|
}).OnlyShowIf(new Tag("map_source", "OpenStreetMap"))
|
||||||
]
|
]
|
||||||
|
|
|
@ -17,9 +17,9 @@ export class OnlyShowIfConstructor implements TagDependantUIElementConstructor{
|
||||||
this._embedded = embedded;
|
this._embedded = embedded;
|
||||||
}
|
}
|
||||||
|
|
||||||
construct(tags: UIEventSource<any>, changes: Changes): TagDependantUIElement {
|
construct(dependencies): TagDependantUIElement {
|
||||||
return new OnlyShowIf(tags,
|
return new OnlyShowIf(dependencies.tags,
|
||||||
this._embedded.construct(tags, changes),
|
this._embedded.construct(dependencies),
|
||||||
this._tagsFilter);
|
this._tagsFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,8 +87,8 @@ export class TagRenderingOptions implements TagDependantUIElementConstructor {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
OnlyShowIf(tagsFilter: TagsFilter) : TagDependantUIElementConstructor{
|
OnlyShowIf(dependencies): TagDependantUIElementConstructor {
|
||||||
return new OnlyShowIfConstructor(tagsFilter, this);
|
return new OnlyShowIfConstructor(dependencies, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,8 +111,8 @@ export class TagRenderingOptions implements TagDependantUIElementConstructor {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
construct(tags: UIEventSource<any>, changes: Changes): TagDependantUIElement {
|
construct(dependencies: { tags: UIEventSource<any>, changes: Changes }): TagDependantUIElement {
|
||||||
return new TagRendering(tags, changes, this.options);
|
return new TagRendering(dependencies.tags, dependencies.changes, this.options);
|
||||||
}
|
}
|
||||||
|
|
||||||
IsKnown(properties: any): boolean {
|
IsKnown(properties: any): boolean {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import {UIElement} from "../UI/UIElement";
|
||||||
|
|
||||||
export interface TagDependantUIElementConstructor {
|
export interface TagDependantUIElementConstructor {
|
||||||
|
|
||||||
construct(tags: UIEventSource<any>, changes: Changes): TagDependantUIElement;
|
construct(dependencies: {tags: UIEventSource<any>, changes: Changes}): TagDependantUIElement;
|
||||||
IsKnown(properties: any): boolean;
|
IsKnown(properties: any): boolean;
|
||||||
IsQuestioning(properties: any): boolean;
|
IsQuestioning(properties: any): boolean;
|
||||||
Priority(): number;
|
Priority(): number;
|
||||||
|
|
|
@ -41,12 +41,13 @@ export class FeatureInfoBox extends UIElement {
|
||||||
this._userDetails = userDetails;
|
this._userDetails = userDetails;
|
||||||
this.ListenTo(userDetails);
|
this.ListenTo(userDetails);
|
||||||
|
|
||||||
|
const deps = {tags:this._tagsES , changes:this._changes}
|
||||||
|
|
||||||
this._infoboxes = [];
|
this._infoboxes = [];
|
||||||
elementsToShow = elementsToShow ?? []
|
elementsToShow = elementsToShow ?? []
|
||||||
for (const tagRenderingOption of elementsToShow) {
|
for (const tagRenderingOption of elementsToShow) {
|
||||||
this._infoboxes.push(
|
this._infoboxes.push(
|
||||||
tagRenderingOption.construct(this._tagsES, this._changes));
|
tagRenderingOption.construct(deps));
|
||||||
}
|
}
|
||||||
|
|
||||||
title = title ?? new TagRenderingOptions(
|
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._title = new TagRenderingOptions(title.options).construct(deps);
|
||||||
this._osmLink =new OsmLink().construct(this._tagsES, this._changes);
|
this._osmLink =new OsmLink().construct(deps);
|
||||||
this._wikipedialink = new WikipediaLink().construct(this._tagsES, this._changes);
|
this._wikipedialink = new WikipediaLink().construct(deps);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,10 @@ class ImageCarouselWithUpload extends TagDependantUIElement {
|
||||||
private _imageElement: ImageCarousel;
|
private _imageElement: ImageCarousel;
|
||||||
private _pictureUploader: ImageUploadFlow;
|
private _pictureUploader: ImageUploadFlow;
|
||||||
|
|
||||||
constructor(tags: UIEventSource<any>, changes: Changes) {
|
constructor(dependencies: {tags: UIEventSource<any>, changes: Changes}) {
|
||||||
super(tags);
|
super(dependencies.tags);
|
||||||
|
const tags = dependencies.tags;
|
||||||
|
const changes = dependencies.changes;
|
||||||
this._imageElement = new ImageCarousel(tags, changes);
|
this._imageElement = new ImageCarousel(tags, changes);
|
||||||
const userDetails = changes.login.userDetails;
|
const userDetails = changes.login.userDetails;
|
||||||
const license = changes.login.GetPreference( "mapcomplete-pictures-license");
|
const license = changes.login.GetPreference( "mapcomplete-pictures-license");
|
||||||
|
|
Loading…
Reference in a new issue