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")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue