forked from MapComplete/MapComplete
Finish the additions of reviews
This commit is contained in:
parent
c02406241e
commit
cdfffd6120
29 changed files with 675 additions and 142 deletions
|
@ -35,11 +35,25 @@ export class FeatureInfoBox extends UIElement {
|
|||
this._titleIcons = new Combine(
|
||||
layerConfig.titleIcons.map(icon => new TagRenderingAnswer(tags, icon)))
|
||||
.SetClass("featureinfobox-icons");
|
||||
this._renderings = layerConfig.tagRenderings.map(tr => new EditableTagRendering(tags, tr));
|
||||
this._renderings[0]?.SetClass("first-rendering");
|
||||
|
||||
let questionBox : UIElement = undefined;
|
||||
if (State.state.featureSwitchUserbadge.data) {
|
||||
this._questionBox = new QuestionBox(tags, layerConfig.tagRenderings);
|
||||
questionBox = new QuestionBox(tags, layerConfig.tagRenderings);
|
||||
}
|
||||
|
||||
let questionBoxIsUsed = false;
|
||||
this._renderings = layerConfig.tagRenderings.map(tr => {
|
||||
if(tr.question === null){
|
||||
questionBoxIsUsed = true;
|
||||
// This is the question box!
|
||||
return questionBox;
|
||||
}
|
||||
return new EditableTagRendering(tags, tr);
|
||||
});
|
||||
this._renderings[0]?.SetClass("first-rendering");
|
||||
if(!questionBoxIsUsed){
|
||||
this._renderings.push(questionBox);
|
||||
}
|
||||
}
|
||||
|
||||
InnerRender(): string {
|
||||
|
|
|
@ -22,7 +22,9 @@ export default class QuestionBox extends UIElement {
|
|||
this.ListenTo(this._skippedQuestions);
|
||||
this._tags = tags;
|
||||
const self = this;
|
||||
this._tagRenderings = tagRenderings.filter(tr => tr.question !== undefined);
|
||||
this._tagRenderings = tagRenderings
|
||||
.filter(tr => tr.question !== undefined)
|
||||
.filter(tr => tr.question !== null);
|
||||
this._tagRenderingQuestions = this._tagRenderings
|
||||
.map((tagRendering, i) => new TagRenderingQuestion(this._tags, tagRendering,
|
||||
() => {
|
||||
|
|
|
@ -1,32 +1,33 @@
|
|||
import {UIEventSource} from "../../Logic/UIEventSource";
|
||||
import {UIElement} from "../UIElement";
|
||||
import Translations from "../i18n/Translations";
|
||||
import State from "../../State";
|
||||
import {OsmConnection, UserDetails} from "../../Logic/Osm/OsmConnection";
|
||||
|
||||
export class SaveButton extends UIElement {
|
||||
|
||||
private _value: UIEventSource<any>;
|
||||
private _friendlyLogin: UIElement;
|
||||
private readonly _value: UIEventSource<any>;
|
||||
private readonly _friendlyLogin: UIElement;
|
||||
private readonly _userDetails: UIEventSource<UserDetails>;
|
||||
|
||||
constructor(value: UIEventSource<any>) {
|
||||
constructor(value: UIEventSource<any>, osmConnection: OsmConnection) {
|
||||
super(value);
|
||||
this._userDetails = osmConnection?.userDetails;
|
||||
if(value === undefined){
|
||||
throw "No event source for savebutton, something is wrong"
|
||||
}
|
||||
this._value = value;
|
||||
|
||||
this._friendlyLogin = Translations.t.general.loginToStart.Clone()
|
||||
.SetClass("login-button-friendly")
|
||||
.onClick(() => State.state.osmConnection.AttemptLogin())
|
||||
.onClick(() => osmConnection?.AttemptLogin())
|
||||
}
|
||||
|
||||
InnerRender(): string {
|
||||
let clss = "save";
|
||||
|
||||
if(State.state !== undefined && !State.state.osmConnection.userDetails.data.loggedIn){
|
||||
if(this._userDetails != undefined && !this._userDetails.data.loggedIn){
|
||||
return this._friendlyLogin.Render();
|
||||
}
|
||||
if ((this._value.data ?? "") === "") {
|
||||
if (this._value.data === false || (this._value.data ?? "") === "") {
|
||||
clss = "save-non-active";
|
||||
}
|
||||
return Translations.t.general.save.Clone().SetClass(clss).Render();
|
||||
|
|
|
@ -64,7 +64,7 @@ export default class TagRenderingQuestion extends UIElement {
|
|||
}
|
||||
|
||||
|
||||
this._saveButton = new SaveButton(this._inputElement.GetValue())
|
||||
this._saveButton = new SaveButton(this._inputElement.GetValue(), State.state.osmConnection)
|
||||
.onClick(save)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue