Add binoculars theme, auto reformat everything

This commit is contained in:
Pieter Vander Vennet 2021-09-09 00:05:51 +02:00
parent 38dea806c5
commit 78d6482c88
586 changed files with 115573 additions and 111842 deletions

View file

@ -4,7 +4,6 @@ import Svg from "../../Svg";
import Img from "../../UI/Base/Img";
import {LocalStorageSource} from "../Web/LocalStorageSource";
import {VariableUiElement} from "../../UI/Base/VariableUIElement";
import BaseUIElement from "../../UI/BaseUIElement";
import LayoutConfig from "../../Models/ThemeConfig/LayoutConfig";
import {QueryParameters} from "../Web/QueryParameters";
@ -161,16 +160,16 @@ export default class GeoLocationHandler extends VariableUiElement {
} else {
lastClick.setData(new Date())
}
}else{
} else {
lastClick.setData(new Date())
}
}
self.init(true, true);
});
const latLonGiven = QueryParameters.wasInitialized("lat") && QueryParameters.wasInitialized("lon")
this.init(false, !latLonGiven);
isLocked.addCallbackAndRunD(isLocked => {
@ -180,7 +179,7 @@ export default class GeoLocationHandler extends VariableUiElement {
leafletMap.data?.dragging?.enable()
}
})
this._currentGPSLocation.addCallback((location) => {
self._previousLocationGrant.setData("granted");

View file

@ -6,7 +6,7 @@ import LayoutConfig from "../../Models/ThemeConfig/LayoutConfig";
export default class InstalledThemes {
public installedThemes: UIEventSource<{ layout: LayoutConfig; definition: string }[]>;
constructor(osmConnection: OsmConnection) {
this.installedThemes = osmConnection.preferencesHandler.preferences.map<{ layout: LayoutConfig, definition: string }[]>(allPreferences => {
const installedThemes: { layout: LayoutConfig, definition: string }[] = [];
@ -25,10 +25,10 @@ export default class InstalledThemes {
}
try {
let layoutJson;
try{
try {
layoutJson = JSON.parse(atob(customLayout.data))
}catch(e){
layoutJson = JSON.parse( Utils.UnMinify(LZString.decompressFromBase64(customLayout.data)))
} catch (e) {
layoutJson = JSON.parse(Utils.UnMinify(LZString.decompressFromBase64(customLayout.data)))
}
const layout = new LayoutConfig(layoutJson, false);
installedThemes.push({
@ -43,7 +43,7 @@ export default class InstalledThemes {
}
InstalledThemes.DeleteInvalid(osmConnection, invalidThemes);
return installedThemes;
});

View file

@ -7,13 +7,13 @@ import Loc from "../../Models/Loc";
* Sets the current background layer to a layer that is actually available
*/
export default class LayerResetter {
constructor( currentBackgroundLayer: UIEventSource<BaseLayer>,
location: UIEventSource<Loc>,
availableLayers: UIEventSource<BaseLayer[]>,
defaultLayerId: UIEventSource<string> = undefined) {
defaultLayerId = defaultLayerId ?? new UIEventSource<string>(AvailableBaseLayers.osmCarto.id);
constructor(currentBackgroundLayer: UIEventSource<BaseLayer>,
location: UIEventSource<Loc>,
availableLayers: UIEventSource<BaseLayer[]>,
defaultLayerId: UIEventSource<string> = undefined) {
defaultLayerId = defaultLayerId ?? new UIEventSource<string>(AvailableBaseLayers.osmCarto.id);
// Change the baselayer back to OSM if we go out of the current range of the layer
availableLayers.addCallbackAndRun(availableLayers => {
let defaultLayer = undefined;
@ -28,7 +28,7 @@ export default class LayerResetter {
if (availableLayer.min_zoom > location.data.zoom) {
break;
}
if(availableLayer.id === defaultLayerId.data){
if (availableLayer.id === defaultLayerId.data) {
defaultLayer = availableLayer;
}
return; // All good - the current layer still works!
@ -38,7 +38,7 @@ export default class LayerResetter {
console.log("AvailableBaseLayers-actor: detected that the current bounds aren't sufficient anymore - reverting to OSM standard")
currentBackgroundLayer.setData(defaultLayer ?? AvailableBaseLayers.osmCarto);
});
}
}

View file

@ -13,7 +13,7 @@ import LayoutConfig from "../../Models/ThemeConfig/LayoutConfig";
export default class OverpassFeatureSource implements FeatureSource {
public readonly name = "OverpassFeatureSource"
/**
* The last loaded features of the geojson
*/
@ -147,7 +147,7 @@ export default class OverpassFeatureSource implements FeatureSource {
}
const bounds = this._leafletMap.data?.getBounds();
if(bounds === undefined){
if (bounds === undefined) {
return;
}

View file

@ -54,7 +54,7 @@ export default class PendingChangesUploader {
function onunload(e) {
if(changes.pendingChanges.data.length == 0){
if (changes.pendingChanges.data.length == 0) {
return;
}
changes.flushChanges("onbeforeunload - probably closing or something similar");

View file

@ -3,6 +3,7 @@ Actors
An **actor** is a module which converts one UIEventSource into another while performing logic.
Typically, it will only expose the constructor taking some UIEventSources (and configuration) and a few fields which are UIEVentSources.
Typically, it will only expose the constructor taking some UIEventSources (and configuration) and a few fields which are
UIEVentSources.
An actor should _never_ have a dependency on 'State' and should _never_ import it

View file

@ -9,11 +9,10 @@ import OsmApiFeatureSource from "../FeatureSource/OsmApiFeatureSource";
* Makes sure the hash shows the selected element and vice-versa.
*/
export default class SelectedFeatureHandler {
private static readonly _no_trigger_on = ["welcome", "copyright", "layers", "new"]
private readonly _featureSource: FeatureSource;
private readonly _hash: UIEventSource<string>;
private readonly _selectedFeature: UIEventSource<any>;
private static readonly _no_trigger_on = ["welcome", "copyright", "layers", "new"]
private readonly _osmApiSource: OsmApiFeatureSource;
constructor(hash: UIEventSource<string>,

View file

@ -1,7 +1,5 @@
import * as L from "leaflet";
import Svg from "../../Svg";
import {UIEventSource} from "../UIEventSource";
import Img from "../../UI/Base/Img";
import ScrollableFullScreen from "../../UI/Base/ScrollableFullScreen";
import AddNewMarker from "../../UI/BigComponents/AddNewMarker";
import FilteredLayer from "../../Models/FilteredLayer";
@ -32,28 +30,28 @@ export default class StrayClickHandler {
})
lastClickLocation.addCallback(function (lastClick) {
if (self._lastMarker !== undefined) {
leafletMap.data?.removeLayer(self._lastMarker);
}
if(lastClick === undefined){
if (lastClick === undefined) {
return;
}
selectedElement.setData(undefined);
const clickCoor : [number, number] = [lastClick.lat, lastClick.lon]
const clickCoor: [number, number] = [lastClick.lat, lastClick.lon]
self._lastMarker = L.marker(clickCoor, {
icon: L.divIcon({
html: new AddNewMarker(filteredLayers).ConstructElement(),
iconSize: [50, 50],
iconAnchor: [25, 50],
popupAnchor: [0, -45]
})
})
});
const popup = L.popup({
autoPan: true,
autoPanPaddingTopLeft: [15,15],
autoPanPaddingTopLeft: [15, 15],
closeOnEscapeKey: true,
autoClose: true
}).setContent("<div id='strayclick' style='height: 65vh'></div>");
@ -61,13 +59,13 @@ export default class StrayClickHandler {
self._lastMarker.bindPopup(popup);
self._lastMarker.on("click", () => {
if(leafletMap.data.getZoom() < Constants.userJourney.minZoomLevelToAddNewPoints){
if (leafletMap.data.getZoom() < Constants.userJourney.minZoomLevelToAddNewPoints) {
self._lastMarker.closePopup()
leafletMap.data.flyTo(clickCoor, Constants.userJourney.minZoomLevelToAddNewPoints)
return;
}
uiToShow.AttachTo("strayclick")
uiToShow.Activate();
});

View file

@ -7,7 +7,7 @@ import Combine from "../../UI/Base/Combine";
import LayoutConfig from "../../Models/ThemeConfig/LayoutConfig";
class TitleElement extends UIEventSource<string> {
private readonly _layoutToUse: UIEventSource<LayoutConfig>;
private readonly _selectedFeature: UIEventSource<any>;
private readonly _allElementsStorage: ElementStorage;
@ -16,17 +16,17 @@ class TitleElement extends UIEventSource<string> {
selectedFeature: UIEventSource<any>,
allElementsStorage: ElementStorage) {
super("MapComplete");
this._layoutToUse = layoutToUse;
this._selectedFeature = selectedFeature;
this._allElementsStorage = allElementsStorage;
this.syncWith(
this._selectedFeature.map(
selected => {
const defaultTitle = Translations.WT(this._layoutToUse.data?.title)?.txt ??"MapComplete"
const defaultTitle = Translations.WT(this._layoutToUse.data?.title)?.txt ?? "MapComplete"
if(selected === undefined){
if (selected === undefined) {
return defaultTitle
}
@ -49,10 +49,9 @@ class TitleElement extends UIEventSource<string> {
}
, [Locale.language, layoutToUse]
)
)
}
}