Fix the build
This commit is contained in:
parent
e42a668c4a
commit
0b57042de1
10 changed files with 62 additions and 41 deletions
|
@ -46,6 +46,8 @@ import FilteringFeatureSource from "./Logic/FeatureSource/FilteringFeatureSource
|
|||
import WayHandlingApplyingFeatureSource from "./Logic/FeatureSource/WayHandlingApplyingFeatureSource";
|
||||
import FeatureSource from "./Logic/FeatureSource/FeatureSource";
|
||||
import NoOverlapSource from "./Logic/FeatureSource/NoOverlapSource";
|
||||
import AvailableBaseLayers from "./Logic/Actors/AvailableBaseLayers";
|
||||
import LayerResetter from "./Logic/Actors/LayerResetter";
|
||||
|
||||
export class InitUiElements {
|
||||
|
||||
|
@ -83,6 +85,12 @@ export class InitUiElements {
|
|||
console.warn("NOT saving custom layout to OSM as we are tesing -> probably in an iFrame")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
InitUiElements.InitBaseMap();
|
||||
|
||||
new FixedUiElement("").AttachTo("decoration-desktop"); // Remove the decoration
|
||||
|
@ -348,6 +356,28 @@ export class InitUiElements {
|
|||
|
||||
static InitBaseMap() {
|
||||
|
||||
State.state.availableBackgroundLayers = new AvailableBaseLayers(State.state.locationControl).availableEditorLayers;
|
||||
State.state.backgroundLayer = QueryParameters.GetQueryParameter("background",
|
||||
State.state.layoutToUse.data.defaultBackgroundId ?? AvailableBaseLayers.osmCarto.id,
|
||||
"The id of the background layer to start with")
|
||||
.map((selectedId: string) => {
|
||||
const available = State.state.availableBackgroundLayers.data;
|
||||
for (const layer of available) {
|
||||
if (layer.id === selectedId) {
|
||||
return layer;
|
||||
}
|
||||
}
|
||||
return AvailableBaseLayers.osmCarto;
|
||||
}, [], layer => layer.id);
|
||||
|
||||
|
||||
|
||||
|
||||
new LayerResetter(
|
||||
State.state.backgroundLayer, State.state.locationControl,
|
||||
State.state.availableBackgroundLayers, State.state.layoutToUse.map((layout: LayoutConfig) => layout.defaultBackgroundId));
|
||||
|
||||
|
||||
const attr = new Attribution(State.state.locationControl, State.state.osmConnection.userDetails, State.state.layoutToUse, State.state.leafletMap);
|
||||
const bm = new Basemap("leafletDiv",
|
||||
State.state.locationControl,
|
||||
|
@ -364,6 +394,10 @@ export class InitUiElements {
|
|||
}
|
||||
|
||||
static InitLayers() {
|
||||
|
||||
|
||||
|
||||
|
||||
const state = State.state;
|
||||
const flayers: FilteredLayer[] = []
|
||||
for (const layer of state.layoutToUse.data.layers) {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
console.log("AVAILABLE LAYERS")
|
||||
import * as editorlayerindex from "../../assets/editor-layer-index.json"
|
||||
import {BaseLayer} from "../../Models/BaseLayer";
|
||||
import * as L from "leaflet";
|
||||
|
|
|
@ -6,7 +6,6 @@ import State from "../../State";
|
|||
import Locale from "../../UI/i18n/Locale";
|
||||
import LayoutConfig from "../../Customizations/JSON/LayoutConfig";
|
||||
import Constants from "../../Models/Constants";
|
||||
import {Basemap} from "../Leaflet/Basemap";
|
||||
|
||||
export class ChangesetHandler {
|
||||
|
||||
|
|
|
@ -16,4 +16,5 @@ export default class Constants {
|
|||
addNewPointWithUnreadMessagesUnlock: 500,
|
||||
minZoomLevelToAddNewPoints: (Utils.isRetina() ? 18 : 19)
|
||||
};
|
||||
|
||||
}
|
4
Models/LeafletMap.ts
Normal file
4
Models/LeafletMap.ts
Normal file
|
@ -0,0 +1,4 @@
|
|||
export default interface LeafletMap {
|
||||
|
||||
getBounds(): [[number, number], [number, number]];
|
||||
}
|
24
State.ts
24
State.ts
|
@ -15,9 +15,7 @@ import InstalledThemes from "./Logic/Actors/InstalledThemes";
|
|||
import {BaseLayer} from "./Models/BaseLayer";
|
||||
import Loc from "./Models/Loc";
|
||||
import Constants from "./Models/Constants";
|
||||
import AvailableBaseLayers from "./Logic/Actors/AvailableBaseLayers";
|
||||
import * as L from "leaflet"
|
||||
import LayerResetter from "./Logic/Actors/LayerResetter";
|
||||
|
||||
import UpdateFromOverpass from "./Logic/Actors/UpdateFromOverpass";
|
||||
import LayerConfig from "./Customizations/JSON/LayerConfig";
|
||||
|
||||
|
@ -101,7 +99,7 @@ export default class State {
|
|||
* The map location: currently centered lat, lon and zoom
|
||||
*/
|
||||
public readonly locationControl = new UIEventSource<Loc>(undefined);
|
||||
public readonly backgroundLayer;
|
||||
public backgroundLayer;
|
||||
/* Last location where a click was registered
|
||||
*/
|
||||
public readonly LastClickLocation: UIEventSource<{ lat: number, lon: number }> = new UIEventSource<{ lat: number, lon: number }>(undefined)
|
||||
|
@ -155,24 +153,6 @@ export default class State {
|
|||
});
|
||||
|
||||
|
||||
this.availableBackgroundLayers = new AvailableBaseLayers(this.locationControl).availableEditorLayers;
|
||||
this.backgroundLayer = QueryParameters.GetQueryParameter("background",
|
||||
this.layoutToUse.data.defaultBackgroundId ?? AvailableBaseLayers.osmCarto.id,
|
||||
"The id of the background layer to start with")
|
||||
.map((selectedId: string) => {
|
||||
const available = self.availableBackgroundLayers.data;
|
||||
for (const layer of available) {
|
||||
if (layer.id === selectedId) {
|
||||
return layer;
|
||||
}
|
||||
}
|
||||
return AvailableBaseLayers.osmCarto;
|
||||
}, [], layer => layer.id);
|
||||
|
||||
|
||||
new LayerResetter(
|
||||
this.backgroundLayer, this.locationControl,
|
||||
this.availableBackgroundLayers, this.layoutToUse.map((layout: LayoutConfig) => layout.defaultBackgroundId));
|
||||
|
||||
|
||||
function featSw(key: string, deflt: (layout: LayoutConfig) => boolean, documentation: string): UIEventSource<boolean> {
|
||||
|
|
|
@ -7,14 +7,14 @@ import {UserDetails} from "../../Logic/Osm/OsmConnection";
|
|||
import Constants from "../../Models/Constants";
|
||||
import LayoutConfig from "../../Customizations/JSON/LayoutConfig";
|
||||
import Loc from "../../Models/Loc";
|
||||
import * as L from "leaflet"
|
||||
import LeafletMap from "../../Models/LeafletMap";
|
||||
|
||||
export default class Attribution extends UIElement {
|
||||
|
||||
private readonly _location: UIEventSource<Loc>;
|
||||
private readonly _layoutToUse: UIEventSource<LayoutConfig>;
|
||||
private readonly _userDetails: UIEventSource<UserDetails>;
|
||||
private readonly _leafletMap: UIEventSource<L.Map>;
|
||||
private readonly _leafletMap: UIEventSource<LeafletMap>;
|
||||
|
||||
constructor(location: UIEventSource<Loc>,
|
||||
userDetails: UIEventSource<UserDetails>,
|
||||
|
|
|
@ -6,6 +6,7 @@ import {FixedUiElement} from "../Base/FixedUiElement";
|
|||
import {OH} from "./OpeningHours";
|
||||
import Translations from "../i18n/Translations";
|
||||
import Constants from "../../Models/Constants";
|
||||
import opening_hours from "opening_hours";
|
||||
|
||||
export default class OpeningHoursVisualization extends UIElement {
|
||||
private readonly _key: string;
|
||||
|
|
|
@ -8,7 +8,7 @@ import {FixedUiElement} from "./Base/FixedUiElement";
|
|||
import Locale from "../UI/i18n/Locale";
|
||||
import {ImageUploadFlow} from "./Image/ImageUploadFlow";
|
||||
import {Translation} from "./i18n/Translation";
|
||||
import State from "../State";
|
||||
|
||||
import ShareButton from "./ShareButton";
|
||||
import Svg from "../Svg";
|
||||
import ReviewElement from "./Reviews/ReviewElement";
|
||||
|
@ -17,6 +17,8 @@ import Translations from "./i18n/Translations";
|
|||
import ReviewForm from "./Reviews/ReviewForm";
|
||||
import OpeningHoursVisualization from "./OpeningHours/OhVisualization";
|
||||
|
||||
import State from "../State";
|
||||
|
||||
export class SubstitutedTranslation extends UIElement {
|
||||
private readonly tags: UIEventSource<any>;
|
||||
private readonly translation: Translation;
|
||||
|
@ -89,7 +91,7 @@ export class SubstitutedTranslation extends UIElement {
|
|||
}
|
||||
|
||||
|
||||
const element = knownSpecial.constr(this.tags, args);
|
||||
const element = knownSpecial.constr(State.state, this.tags, args);
|
||||
return [...partBefore, element, ...partAfter]
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
|
@ -108,7 +110,7 @@ export default class SpecialVisualizations {
|
|||
|
||||
public static specialVisualizations: {
|
||||
funcName: string,
|
||||
constr: ((tagSource: UIEventSource<any>, argument: string[]) => UIElement),
|
||||
constr: ((state: State,tagSource: UIEventSource<any>, argument: string[]) => UIElement),
|
||||
docs: string,
|
||||
example?: string,
|
||||
args: { name: string, defaultValue?: string, doc: string }[]
|
||||
|
@ -118,7 +120,7 @@ export default class SpecialVisualizations {
|
|||
funcName: "all_tags",
|
||||
docs: "Prints all key-value pairs of the object - used for debugging",
|
||||
args: [],
|
||||
constr: ((tags: UIEventSource<any>) => {
|
||||
constr: ((state: State,tags: UIEventSource<any>) => {
|
||||
return new VariableUiElement(tags.map(tags => {
|
||||
const parts = [];
|
||||
for (const key in tags) {
|
||||
|
@ -142,7 +144,7 @@ export default class SpecialVisualizations {
|
|||
defaultValue: "true",
|
||||
doc: "Also include images given via 'Wikidata', 'wikimedia_commons' and 'mapillary"
|
||||
}],
|
||||
constr: (tags, args) => {
|
||||
constr: (state: State,tags, args) => {
|
||||
return new ImageCarousel(tags, args[0], args[1].toLowerCase() === "true");
|
||||
}
|
||||
},
|
||||
|
@ -155,7 +157,7 @@ export default class SpecialVisualizations {
|
|||
doc: "Image tag to add the URL to (or image-tag:0, image-tag:1 when multiple images are added)",
|
||||
defaultValue: "image"
|
||||
}],
|
||||
constr: (tags, args) => {
|
||||
constr: (state: State,tags, args) => {
|
||||
return new ImageUploadFlow(tags, args[0])
|
||||
}
|
||||
},
|
||||
|
@ -167,7 +169,7 @@ export default class SpecialVisualizations {
|
|||
name: "subject",
|
||||
doc: "The identifier used for this value; by default the name of the reviewed object"
|
||||
}],
|
||||
constr: (tags, args) => {
|
||||
constr: (state: State,tags, args) => {
|
||||
const tgs = tags.data;
|
||||
console.log("Args[0]", args[0])
|
||||
let subject = tgs.name ?? "";
|
||||
|
@ -179,10 +181,10 @@ export default class SpecialVisualizations {
|
|||
}
|
||||
const mangrove = MangroveReviews.Get(Number(tgs._lon), Number(tgs._lat),
|
||||
encodeURIComponent(subject),
|
||||
State.state.mangroveIdentity,
|
||||
State.state.osmConnection._dryRun
|
||||
state.mangroveIdentity,
|
||||
state.osmConnection._dryRun
|
||||
);
|
||||
const form = new ReviewForm((r, whenDone) => mangrove.AddReview(r, whenDone), State.state.osmConnection.userDetails);
|
||||
const form = new ReviewForm((r, whenDone) => mangrove.AddReview(r, whenDone), state.osmConnection.userDetails);
|
||||
return new ReviewElement(mangrove.GetSubjectUri(), mangrove.GetReviews(), form);
|
||||
}
|
||||
},
|
||||
|
@ -194,7 +196,7 @@ export default class SpecialVisualizations {
|
|||
defaultValue: "opening_hours",
|
||||
doc: "The tagkey from which the table is constructed."
|
||||
}],
|
||||
constr: (tagSource: UIEventSource<any>, args) => {
|
||||
constr: (state: State,tagSource: UIEventSource<any>, args) => {
|
||||
let keyname = args[0];
|
||||
if (keyname === undefined || keyname === "") {
|
||||
keyname = keyname ?? "opening_hours"
|
||||
|
@ -215,7 +217,7 @@ export default class SpecialVisualizations {
|
|||
}, {
|
||||
name: "path", doc: "The path (or shorthand) that should be returned"
|
||||
}],
|
||||
constr: (tagSource: UIEventSource<any>, args) => {
|
||||
constr: (state: State,tagSource: UIEventSource<any>, args) => {
|
||||
const url = args[0];
|
||||
const shorthands = args[1];
|
||||
const neededValue = args[2];
|
||||
|
@ -233,9 +235,9 @@ export default class SpecialVisualizations {
|
|||
doc: "The url to share (defualt: current URL)",
|
||||
}
|
||||
],
|
||||
constr: (tagSource: UIEventSource<any>, args) => {
|
||||
constr: (state: State,tagSource: UIEventSource<any>, args) => {
|
||||
if (window.navigator.share) {
|
||||
const title = State.state.layoutToUse.data.title.txt;
|
||||
const title = state.layoutToUse.data.title.txt;
|
||||
let name = tagSource.data.name;
|
||||
if (name) {
|
||||
name = `${name} (${title})`
|
||||
|
@ -249,7 +251,7 @@ export default class SpecialVisualizations {
|
|||
return new ShareButton(Svg.share_svg(), {
|
||||
title: name,
|
||||
url: url,
|
||||
text: State.state.layoutToUse.data.shortDescription.txt
|
||||
text: state.layoutToUse.data.shortDescription.txt
|
||||
})
|
||||
} else {
|
||||
return new FixedUiElement("")
|
||||
|
|
|
@ -12,7 +12,6 @@ import Translations from "../UI/i18n/Translations";
|
|||
import {Translation} from "../UI/i18n/Translation";
|
||||
import LayoutConfig from "../Customizations/JSON/LayoutConfig";
|
||||
|
||||
|
||||
function enc(str: string): string {
|
||||
return encodeURIComponent(str.toLowerCase());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue