Add details rendering

This commit is contained in:
Robin van der Linde 2022-07-13 16:12:25 +02:00
parent 8d8f2f6827
commit befee4b546
Signed by untrusted user: Robin-van-der-Linde
GPG key ID: 53956B3252478F0D
4 changed files with 118 additions and 4 deletions

View file

@ -1,4 +1,4 @@
import {Store, UIEventSource} from "../Logic/UIEventSource";
import {Store, Stores, UIEventSource} from "../Logic/UIEventSource";
import {VariableUiElement} from "./Base/VariableUIElement";
import LiveQueryHandler from "../Logic/Web/LiveQueryHandler";
import {ImageCarousel} from "./Image/ImageCarousel";
@ -57,6 +57,7 @@ import {SaveButton} from "./Popup/SaveButton";
import {MapillaryLink} from "./BigComponents/MapillaryLink";
import {CheckBox} from "./Input/Checkboxes";
import Slider from "./Input/Slider";
import List from "./Base/List";
export interface SpecialVisualization {
funcName: string,
@ -1091,7 +1092,40 @@ export default class SpecialVisualizations {
}))
},
new NearbyImageVis(),
new MapillaryLinkVis()
new MapillaryLinkVis(),
{
funcName: "maproulette_task",
args: [],
constr(state, tagSource, argument, guistate) {
let parentId = tagSource.data.mr_challengeId;
let challenge = Stores.FromPromise(Utils.downloadJsonCached(`https://maproulette.org/api/v2/challenge/${parentId}`,24*60*60*1000));
let details = new VariableUiElement( challenge.map(challenge => {
let listItems: BaseUIElement[] = [];
let title: BaseUIElement;
if (challenge?.name) {
title = new Title(challenge.name);
}
if (challenge?.description) {
listItems.push(new FixedUiElement(challenge.description));
}
if (challenge?.instruction) {
listItems.push(new FixedUiElement(challenge.instruction));
}
if(listItems.length === 0) {
return undefined;
} else {
return [title, new List(listItems)];
}
}))
return details;
},
docs: "Show details of a MapRoulette task"
}
]
specialVisualizations.push(new AutoApplyButton(specialVisualizations))