forked from MapComplete/MapComplete
Add current view popup
This commit is contained in:
commit
c76b0a6340
9 changed files with 116 additions and 45 deletions
|
@ -15,10 +15,17 @@ import FilteredLayer from "../../Models/FilteredLayer";
|
|||
import BaseLayer from "../../Models/BaseLayer";
|
||||
import {OsmConnection} from "../../Logic/Osm/OsmConnection";
|
||||
import BackgroundMapSwitch from "./BackgroundMapSwitch";
|
||||
import {FeatureSourceForLayer} from "../../Logic/FeatureSource/FeatureSource";
|
||||
import Lazy from "../Base/Lazy";
|
||||
import {VariableUiElement} from "../Base/VariableUIElement";
|
||||
import FeatureInfoBox from "../Popup/FeatureInfoBox";
|
||||
import {ElementStorage} from "../../Logic/ElementStorage";
|
||||
|
||||
export default class LeftControls extends Combine {
|
||||
|
||||
constructor(state: {
|
||||
allElements: ElementStorage;
|
||||
currentView: FeatureSourceForLayer;
|
||||
featureSwitchBackgroundSelection: UIEventSource<boolean>;
|
||||
layoutToUse: LayoutConfig,
|
||||
featurePipeline: FeaturePipeline,
|
||||
|
@ -33,12 +40,56 @@ export default class LeftControls extends Combine {
|
|||
osmConnection: OsmConnection
|
||||
},
|
||||
guiState: {
|
||||
currentViewControlIsOpened: UIEventSource<boolean>;
|
||||
downloadControlIsOpened: UIEventSource<boolean>,
|
||||
filterViewIsOpened: UIEventSource<boolean>,
|
||||
copyrightViewIsOpened: UIEventSource<boolean>
|
||||
}) {
|
||||
|
||||
|
||||
const currentViewFL = state.currentView?.layer
|
||||
const currentViewAction = new Toggle(
|
||||
new Lazy(() => {
|
||||
const feature : UIEventSource<any> = state.currentView.features.map(ffs => ffs[0]?.feature)
|
||||
const icon = new VariableUiElement(feature.map(feature => {
|
||||
const defaultIcon = Svg.checkbox_empty_svg()
|
||||
if (feature === undefined) {
|
||||
return defaultIcon;
|
||||
}
|
||||
const tags = {...feature.properties, button: "yes"}
|
||||
const elem = currentViewFL.layerDef.mapRendering[0]?.GenerateLeafletStyle(tags, false, {
|
||||
noSize: true
|
||||
})?.html
|
||||
if(elem === undefined){
|
||||
return defaultIcon
|
||||
}
|
||||
return elem
|
||||
}))
|
||||
|
||||
const featureBox = new VariableUiElement(feature.map(feature => {
|
||||
if(feature === undefined){return undefined}
|
||||
return new Lazy(() => {
|
||||
const tagsSource= state.allElements.getEventSourceById(feature.properties.id)
|
||||
return new FeatureInfoBox(tagsSource, currentViewFL.layerDef, "currentview", guiState.currentViewControlIsOpened)
|
||||
})
|
||||
}))
|
||||
|
||||
|
||||
return new Toggle(
|
||||
featureBox,
|
||||
new MapControlButton(icon),
|
||||
guiState.currentViewControlIsOpened
|
||||
)
|
||||
|
||||
}).SetClass("inline-block w-full").onClick(() => {
|
||||
guiState.currentViewControlIsOpened.setData(true)
|
||||
}),
|
||||
|
||||
|
||||
undefined,
|
||||
new UIEventSource<boolean>(currentViewFL !== undefined && currentViewFL?.layerDef?.tagRenderings !== null)
|
||||
)
|
||||
|
||||
const toggledDownload = new Toggle(
|
||||
new AllDownloads(
|
||||
guiState.downloadControlIsOpened
|
||||
|
@ -75,16 +126,18 @@ export default class LeftControls extends Combine {
|
|||
undefined,
|
||||
state.featureSwitchFilter
|
||||
);
|
||||
|
||||
|
||||
const mapSwitch = new Toggle(
|
||||
new BackgroundMapSwitch(state, state.backgroundLayer),
|
||||
undefined,
|
||||
state.featureSwitchBackgroundSelection
|
||||
)
|
||||
|
||||
super([filterButton,
|
||||
super([
|
||||
currentViewAction,
|
||||
filterButton,
|
||||
downloadButtonn,
|
||||
mapSwitch
|
||||
mapSwitch
|
||||
])
|
||||
|
||||
this.SetClass("flex flex-col")
|
||||
|
|
|
@ -9,6 +9,7 @@ export class DefaultGuiState {
|
|||
public readonly downloadControlIsOpened: UIEventSource<boolean>;
|
||||
public readonly filterViewIsOpened: UIEventSource<boolean>;
|
||||
public readonly copyrightViewIsOpened: UIEventSource<boolean>;
|
||||
public readonly currentViewControlIsOpened: UIEventSource<boolean>;
|
||||
public readonly welcomeMessageOpenedTab: UIEventSource<number>
|
||||
public readonly allFullScreenStates: UIEventSource<boolean>[] = []
|
||||
|
||||
|
@ -40,6 +41,11 @@ export class DefaultGuiState {
|
|||
"false",
|
||||
"Whether or not the copyright view is shown"
|
||||
)
|
||||
this.currentViewControlIsOpened = QueryParameters.GetBooleanQueryParameter(
|
||||
"currentview-toggle",
|
||||
"false",
|
||||
"Whether or not the current view box is shown"
|
||||
)
|
||||
if (Hash.hash.data === "download") {
|
||||
this.downloadControlIsOpened.setData(true)
|
||||
}
|
||||
|
@ -48,12 +54,14 @@ export class DefaultGuiState {
|
|||
}
|
||||
if (Hash.hash.data === "copyright") {
|
||||
this.copyrightViewIsOpened.setData(true)
|
||||
}if (Hash.hash.data === "currentview") {
|
||||
this.currentViewControlIsOpened.setData(true)
|
||||
}
|
||||
if (Hash.hash.data === "" || Hash.hash.data === undefined || Hash.hash.data === "welcome") {
|
||||
this.welcomeMessageIsOpened.setData(true)
|
||||
}
|
||||
|
||||
this.allFullScreenStates.push(this.downloadControlIsOpened, this.filterViewIsOpened, this.copyrightViewIsOpened, this.welcomeMessageIsOpened)
|
||||
this.allFullScreenStates.push(this.downloadControlIsOpened, this.filterViewIsOpened, this.copyrightViewIsOpened, this.welcomeMessageIsOpened, this.currentViewControlIsOpened)
|
||||
|
||||
for (let i = 0; i < this.allFullScreenStates.length; i++) {
|
||||
const fullScreenState = this.allFullScreenStates[i];
|
||||
|
|
|
@ -25,10 +25,13 @@ export default class FeatureInfoBox extends ScrollableFullScreen {
|
|||
public constructor(
|
||||
tags: UIEventSource<any>,
|
||||
layerConfig: LayerConfig,
|
||||
hashToShow?: string,
|
||||
isShown?: UIEventSource<boolean>
|
||||
) {
|
||||
super(() => FeatureInfoBox.GenerateTitleBar(tags, layerConfig),
|
||||
() => FeatureInfoBox.GenerateContent(tags, layerConfig),
|
||||
tags.data.id);
|
||||
hashToShow ?? tags.data.id,
|
||||
isShown);
|
||||
|
||||
if (layerConfig === undefined) {
|
||||
throw "Undefined layerconfig";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue