2021-07-28 16:48:59 +02:00
|
|
|
import Combine from "../Base/Combine";
|
|
|
|
import ScrollableFullScreen from "../Base/ScrollableFullScreen";
|
|
|
|
import Translations from "../i18n/Translations";
|
|
|
|
import Toggle from "../Input/Toggle";
|
|
|
|
import MapControlButton from "../MapControlButton";
|
|
|
|
import Svg from "../../Svg";
|
|
|
|
import AllDownloads from "./AllDownloads";
|
|
|
|
import FilterView from "./FilterView";
|
2021-09-21 02:10:42 +02:00
|
|
|
import {UIEventSource} from "../../Logic/UIEventSource";
|
|
|
|
import FeaturePipeline from "../../Logic/FeatureSource/FeaturePipeline";
|
|
|
|
import Loc from "../../Models/Loc";
|
2021-09-28 17:30:48 +02:00
|
|
|
import {BBox} from "../../Logic/BBox";
|
2021-10-15 05:20:02 +02:00
|
|
|
import LayoutConfig from "../../Models/ThemeConfig/LayoutConfig";
|
|
|
|
import FilteredLayer from "../../Models/FilteredLayer";
|
2021-11-03 00:44:53 +01:00
|
|
|
import BaseLayer from "../../Models/BaseLayer";
|
|
|
|
import {OsmConnection} from "../../Logic/Osm/OsmConnection";
|
2021-11-21 02:44:35 +01:00
|
|
|
import BackgroundMapSwitch from "./BackgroundMapSwitch";
|
2021-07-28 16:48:59 +02:00
|
|
|
|
|
|
|
export default class LeftControls extends Combine {
|
|
|
|
|
2021-10-15 05:20:02 +02:00
|
|
|
constructor(state: {
|
2021-12-04 12:20:24 +01:00
|
|
|
featureSwitchBackgroundSelection: UIEventSource<boolean>;
|
2021-10-15 05:20:02 +02:00
|
|
|
layoutToUse: LayoutConfig,
|
|
|
|
featurePipeline: FeaturePipeline,
|
|
|
|
currentBounds: UIEventSource<BBox>,
|
|
|
|
locationControl: UIEventSource<Loc>,
|
|
|
|
overlayToggles: any,
|
|
|
|
featureSwitchEnableExport: UIEventSource<boolean>,
|
|
|
|
featureSwitchExportAsPdf: UIEventSource<boolean>,
|
|
|
|
filteredLayers: UIEventSource<FilteredLayer[]>,
|
2021-11-03 00:44:53 +01:00
|
|
|
featureSwitchFilter: UIEventSource<boolean>,
|
|
|
|
backgroundLayer: UIEventSource<BaseLayer>,
|
|
|
|
osmConnection: OsmConnection
|
2021-10-15 05:20:02 +02:00
|
|
|
},
|
|
|
|
guiState: {
|
|
|
|
downloadControlIsOpened: UIEventSource<boolean>,
|
|
|
|
filterViewIsOpened: UIEventSource<boolean>,
|
2021-10-23 02:46:37 +02:00
|
|
|
copyrightViewIsOpened: UIEventSource<boolean>
|
2021-10-15 05:20:02 +02:00
|
|
|
}) {
|
2021-07-28 16:48:59 +02:00
|
|
|
|
|
|
|
|
|
|
|
const toggledDownload = new Toggle(
|
|
|
|
new AllDownloads(
|
2021-10-15 05:20:02 +02:00
|
|
|
guiState.downloadControlIsOpened
|
2021-07-28 16:48:59 +02:00
|
|
|
).SetClass("block p-1 rounded-full"),
|
2021-07-28 18:20:59 +02:00
|
|
|
new MapControlButton(Svg.download_svg())
|
2021-10-15 05:20:02 +02:00
|
|
|
.onClick(() => guiState.downloadControlIsOpened.setData(true)),
|
|
|
|
guiState.downloadControlIsOpened
|
2021-07-28 18:20:59 +02:00
|
|
|
)
|
2021-07-28 16:48:59 +02:00
|
|
|
|
|
|
|
const downloadButtonn = new Toggle(
|
|
|
|
toggledDownload,
|
|
|
|
undefined,
|
2021-10-15 05:20:02 +02:00
|
|
|
state.featureSwitchEnableExport.map(downloadEnabled => downloadEnabled || state.featureSwitchExportAsPdf.data,
|
|
|
|
[state.featureSwitchExportAsPdf])
|
2021-07-28 16:48:59 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
const toggledFilter = new Toggle(
|
|
|
|
new ScrollableFullScreen(
|
|
|
|
() => Translations.t.general.layerSelection.title.Clone(),
|
|
|
|
() =>
|
2021-10-15 05:20:02 +02:00
|
|
|
new FilterView(state.filteredLayers, state.overlayToggles).SetClass(
|
2021-10-23 02:46:37 +02:00
|
|
|
"block p-1"
|
2021-07-28 16:48:59 +02:00
|
|
|
),
|
2021-10-25 20:50:59 +02:00
|
|
|
"filters",
|
2021-10-15 05:20:02 +02:00
|
|
|
guiState.filterViewIsOpened
|
2021-10-23 02:46:37 +02:00
|
|
|
).SetClass("rounded-lg"),
|
2021-07-28 18:20:59 +02:00
|
|
|
new MapControlButton(Svg.filter_svg())
|
2021-10-15 05:20:02 +02:00
|
|
|
.onClick(() => guiState.filterViewIsOpened.setData(true)),
|
|
|
|
guiState.filterViewIsOpened
|
2021-07-28 18:20:59 +02:00
|
|
|
)
|
2021-07-28 16:48:59 +02:00
|
|
|
|
|
|
|
const filterButton = new Toggle(
|
|
|
|
toggledFilter,
|
|
|
|
undefined,
|
2021-10-15 05:20:02 +02:00
|
|
|
state.featureSwitchFilter
|
2021-07-28 16:48:59 +02:00
|
|
|
);
|
2021-12-04 12:20:24 +01:00
|
|
|
|
|
|
|
const mapSwitch = new Toggle(
|
|
|
|
new BackgroundMapSwitch(state, state.backgroundLayer),
|
|
|
|
undefined,
|
|
|
|
state.featureSwitchBackgroundSelection
|
|
|
|
)
|
2021-07-28 16:48:59 +02:00
|
|
|
|
|
|
|
super([filterButton,
|
|
|
|
downloadButtonn,
|
2021-12-04 12:20:24 +01:00
|
|
|
mapSwitch
|
2021-11-21 02:44:35 +01:00
|
|
|
])
|
2021-09-09 00:05:51 +02:00
|
|
|
|
2021-07-28 16:48:59 +02:00
|
|
|
this.SetClass("flex flex-col")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|