forked from MapComplete/MapComplete
I should have commited sooner...
This commit is contained in:
parent
2685b6e734
commit
16612b10ef
35 changed files with 570 additions and 177 deletions
|
@ -14,7 +14,6 @@ export class FullScreenMessageBox extends UIElement {
|
|||
constructor(onClear: (() => void)) {
|
||||
super(State.state.fullScreenMessage);
|
||||
this.HideOnEmpty(true);
|
||||
const self = this;
|
||||
|
||||
this.returnToTheMap =
|
||||
new Combine([Translations.t.general.returnToTheMap.Clone().SetStyle("font-size:xx-large")])
|
||||
|
|
|
@ -2,6 +2,10 @@ import {InputElement} from "./InputElement";
|
|||
import {UIEventSource} from "../../Logic/UIEventSource";
|
||||
import Combine from "../Base/Combine";
|
||||
import Svg from "../../Svg";
|
||||
import * as L from "leaflet"
|
||||
import * as X from "leaflet-providers"
|
||||
import {Basemap} from "../../Logic/Leaflet/Basemap";
|
||||
import State from "../../State";
|
||||
|
||||
/**
|
||||
* Selects a direction in degrees
|
||||
|
@ -34,8 +38,8 @@ export default class DirectionInput extends InputElement<string> {
|
|||
}
|
||||
|
||||
InnerRender(): string {
|
||||
console.log("Inner render direction")
|
||||
return new Combine([
|
||||
`<div id="direction-leaflet-div-${this.id}" style="width:100%;height: 100%;position: absolute;top:0;left:0;border-radius:100%;"></div>`,
|
||||
Svg.direction_svg().SetStyle(
|
||||
`position: absolute;top: 0;left: 0;width: 100%;height: 100%;rotate:${this.value.data}deg;`)
|
||||
.SetClass("direction-svg"),
|
||||
|
@ -47,8 +51,7 @@ export default class DirectionInput extends InputElement<string> {
|
|||
}
|
||||
|
||||
protected InnerUpdate(htmlElement: HTMLElement) {
|
||||
console.log("Inner update direction")
|
||||
super.InnerUpdate(htmlElement);
|
||||
super.InnerUpdate(htmlElement);
|
||||
const self = this;
|
||||
|
||||
function onPosChange(x: number, y: number) {
|
||||
|
@ -57,7 +60,7 @@ export default class DirectionInput extends InputElement<string> {
|
|||
const dy = (rect.top + rect.bottom) / 2 - y;
|
||||
const angle = 180 * Math.atan2(dy, dx) / Math.PI;
|
||||
const angleGeo = Math.floor((450 - angle) % 360);
|
||||
self.value.setData(""+angleGeo)
|
||||
self.value.setData("" + angleGeo)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -16,7 +16,9 @@ interface TextFieldDef {
|
|||
explanation: string,
|
||||
isValid: ((s: string, country?: string) => boolean),
|
||||
reformat?: ((s: string, country?: string) => string),
|
||||
inputHelper?: (value: UIEventSource<string>) => InputElement<string>,
|
||||
inputHelper?: (value: UIEventSource<string>, options?: {
|
||||
location: [number, number]
|
||||
}) => InputElement<string>,
|
||||
}
|
||||
|
||||
export default class ValidatedTextField {
|
||||
|
@ -26,7 +28,9 @@ export default class ValidatedTextField {
|
|||
explanation: string,
|
||||
isValid?: ((s: string, country?: string) => boolean),
|
||||
reformat?: ((s: string, country?: string) => string),
|
||||
inputHelper?: (value: UIEventSource<string>) => InputElement<string>): TextFieldDef {
|
||||
inputHelper?: (value: UIEventSource<string>, options?:{
|
||||
location: [number, number]
|
||||
}) => InputElement<string>): TextFieldDef {
|
||||
|
||||
if (isValid === undefined) {
|
||||
isValid = () => true;
|
||||
|
@ -197,7 +201,8 @@ export default class ValidatedTextField {
|
|||
textArea?: boolean,
|
||||
textAreaRows?: number,
|
||||
isValid?: ((s: string, country: string) => boolean),
|
||||
country?: string
|
||||
country?: string,
|
||||
location?: [number /*lat*/, number /*lon*/]
|
||||
}): InputElement<string> {
|
||||
options = options ?? {};
|
||||
options.placeholder = options.placeholder ?? type;
|
||||
|
@ -230,7 +235,9 @@ export default class ValidatedTextField {
|
|||
}
|
||||
|
||||
if (tp.inputHelper) {
|
||||
input = new CombinedInputElement(input, tp.inputHelper(input.GetValue()));
|
||||
input = new CombinedInputElement(input, tp.inputHelper(input.GetValue(),{
|
||||
location: options.location
|
||||
}));
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,8 @@ export class FeatureInfoBox extends UIElement {
|
|||
this._layerConfig = layerConfig;
|
||||
|
||||
|
||||
this._title = new TagRenderingAnswer(tags, layerConfig.title)
|
||||
this._title = layerConfig.title === undefined ? undefined :
|
||||
new TagRenderingAnswer(tags, layerConfig.title)
|
||||
.SetClass("featureinfobox-title");
|
||||
this._titleIcons = new Combine(
|
||||
layerConfig.titleIcons.map(icon => new TagRenderingAnswer(tags, icon)))
|
||||
|
|
|
@ -15,6 +15,9 @@ export default class TagRenderingAnswer extends UIElement {
|
|||
super(tags);
|
||||
this._tags = tags;
|
||||
this._configuration = configuration;
|
||||
if(configuration === undefined){
|
||||
throw "Trying to generate a tagRenderingAnswer without configuration..."
|
||||
}
|
||||
}
|
||||
|
||||
InnerRender(): string {
|
||||
|
|
|
@ -251,7 +251,8 @@ export default class TagRenderingQuestion extends UIElement {
|
|||
|
||||
const textField = ValidatedTextField.InputForType(this._configuration.freeform.type, {
|
||||
isValid: (str) => (str.length <= 255),
|
||||
country: this._tags.data._country
|
||||
country: this._tags.data._country,
|
||||
location: [this._tags.data._lat, this._tags.data._lon]
|
||||
});
|
||||
|
||||
textField.GetValue().setData(this._tags.data[this._configuration.freeform.key]);
|
||||
|
|
|
@ -39,12 +39,16 @@ export class SubstitutedTranslation extends UIElement {
|
|||
return []
|
||||
}
|
||||
const tags = this.tags.data;
|
||||
txt = SubstitutedTranslation.SubstituteKeys(txt, tags);
|
||||
return this.EvaluateSpecialComponents(txt);
|
||||
}
|
||||
|
||||
public static SubstituteKeys(txt: string, tags: any) {
|
||||
for (const key in tags) {
|
||||
// Poor mans replace all
|
||||
txt = txt.split("{" + key + "}").join(tags[key]);
|
||||
}
|
||||
|
||||
return this.EvaluateSpecialComponents(txt);
|
||||
return txt;
|
||||
}
|
||||
|
||||
private EvaluateSpecialComponents(template: string): UIElement[] {
|
||||
|
|
|
@ -94,15 +94,6 @@ export class UserBadge extends UIElement {
|
|||
dryrun = new FixedUiElement("TESTING").SetClass("alert");
|
||||
}
|
||||
|
||||
if (user.home !== undefined) {
|
||||
const icon = L.icon({
|
||||
iconUrl: Img.AsData(Svg.home_white_bg),
|
||||
iconSize: [30, 30],
|
||||
iconAnchor: [15, 15]
|
||||
});
|
||||
L.marker([user.home.lat, user.home.lon], {icon: icon}).addTo(State.state.bm.map)
|
||||
}
|
||||
|
||||
const settings =
|
||||
new Link(Svg.gear_svg(),
|
||||
`https://www.openstreetmap.org/user/${encodeURIComponent(user.name)}/account`,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue