2020-06-27 03:06:51 +02:00
|
|
|
import {UIElement} from "./UIElement";
|
|
|
|
import {TagMapping, TagMappingOptions} from "./TagMapping";
|
|
|
|
import {Question, QuestionDefinition} from "../Logic/Question";
|
|
|
|
import {UIEventSource} from "./UIEventSource";
|
|
|
|
import {VerticalCombine} from "./VerticalCombine";
|
|
|
|
import {QuestionPicker} from "./QuestionPicker";
|
|
|
|
import {OsmImageUploadHandler} from "../Logic/OsmImageUploadHandler";
|
|
|
|
import {ImageCarousel} from "./Image/ImageCarousel";
|
|
|
|
import {Changes} from "../Logic/Changes";
|
|
|
|
import {UserDetails} from "../Logic/OsmConnection";
|
|
|
|
import {Img} from "./Img";
|
|
|
|
import {CommonTagMappings} from "../Layers/CommonTagMappings";
|
|
|
|
import {Tag} from "../Logic/TagsFilter";
|
2020-06-28 00:06:23 +02:00
|
|
|
import {ImageUploadFlow} from "./ImageUploadFlow";
|
2020-06-27 03:06:51 +02:00
|
|
|
|
|
|
|
export class FeatureInfoBox extends UIElement {
|
|
|
|
|
|
|
|
private _tagsES: UIEventSource<any>;
|
|
|
|
|
|
|
|
|
|
|
|
private _title: UIElement;
|
|
|
|
private _osmLink: UIElement;
|
|
|
|
private _infoElements: UIElement[]
|
|
|
|
|
|
|
|
|
|
|
|
private _questions: QuestionPicker;
|
|
|
|
|
|
|
|
private _changes: Changes;
|
|
|
|
private _userDetails: UIEventSource<UserDetails>;
|
|
|
|
private _imageElement: ImageCarousel;
|
2020-06-28 00:06:23 +02:00
|
|
|
private _pictureUploader: UIElement;
|
|
|
|
private _wikipedialink: UIElement;
|
2020-06-27 03:06:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
tagsES: UIEventSource<any>,
|
|
|
|
elementsToShow: (TagMappingOptions | QuestionDefinition | UIElement)[],
|
|
|
|
questions: QuestionDefinition[],
|
|
|
|
changes: Changes,
|
|
|
|
userDetails: UIEventSource<UserDetails>,
|
|
|
|
) {
|
|
|
|
super(tagsES);
|
|
|
|
this._tagsES = tagsES;
|
|
|
|
this._changes = changes;
|
|
|
|
this._userDetails = userDetails;
|
|
|
|
|
|
|
|
this._imageElement = new ImageCarousel(this._tagsES);
|
|
|
|
|
|
|
|
this._questions = new QuestionPicker(
|
|
|
|
this._changes.asQuestions(questions), this._tagsES);
|
|
|
|
|
|
|
|
var infoboxes: UIElement[] = [];
|
|
|
|
for (const uiElement of elementsToShow) {
|
|
|
|
if (uiElement instanceof QuestionDefinition) {
|
|
|
|
const questionDef = uiElement as QuestionDefinition;
|
|
|
|
const question = new Question(this._changes, questionDef);
|
|
|
|
infoboxes.push(question.CreateHtml(this._tagsES));
|
|
|
|
} else if (uiElement instanceof TagMappingOptions) {
|
|
|
|
const tagMappingOpt = uiElement as TagMappingOptions;
|
|
|
|
infoboxes.push(new TagMapping(tagMappingOpt, this._tagsES))
|
|
|
|
} else {
|
|
|
|
const ui = uiElement as UIElement;
|
|
|
|
infoboxes.push(ui);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
this._title = infoboxes.shift();
|
|
|
|
this._infoElements = infoboxes;
|
|
|
|
|
|
|
|
this._osmLink = new TagMapping(CommonTagMappings.osmLink, this._tagsES);
|
2020-06-28 00:06:23 +02:00
|
|
|
this._wikipedialink = new TagMapping(CommonTagMappings.wikipediaLink, this._tagsES);
|
|
|
|
this._pictureUploader = new OsmImageUploadHandler(tagsES, userDetails, changes, this._imageElement.slideshow).getUI();
|
2020-06-27 03:06:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
InnerRender(): string {
|
|
|
|
|
2020-06-28 00:06:23 +02:00
|
|
|
let questions = "";
|
|
|
|
|
|
|
|
if (this._userDetails.data.loggedIn) {
|
|
|
|
questions = this._questions.HideOnEmpty(true).Render();
|
|
|
|
}
|
2020-06-27 03:06:51 +02:00
|
|
|
|
|
|
|
return "<div class='featureinfobox'>" +
|
|
|
|
"<div class='featureinfoboxtitle'>" +
|
|
|
|
"<span>" + this._title.Render() + "</span>" +
|
2020-06-28 00:06:23 +02:00
|
|
|
this._wikipedialink.Render() +
|
2020-06-27 03:06:51 +02:00
|
|
|
this._osmLink.Render() +
|
|
|
|
"</div>" +
|
2020-06-28 00:06:23 +02:00
|
|
|
|
2020-06-27 03:06:51 +02:00
|
|
|
"<div class='infoboxcontents'>" +
|
|
|
|
|
|
|
|
this._imageElement.Render() +
|
2020-06-28 00:06:23 +02:00
|
|
|
this._pictureUploader.Render() +
|
|
|
|
|
|
|
|
new VerticalCombine(this._infoElements, 'infobox-information').HideOnEmpty(true).Render() +
|
|
|
|
|
|
|
|
questions +
|
|
|
|
|
2020-06-27 03:06:51 +02:00
|
|
|
|
|
|
|
"</div>" +
|
|
|
|
"" +
|
|
|
|
"</div>";
|
|
|
|
}
|
|
|
|
|
|
|
|
Activate() {
|
|
|
|
super.Activate();
|
|
|
|
this._imageElement.Activate();
|
2020-06-28 00:06:23 +02:00
|
|
|
this._pictureUploader.Activate();
|
2020-06-27 03:06:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Update() {
|
|
|
|
super.Update();
|
|
|
|
this._imageElement.Update();
|
2020-06-28 00:06:23 +02:00
|
|
|
this._pictureUploader.Update();
|
2020-06-27 03:06:51 +02:00
|
|
|
}
|
|
|
|
}
|