Fixed some typos, fixed legacy loading in non-legacy settings, also show attribution when layer control is disabled

This commit is contained in:
pietervdvn 2021-05-03 16:04:35 +02:00
parent 4a3537f925
commit b441e6e8a5
8 changed files with 75 additions and 60 deletions

View file

@ -208,11 +208,11 @@ export class InitUiElements {
} }
let json: {} let json: {}
try{ try {
json = JSON.parse(atob(hash)); json = JSON.parse(atob(hash));
} catch (e) { } catch (e) {
// We try to decode with lz-string // We try to decode with lz-string
json = JSON.parse( Utils.UnMinify(LZString.decompressFromBase64(hash))) as LayoutConfigJson; json = JSON.parse(Utils.UnMinify(LZString.decompressFromBase64(hash))) as LayoutConfigJson;
} }
@ -229,7 +229,6 @@ export class InitUiElements {
private static OnlyIf(featureSwitch: UIEventSource<boolean>, callback: () => void) { private static OnlyIf(featureSwitch: UIEventSource<boolean>, callback: () => void) {
featureSwitch.addCallbackAndRun(() => { featureSwitch.addCallbackAndRun(() => {
if (featureSwitch.data) { if (featureSwitch.data) {
callback(); callback();
} }
@ -269,16 +268,7 @@ export class InitUiElements {
} }
private static InitLayerSelection() { private static InitLayerSelection() {
InitUiElements.OnlyIf(State.state.featureSwitchLayers, () => {
const layerControlPanel = new LayerControlPanel(
State.state.layerControlIsOpened)
.SetClass("block p-1 rounded-full");
const checkbox = new CheckBox(
layerControlPanel,
new MapControlButton(Svg.layers_svg()),
State.state.layerControlIsOpened
)
const copyrightNotice = const copyrightNotice =
new ScrollableFullScreen( new ScrollableFullScreen(
() => Translations.t.general.attribution.attributionTitle.Clone(), () => Translations.t.general.attribution.attributionTitle.Clone(),
@ -293,24 +283,39 @@ export class InitUiElements {
copyrightNotice.isShown copyrightNotice.isShown
).SetClass("p-0.5") ).SetClass("p-0.5")
new Combine([copyrightButton, checkbox]) const layerControlPanel = new LayerControlPanel(
State.state.layerControlIsOpened)
.SetClass("block p-1 rounded-full");
const layerControlButton = new CheckBox(
layerControlPanel,
new MapControlButton(Svg.layers_svg()),
State.state.layerControlIsOpened
)
const layerControl = new CheckBox(
layerControlButton,
"",
State.state.featureSwitchLayers
)
new Combine([copyrightButton, layerControl])
.AttachTo("bottom-left"); .AttachTo("bottom-left");
State.state.locationControl State.state.locationControl
.addCallback(() => { .addCallback(() => {
// Close the layer selection when the map is moved // Close the layer selection when the map is moved
checkbox.isEnabled.setData(false); layerControlButton.isEnabled.setData(false);
copyrightButton.isEnabled.setData(false); copyrightButton.isEnabled.setData(false);
}); });
State.state.selectedElement.addCallbackAndRun(feature => { State.state.selectedElement.addCallbackAndRun(feature => {
if (feature !== undefined) { if (feature !== undefined) {
checkbox.isEnabled.setData(false); layerControlButton.isEnabled.setData(false);
copyrightButton.isEnabled.setData(false);
} }
}) })
});
} }
private static InitBaseMap() { private static InitBaseMap() {

View file

@ -15,8 +15,6 @@ public readonly name = "FilteringFeatureSource"
const self = this; const self = this;
console.log("INITING pipeline: ",layers)
function update() { function update() {
const layerDict = {}; const layerDict = {};
@ -69,6 +67,7 @@ public readonly name = "FilteringFeatureSource"
return false; return false;
}); });
console.log("Filtering layer source: input: ", upstream.features.data?.length, "output:", newFeatures.length)
self.features.setData(newFeatures); self.features.setData(newFeatures);
if(missingLayers.size > 0){ if(missingLayers.size > 0){
console.error("Some layers were not found: ", Array.from(missingLayers)) console.error("Some layers were not found: ", Array.from(missingLayers))

View file

@ -2,7 +2,7 @@ import { Utils } from "../Utils";
export default class Constants { export default class Constants {
public static vNumber = "0.7.0a"; public static vNumber = "0.7.0b";
// The user journey states thresholds when a new feature gets unlocked // The user journey states thresholds when a new feature gets unlocked
public static userJourney = { public static userJourney = {

View file

@ -52,7 +52,7 @@ export class SubtleButton extends UIElement{
return new Combine([ return new Combine([
this.image, this.image,
this.message, this.message,
]).SetClass("block flex p-3 my-2 bg-blue-100 rounded-lg hover:shadow-xl hover:bg-blue-200") ]).SetClass("block flex p-3 my-2 bg-blue-100 rounded-lg hover:shadow-xl hover:bg-blue-200 link-no-underline")
.Render(); .Render();
} }

View file

@ -114,6 +114,10 @@ a {
color: #0078A8; color: #0078A8;
} }
.link-no-underline a {
text-decoration: none;
}
li { li {
margin-left: 0.5em; margin-left: 0.5em;
padding-left: 0.2em; padding-left: 0.2em;

View file

@ -1,3 +1,4 @@
<!DOCTYPE html> <!DOCTYPE html>
<!-- WARNING: index.html serves as a template. If you want to change something, change it there --> <!-- WARNING: index.html serves as a template. If you want to change something, change it there -->
<html lang="en"> <html lang="en">

View file

@ -1,10 +1,10 @@
{ {
"name": "index", "name": "index",
"short_name": "M", "short_name": "MapComplete",
"start_url": "/index.html", "start_url": "/index.html",
"display": "standalone", "display": "standalone",
"background_color": "#fff", "background_color": "#fff",
"description": "M", "description": "An easy to use OpenStreetMap viewer and editor",
"orientation": "portrait-primary, landscape-primary", "orientation": "portrait-primary, landscape-primary",
"icons": [ "icons": [
{ {

View file

@ -70,13 +70,19 @@ let layoutToUse: LayoutConfig = AllKnownLayouts.allKnownLayouts.get(defaultLayou
const userLayoutParam = QueryParameters.GetQueryParameter("userlayout", "false", "If not 'false', a custom (non-official) theme is loaded. This custom layout can be done in multiple ways: \n\n- The hash of the URL contains a base64-encoded .json-file containing the theme definition\n- The hash of the URL contains a lz-compressed .json-file, as generated by the custom theme generator\n- The parameter itself is an URL, in which case that URL will be downloaded. It should point to a .json of a theme"); const userLayoutParam = QueryParameters.GetQueryParameter("userlayout", "false", "If not 'false', a custom (non-official) theme is loaded. This custom layout can be done in multiple ways: \n\n- The hash of the URL contains a base64-encoded .json-file containing the theme definition\n- The hash of the URL contains a lz-compressed .json-file, as generated by the custom theme generator\n- The parameter itself is an URL, in which case that URL will be downloaded. It should point to a .json of a theme");
// Workaround/legacy to keep the old paramters working as I renamed some of them // Workaround/legacy to keep the old paramters working as I renamed some of them
if(layoutToUse?.id === "cyclofix"){ if (layoutToUse?.id === "cyclofix") {
QueryParameters.GetQueryParameter("layer-bike_shops", "true", "Legacy - keep De Fietsambassade working").syncWith( const legacy = QueryParameters.GetQueryParameter("layer-bike_shops", "true", "Legacy - keep De Fietsambassade working");
QueryParameters.GetQueryParameter("layer-bike_shop","true","Legacy - keep De Fietsambassade working") const correct = QueryParameters.GetQueryParameter("layer-bike_shop", "true", "Legacy - keep De Fietsambassade working")
) if(legacy.data !== "true"){
const bikecafes = QueryParameters.GetQueryParameter("layer-bike_cafes", "true", "Legacy - keep De Fietsambassade working").syncWith( correct.setData(legacy.data)
QueryParameters.GetQueryParameter("layer-bike_cafe","true","Legacy - keep De Fietsambassade working") }
) 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)
}
} }
@ -98,7 +104,7 @@ if (layoutFromBase64.startsWith("http")) {
try { try {
console.log("Received ", data) console.log("Received ", data)
let parsed = data; let parsed = data;
if(typeof parsed == "string"){ if (typeof parsed == "string") {
parsed = JSON.parse(data); parsed = JSON.parse(data);
} }
// Overwrite the id to the wiki:value // Overwrite the id to the wiki:value
@ -129,10 +135,10 @@ if (layoutFromBase64.startsWith("http")) {
// This is the default case: a builtin theme // This is the default case: a builtin theme
InitUiElements.InitAll(layoutToUse, layoutFromBase64, testing, defaultLayout); InitUiElements.InitAll(layoutToUse, layoutFromBase64, testing, defaultLayout);
} else { } else {
// We fall through: no theme loaded: just show a few buttons // We fall through: no theme loaded: just show an overview of layouts
State.state = new State(undefined); State.state = new State(undefined);
new Combine([new MoreScreen(true), new Combine([new MoreScreen(true),
Translations.t.general.aboutMapcomplete Translations.t.general.aboutMapcomplete.SetClass("link-underline")
]).SetClass("block m-5 lg:w-3/4 lg:ml-40") ]).SetClass("block m-5 lg:w-3/4 lg:ml-40")
.SetStyle("pointer-events: all;") .SetStyle("pointer-events: all;")
.AttachTo("topleft-tools"); .AttachTo("topleft-tools");