forked from MapComplete/MapComplete
refactoring: Fix generateLayouts
This commit is contained in:
parent
5117bccb9a
commit
7f26e4cb3b
5 changed files with 67 additions and 161 deletions
|
@ -1,71 +1,13 @@
|
|||
import {FixedUiElement} from "./UI/Base/FixedUiElement";
|
||||
import {QueryParameters} from "./Logic/Web/QueryParameters";
|
||||
import Combine from "./UI/Base/Combine";
|
||||
import AvailableBaseLayers from "./Logic/Actors/AvailableBaseLayers";
|
||||
import MinimapImplementation from "./UI/Base/MinimapImplementation";
|
||||
import {Utils} from "./Utils";
|
||||
import { Utils } from "./Utils"
|
||||
import ThemeViewState from "./Models/ThemeViewState"
|
||||
import SvelteUIElement from "./UI/Base/SvelteUIElement"
|
||||
import ThemeViewGUI from "./UI/ThemeViewGUI.svelte"
|
||||
import LayoutConfig from "./Models/ThemeConfig/LayoutConfig";
|
||||
import DefaultGUI from "./UI/DefaultGUI";
|
||||
import State from "./State";
|
||||
import AvailableBaseLayersImplementation from "./Logic/Actors/AvailableBaseLayersImplementation";
|
||||
import ShowOverlayLayerImplementation from "./UI/ShowDataLayer/ShowOverlayLayerImplementation";
|
||||
import {DefaultGuiState} from "./UI/DefaultGuiState";
|
||||
import DashboardGui from "./UI/DashboardGui";
|
||||
|
||||
|
||||
document.getElementById("decoration-desktop").remove();
|
||||
new Combine(["Initializing... <br/>",
|
||||
new FixedUiElement("<a>If this message persist, something went wrong - click here to try again</a>")
|
||||
.SetClass("link-underline small")
|
||||
.onClick(() => {
|
||||
localStorage.clear();
|
||||
window.location.reload(true);
|
||||
|
||||
})])
|
||||
.AttachTo("centermessage"); // Add an initialization and reset button if something goes wrong
|
||||
|
||||
|
||||
|
||||
// Workaround for a stupid crash: inject some functions which would give stupid circular dependencies or crash the other nodejs scripts running from console
|
||||
MinimapImplementation.initialize()
|
||||
AvailableBaseLayers.implement(new AvailableBaseLayersImplementation())
|
||||
ShowOverlayLayerImplementation.Implement();
|
||||
// Miscelleanous
|
||||
Utils.DisableLongPresses()
|
||||
if(new URLSearchParams(window.location.search).get("test") === "true"){
|
||||
console.log(themeConfig)
|
||||
}
|
||||
const layoutToUse = new LayoutConfig(themeConfig)
|
||||
|
||||
|
||||
// Workaround/legacy to keep the old paramters working as I renamed some of them
|
||||
if (layoutToUse?.id === "cyclofix") {
|
||||
const legacy = QueryParameters.GetQueryParameter("layer-bike_shops", "true", "Legacy - keep De Fietsambassade working");
|
||||
const correct = QueryParameters.GetQueryParameter("layer-bike_shop", "true", "Legacy - keep De Fietsambassade working")
|
||||
if (legacy.data !== "true") {
|
||||
correct.setData(legacy.data)
|
||||
}
|
||||
console.log("layer-bike_shop toggles: legacy:", legacy.data, "new:", correct.data)
|
||||
|
||||
const legacyCafe = QueryParameters.GetQueryParameter("layer-bike_cafes", "true", "Legacy - keep De Fietsambassade working")
|
||||
const correctCafe = QueryParameters.GetQueryParameter("layer-bike_cafe", "true", "Legacy - keep De Fietsambassade working")
|
||||
if (legacyCafe.data !== "true") {
|
||||
correctCafe.setData(legacy.data)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
const guiState = new DefaultGuiState()
|
||||
State.state = new State(layoutToUse);
|
||||
DefaultGuiState.state = guiState;
|
||||
// This 'leaks' the global state via the window object, useful for debugging
|
||||
// @ts-ignore
|
||||
window.mapcomplete_state = State.state;
|
||||
|
||||
const mode = QueryParameters.GetQueryParameter("mode", "map", "The mode the application starts in, e.g. 'map' or 'dashboard'")
|
||||
if(mode.data === "dashboard"){
|
||||
new DashboardGui(State.state, guiState).setup()
|
||||
}else{
|
||||
new DefaultGUI(State.state, guiState).setup()
|
||||
}
|
||||
const state = new ThemeViewState(new LayoutConfig(<any> layout))
|
||||
const main = new SvelteUIElement(ThemeViewGUI, { state })
|
||||
main.AttachTo("maindiv")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue