forked from MapComplete/MapComplete
Full code cleanup
This commit is contained in:
parent
8e6ee8c87f
commit
bd21212eba
246 changed files with 19418 additions and 11729 deletions
|
@ -15,9 +15,9 @@ export class FixedInputElement<T> extends InputElement<T> {
|
|||
comparator: ((t0: T, t1: T) => boolean) = undefined) {
|
||||
super();
|
||||
this._comparator = comparator ?? ((t0, t1) => t0 == t1);
|
||||
if(value instanceof UIEventSource){
|
||||
if (value instanceof UIEventSource) {
|
||||
this.value = value
|
||||
}else{
|
||||
} else {
|
||||
this.value = new UIEventSource<T>(value);
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ export default class LengthInput extends InputElement<string> {
|
|||
background: this.background,
|
||||
allowMoving: false,
|
||||
location: this._location,
|
||||
attribution:true,
|
||||
attribution: true,
|
||||
leafletOptions: {
|
||||
tap: true
|
||||
}
|
||||
|
|
|
@ -96,22 +96,22 @@ export default class LocationInput extends InputElement<Loc> implements MinimapO
|
|||
let min = undefined;
|
||||
let matchedWay = undefined;
|
||||
for (const feature of self._snapTo.data ?? []) {
|
||||
try{
|
||||
|
||||
const nearestPointOnLine = GeoOperations.nearestPoint(feature.feature, [loc.lon, loc.lat])
|
||||
if (min === undefined) {
|
||||
min = nearestPointOnLine
|
||||
matchedWay = feature.feature;
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
|
||||
if (min.properties.dist > nearestPointOnLine.properties.dist) {
|
||||
min = nearestPointOnLine
|
||||
matchedWay = feature.feature;
|
||||
const nearestPointOnLine = GeoOperations.nearestPoint(feature.feature, [loc.lon, loc.lat])
|
||||
if (min === undefined) {
|
||||
min = nearestPointOnLine
|
||||
matchedWay = feature.feature;
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
}catch(e){
|
||||
console.log("Snapping to a nearest point failed for ", feature.feature,"due to ", e)
|
||||
if (min.properties.dist > nearestPointOnLine.properties.dist) {
|
||||
min = nearestPointOnLine
|
||||
matchedWay = feature.feature;
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
console.log("Snapping to a nearest point failed for ", feature.feature, "due to ", e)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -167,8 +167,9 @@ export default class LocationInput extends InputElement<Loc> implements MinimapO
|
|||
installBounds(factor: number | BBox, showRange?: boolean): void {
|
||||
this.map.installBounds(factor, showRange)
|
||||
}
|
||||
|
||||
TakeScreenshot(): Promise<any> {
|
||||
return this.map.TakeScreenshot()
|
||||
return this.map.TakeScreenshot()
|
||||
}
|
||||
|
||||
protected InnerConstructElement(): HTMLElement {
|
||||
|
|
|
@ -18,16 +18,8 @@ export default class Toggle extends VariableUiElement {
|
|||
this.isEnabled = isEnabled
|
||||
}
|
||||
|
||||
public ToggleOnClick(): Toggle {
|
||||
const self = this;
|
||||
this.onClick(() => {
|
||||
self.isEnabled.setData(!self.isEnabled.data);
|
||||
})
|
||||
return this;
|
||||
}
|
||||
|
||||
public static If(condition: UIEventSource<boolean>, constructor: () => BaseUIElement): BaseUIElement {
|
||||
if(constructor === undefined){
|
||||
public static If(condition: UIEventSource<boolean>, constructor: () => BaseUIElement): BaseUIElement {
|
||||
if (constructor === undefined) {
|
||||
return undefined
|
||||
}
|
||||
return new Toggle(
|
||||
|
@ -35,6 +27,14 @@ export default class Toggle extends VariableUiElement {
|
|||
undefined,
|
||||
condition
|
||||
)
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ToggleOnClick(): Toggle {
|
||||
const self = this;
|
||||
this.onClick(() => {
|
||||
self.isEnabled.setData(!self.isEnabled.data);
|
||||
})
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -271,7 +271,7 @@ export default class ValidatedTextField {
|
|||
if (args[0]) {
|
||||
zoom = Number(args[0])
|
||||
if (isNaN(zoom)) {
|
||||
console.error("Invalid zoom level for argument at 'length'-input. The offending argument is: ",args[0]," (using 19 instead)")
|
||||
console.error("Invalid zoom level for argument at 'length'-input. The offending argument is: ", args[0], " (using 19 instead)")
|
||||
zoom = 19
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,9 +5,9 @@ import {VariableUiElement} from "../Base/VariableUIElement";
|
|||
|
||||
export default class VariableInputElement<T> extends InputElement<T> {
|
||||
|
||||
public readonly IsSelected: UIEventSource<boolean>;
|
||||
private readonly value: UIEventSource<T>;
|
||||
private readonly element: BaseUIElement
|
||||
public readonly IsSelected: UIEventSource<boolean>;
|
||||
private readonly upstream: UIEventSource<InputElement<T>>;
|
||||
|
||||
constructor(upstream: UIEventSource<InputElement<T>>) {
|
||||
|
@ -23,13 +23,12 @@ export default class VariableInputElement<T> extends InputElement<T> {
|
|||
return this.value;
|
||||
}
|
||||
|
||||
protected InnerConstructElement(): HTMLElement {
|
||||
return this.element.ConstructElement();
|
||||
}
|
||||
|
||||
|
||||
IsValid(t: T): boolean {
|
||||
return this.upstream.data.IsValid(t);
|
||||
}
|
||||
|
||||
protected InnerConstructElement(): HTMLElement {
|
||||
return this.element.ConstructElement();
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue