Merge develop

This commit is contained in:
Pieter Vander Vennet 2022-02-14 20:10:49 +01:00
commit 29f6716fa9
209 changed files with 8475 additions and 4933 deletions

View file

@ -226,7 +226,6 @@ class AutomatonGui {
const osmConnection = new OsmConnection({
allElements: undefined,
changes: undefined,
layoutName: "automaton",
singlePage: false,
oauth_token: QueryParameters.GetQueryParameter("oauth_token", "OAuth token")
});

View file

@ -102,11 +102,6 @@ export default abstract class BaseUIElement {
return this._constructedHtmlElement
}
if (this.InnerConstructElement === undefined) {
throw "ERROR! This is not a correct baseUIElement: " + this.constructor.name
}
try {
const el = this.InnerConstructElement();
@ -152,7 +147,7 @@ export default abstract class BaseUIElement {
}
public AsMarkdown(): string {
throw "AsMarkdown is not implemented by " + this.constructor.name + "; implement it in the subclass"
throw "AsMarkdown is not implemented; implement it in the subclass"
}
public Destroy() {

View file

@ -20,7 +20,6 @@ import Toggle from "../Input/Toggle";
import {OsmConnection} from "../../Logic/Osm/OsmConnection";
import Constants from "../../Models/Constants";
import ContributorCount from "../../Logic/ContributorCount";
import {icon} from "leaflet";
import Img from "../Base/Img";
export class OpenIdEditor extends VariableUiElement {
@ -211,7 +210,11 @@ export default class CopyrightPanel extends Combine {
private static IconAttribution(iconPath: string): BaseUIElement {
if (iconPath.startsWith("http")) {
try{
iconPath = "." + new URL(iconPath).pathname;
}catch(e){
console.error(e)
}
}
const license: SmallLicense = CopyrightPanel.LicenseObject[iconPath]

View file

@ -0,0 +1,81 @@
import {UIElement} from "../UIElement";
import BaseUIElement from "../BaseUIElement";
import {UIEventSource} from "../../Logic/UIEventSource";
import ExtraLinkConfig from "../../Models/ThemeConfig/ExtraLinkConfig";
import MapControlButton from "../MapControlButton";
import Link from "../Base/Link";
import Img from "../Base/Img";
import {SubtleButton} from "../Base/SubtleButton";
import Toggle from "../Input/Toggle";
import Loc from "../../Models/Loc";
import Locale from "../i18n/Locale";
import {Utils} from "../../Utils";
export default class ExtraLinkButton extends UIElement{
private readonly _config: ExtraLinkConfig;
private readonly state: {
layoutToUse: {id: string};
featureSwitchWelcomeMessage: UIEventSource<boolean>, locationControl: UIEventSource<Loc>};
constructor(state: {featureSwitchWelcomeMessage: UIEventSource<boolean>, locationControl: UIEventSource<Loc>, layoutToUse: {id: string}},
config: ExtraLinkConfig) {
super();
this.state = state;
this._config = config;
}
protected InnerRender(): BaseUIElement {
if(this._config === undefined){
return undefined;
}
const c = this._config;
const isIframe = window !== window.top
if(c.requirements.has("iframe") && !isIframe){
return undefined
}
if(c.requirements.has("no-iframe") && isIframe){
return undefined
}
let link : BaseUIElement
const theme = this.state.layoutToUse?.id ?? ""
const href = this.state.locationControl.map(loc => {
const subs = {
...loc,
theme: theme,
language: Locale.language.data
}
return Utils.SubstituteKeys(c.href, subs)
})
if(c.text === undefined){
link = new MapControlButton(
new Link(new Img(c.icon), href, c.newTab).SetClass("block w-full h-full p-1.5")
)
}else {
let img : BaseUIElement = undefined
if(c.icon !== undefined){
img = new Img(c.icon).SetClass("h-6")
}
link = new SubtleButton(img,c.text, {url:
href,
newTab: c.newTab})
}
if(c.requirements.has("no-welcome-message")){
link = new Toggle(undefined, link, this.state.featureSwitchWelcomeMessage)
}
if(c.requirements.has("welcome-message")){
link = new Toggle(link, undefined, this.state.featureSwitchWelcomeMessage)
}
return link;
}
}

View file

@ -9,7 +9,7 @@ import BaseUIElement from "../BaseUIElement";
import LayoutConfig from "../../Models/ThemeConfig/LayoutConfig";
import {UIEventSource} from "../../Logic/UIEventSource";
import Loc from "../../Models/Loc";
import {OsmConnection} from "../../Logic/Osm/OsmConnection";
import UserDetails, {OsmConnection} from "../../Logic/Osm/OsmConnection";
import UserRelatedState from "../../Logic/State/UserRelatedState";
import Toggle from "../Input/Toggle";
import {Utils} from "../../Utils";
@ -52,7 +52,8 @@ export default class MoreScreen extends Combine {
id: string,
icon: string,
title: any,
shortDescription: any
shortDescription: any,
definition?: any
}, isCustom: boolean = false
):
BaseUIElement {
@ -87,6 +88,11 @@ export default class MoreScreen extends Combine {
linkPrefix = `${path}/theme.html?userlayout=${layout.id}&`
}
let hash = ""
if(layout.definition !== undefined){
hash = "#"+btoa(JSON.stringify(layout.definition))
}
const linkText = currentLocation?.map(currentLocation => {
const params = [
["z", currentLocation?.zoom],
@ -95,10 +101,11 @@ export default class MoreScreen extends Combine {
].filter(part => part[1] !== undefined)
.map(part => part[0] + "=" + part[1])
.join("&")
return `${linkPrefix}${params}`;
return `${linkPrefix}${params}${hash}`;
}) ?? new UIEventSource<string>(`${linkPrefix}`)
return new SubtleButton(layout.icon,
new Combine([
`<dt class='text-lg leading-6 font-medium text-gray-900 group-hover:text-blue-800'>`,
@ -134,7 +141,8 @@ export default class MoreScreen extends Combine {
id: string
icon: string,
title: any,
shortDescription: any
shortDescription: any,
definition?: any
} = JSON.parse(str)
return MoreScreen.createLinkButton(state, value, true)

View file

@ -8,9 +8,7 @@ import Svg from "../Svg";
import Toggle from "./Input/Toggle";
import UserBadge from "./BigComponents/UserBadge";
import SearchAndGo from "./BigComponents/SearchAndGo";
import Link from "./Base/Link";
import BaseUIElement from "./BaseUIElement";
import {VariableUiElement} from "./Base/VariableUIElement";
import LeftControls from "./BigComponents/LeftControls";
import RightControls from "./BigComponents/RightControls";
import CenterMessageBox from "./CenterMessageBox";
@ -19,7 +17,6 @@ import ScrollableFullScreen from "./Base/ScrollableFullScreen";
import Translations from "./i18n/Translations";
import SimpleAddUI from "./BigComponents/SimpleAddUI";
import StrayClickHandler from "../Logic/Actors/StrayClickHandler";
import Lazy from "./Base/Lazy";
import {DefaultGuiState} from "./DefaultGuiState";
import LayerConfig from "../Models/ThemeConfig/LayerConfig";
import * as home_location_json from "../assets/layers/home_location/home_location.json";
@ -27,6 +24,7 @@ import NewNoteUi from "./Popup/NewNoteUi";
import Combine from "./Base/Combine";
import AddNewMarker from "./BigComponents/AddNewMarker";
import FilteredLayer from "../Models/FilteredLayer";
import ExtraLinkButton from "./BigComponents/ExtraLinkButton";
/**
@ -161,31 +159,26 @@ export default class DefaultGUI {
const guiState = this._guiState;
const self = this
Toggle.If(state.featureSwitchUserbadge,
() => new UserBadge(state)
).AttachTo("userbadge")
new Combine([
Toggle.If(state.featureSwitchUserbadge,
() => new UserBadge(state)
),
Toggle.If(state.featureSwitchExtraLinkEnabled,
() => new ExtraLinkButton(state, state.layoutToUse.extraLink)
)
]).SetClass("flex flex-col")
.AttachTo("userbadge")
Toggle.If(state.featureSwitchSearch,
() => new SearchAndGo(state))
.AttachTo("searchbox");
let iframePopout: () => BaseUIElement = undefined;
if (window !== window.top) {
// MapComplete is running in an iframe
iframePopout = () => new VariableUiElement(state.locationControl.map(loc => {
const url = `${window.location.origin}${window.location.pathname}?z=${loc.zoom ?? 0}&lat=${loc.lat ?? 0}&lon=${loc.lon ?? 0}`;
const link = new Link(Svg.pop_out_img, url, true).SetClass("block w-full h-full p-1.5")
return new MapControlButton(link)
}))
}
new Toggle(new Lazy(() => self.InitWelcomeMessage()),
Toggle.If(state.featureSwitchIframePopoutEnabled, iframePopout),
state.featureSwitchWelcomeMessage
).AttachTo("messagesbox");
Toggle.If(
state.featureSwitchWelcomeMessage,
() => self.InitWelcomeMessage()
)
.AttachTo("messagesbox");
new LeftControls(state, guiState).AttachTo("bottom-left");

View file

@ -22,27 +22,27 @@ export class DefaultGuiState {
));
this.welcomeMessageIsOpened = QueryParameters.GetBooleanQueryParameter(
"welcome-control-toggle",
"false",
false,
"Whether or not the welcome panel is shown"
)
this.downloadControlIsOpened = QueryParameters.GetBooleanQueryParameter(
"download-control-toggle",
"false",
false,
"Whether or not the download panel is shown"
)
this.filterViewIsOpened = QueryParameters.GetBooleanQueryParameter(
"filter-toggle",
"false",
false,
"Whether or not the filter view is shown"
)
this.copyrightViewIsOpened = QueryParameters.GetBooleanQueryParameter(
"copyright-toggle",
"false",
false,
"Whether or not the copyright view is shown"
)
this.currentViewControlIsOpened = QueryParameters.GetBooleanQueryParameter(
"currentview-toggle",
"false",
false,
"Whether or not the current view box is shown"
)
const states = {