forked from MapComplete/MapComplete
Move extra actions into themeExplanationpanel, switch userinfo and help buttons, remove obsolete scrollableTriggers
This commit is contained in:
parent
8c35bfd67b
commit
3709dc323f
4 changed files with 105 additions and 87 deletions
|
|
@ -55,6 +55,7 @@ export default class DefaultGUI {
|
|||
public setup() {
|
||||
this.SetupUIElements()
|
||||
this.SetupMap()
|
||||
ScrollableFullScreen.ActivateCurrent()
|
||||
|
||||
if (
|
||||
this.state.layoutToUse.customCss !== undefined &&
|
||||
|
|
@ -202,41 +203,43 @@ export default class DefaultGUI {
|
|||
const guiState = this.guiState
|
||||
|
||||
const self = this
|
||||
new Combine([
|
||||
Toggle.If(state.featureSwitchUserbadge, () => {
|
||||
const userInfo = new UserInformationPanel(state, {
|
||||
isOpened: guiState.userInfoIsOpened,
|
||||
})
|
||||
|
||||
const mapControl = new MapControlButton(
|
||||
new VariableUiElement(
|
||||
state.osmConnection.userDetails.map((ud) => {
|
||||
if (ud?.img === undefined) {
|
||||
return Svg.person_ui().SetClass("mt-1 block")
|
||||
}
|
||||
return new Img(ud?.img)
|
||||
})
|
||||
).SetClass("block rounded-full overflow-hidden"),
|
||||
{
|
||||
dontStyle: true,
|
||||
}
|
||||
).onClick(() => guiState.userInfoIsOpened.setData(true))
|
||||
const userInfoMapControl = Toggle.If(state.featureSwitchUserbadge, () => {
|
||||
console.log("Guistate is", guiState)
|
||||
new UserInformationPanel(state, {
|
||||
isOpened: guiState.userInfoIsOpened,
|
||||
})
|
||||
|
||||
return new LoginToggle(
|
||||
mapControl,
|
||||
Translations.t.general.loginWithOpenStreetMap,
|
||||
state
|
||||
)
|
||||
}),
|
||||
Toggle.If(
|
||||
state.featureSwitchExtraLinkEnabled,
|
||||
() => new ExtraLinkButton(state, state.layoutToUse.extraLink)
|
||||
),
|
||||
Toggle.If(state.featureSwitchWelcomeMessage, () => self.InitWelcomeMessage()),
|
||||
Toggle.If(state.featureSwitchIsTesting, () =>
|
||||
new FixedUiElement("TESTING").SetClass("alert m-2 border-2 border-black")
|
||||
),
|
||||
])
|
||||
const mapControl = new MapControlButton(
|
||||
new VariableUiElement(
|
||||
state.osmConnection.userDetails.map((ud) => {
|
||||
if (ud?.img === undefined) {
|
||||
return Svg.person_ui().SetClass("mt-1 block")
|
||||
}
|
||||
return new Img(ud?.img)
|
||||
})
|
||||
).SetClass("block rounded-full overflow-hidden"),
|
||||
{
|
||||
dontStyle: true,
|
||||
}
|
||||
).onClick(() => {
|
||||
self.guiState.userInfoIsOpened.setData(true)
|
||||
})
|
||||
|
||||
return new LoginToggle(mapControl, Translations.t.general.loginWithOpenStreetMap, state)
|
||||
})
|
||||
const extraLink = Toggle.If(
|
||||
state.featureSwitchExtraLinkEnabled,
|
||||
() => new ExtraLinkButton(state, state.layoutToUse.extraLink)
|
||||
)
|
||||
|
||||
const welcomeMessageMapControl = Toggle.If(state.featureSwitchWelcomeMessage, () =>
|
||||
self.InitWelcomeMessage()
|
||||
)
|
||||
const testingBadge = Toggle.If(state.featureSwitchIsTesting, () =>
|
||||
new FixedUiElement("TESTING").SetClass("alert m-2 border-2 border-black")
|
||||
)
|
||||
new Combine([welcomeMessageMapControl, userInfoMapControl, extraLink, testingBadge])
|
||||
.SetClass("flex flex-col")
|
||||
.AttachTo("top-left")
|
||||
|
||||
|
|
@ -274,21 +277,6 @@ export default class DefaultGUI {
|
|||
|
||||
new CenterMessageBox(state).AttachTo("centermessage")
|
||||
document?.getElementById("centermessage")?.classList?.add("pointer-events-none")
|
||||
|
||||
// We have to ping the welcomeMessageIsOpened and other isOpened-stuff to activate the FullScreenMessage if needed
|
||||
for (const state of guiState.allFullScreenStates) {
|
||||
if (state.data) {
|
||||
state.ping()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* At last, if the map moves or an element is selected, we close all the panels just as well
|
||||
*/
|
||||
|
||||
state.selectedElement.addCallbackAndRunD((_) => {
|
||||
guiState.allFullScreenStates.forEach((s) => s.setData(false))
|
||||
})
|
||||
}
|
||||
|
||||
private InitWelcomeMessage(): BaseUIElement {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue