2021-07-27 17:00:05 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import { VariableUiElement } from "../Base/VariableUIElement"
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-28 05:13:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import Toggle from "../Input/Toggle"
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-20 15:14:51 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import Combine from "../Base/Combine"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import Translations from "../i18n/Translations"
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-27 17:00:05 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import { Translation } from "../i18n/Translation"
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-20 16:29:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import Svg from "../../Svg"
							 | 
						
					
						
							
								
									
										
										
										
											2022-06-05 02:24:14 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import { ImmutableStore, Store, UIEventSource } from "../../Logic/UIEventSource"
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-28 05:13:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import FilteredLayer from "../../Models/FilteredLayer"
							 | 
						
					
						
							
								
									
										
										
										
											2021-10-14 21:43:14 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import TilesourceConfig from "../../Models/ThemeConfig/TilesourceConfig"
							 | 
						
					
						
							
								
									
										
										
										
											2022-08-20 12:46:33 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import Loc from "../../Models/Loc"
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-27 19:39:57 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-26 12:26:41 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								export default class FilterView extends VariableUiElement {
							 | 
						
					
						
							
								
									
										
										
										
											2022-08-20 12:46:33 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    constructor(
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        filteredLayer: Store<FilteredLayer[]>,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        tileLayers: { config: TilesourceConfig; isDisplayed: UIEventSource<boolean> }[],
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        state: {
							 | 
						
					
						
							
								
									
										
										
										
											2023-01-11 05:01:48 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            readonly availableBackgroundLayers?: Store<BaseLayer[]>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            readonly featureSwitchBackgroundSelection?: UIEventSource<boolean>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            readonly featureSwitchIsDebugging?: UIEventSource<boolean>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            readonly locationControl?: UIEventSource<Loc>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            readonly featureSwitchMoreQuests: Store<boolean>
							 | 
						
					
						
							
								
									
										
										
										
											2022-08-20 12:46:33 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-27 17:00:05 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        super(
							 | 
						
					
						
							
								
									
										
										
										
											2021-10-14 21:43:14 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            filteredLayer.map((filteredLayers) => {
							 | 
						
					
						
							
								
									
										
										
										
											2022-01-27 01:23:04 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                // Create the views which toggle layers (and filters them) ...
							 | 
						
					
						
							
								
									
										
										
										
											2022-02-02 01:51:19 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                let elements = filteredLayers
							 | 
						
					
						
							
								
									
										
										
										
											2022-08-20 12:46:33 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                    ?.map((l) =>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                        FilterView.createOneFilteredLayerElement(l, state)?.SetClass("filter-panel")
							 | 
						
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                    )
							 | 
						
					
						
							
								
									
										
										
										
											2022-02-02 01:51:19 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                    ?.filter((l) => l !== undefined)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                elements[0].SetClass("first-filter-panel")
							 | 
						
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-01-27 01:23:04 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                // ... create views for non-interactive layers ...
							 | 
						
					
						
							
								
									
										
										
										
											2022-08-20 12:46:33 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                elements = elements.concat(
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                    tileLayers.map((tl) => FilterView.createOverlayToggle(state, tl))
							 | 
						
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                )
							 | 
						
					
						
							
								
									
										
										
										
											2023-01-11 05:01:48 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                return elements
							 | 
						
					
						
							
								
									
										
										
										
											2021-10-14 21:43:14 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        )
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-08-20 12:46:33 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    private static createOverlayToggle(
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        state: { locationControl?: UIEventSource<Loc> },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        config: { config: TilesourceConfig; isDisplayed: UIEventSource<boolean> }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-10-14 21:43:14 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const iconStyle = "width:1.5rem;height:1.5rem;margin-left:1.25rem;flex-shrink: 0;"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        const icon = new Combine([Svg.checkbox_filled]).SetStyle(iconStyle)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        const iconUnselected = new Combine([Svg.checkbox_empty]).SetStyle(iconStyle)
							 | 
						
					
						
							
								
									
										
										
										
											2021-10-25 21:50:38 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const name: Translation = config.config.name
							 | 
						
					
						
							
								
									
										
										
										
											2021-10-14 21:43:14 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-10-30 02:34:16 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const styledNameChecked = name.Clone().SetStyle("font-size:large").SetClass("ml-2")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        const styledNameUnChecked = name.Clone().SetStyle("font-size:large").SetClass("ml-2")
							 | 
						
					
						
							
								
									
										
										
										
											2021-10-14 21:43:14 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        const style = "display:flex;align-items:center;padding:0.5rem 0;"
							 | 
						
					
						
							
								
									
										
										
										
											2023-04-06 01:33:08 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const layerChecked = new Combine([icon, styledNameChecked])
							 | 
						
					
						
							
								
									
										
										
										
											2021-10-14 21:43:14 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            .SetStyle(style)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            .onClick(() => config.isDisplayed.setData(false))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        const layerNotChecked = new Combine([iconUnselected, styledNameUnChecked])
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            .SetStyle(style)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            .onClick(() => config.isDisplayed.setData(true))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        return new Toggle(layerChecked, layerNotChecked, config.isDisplayed)
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-26 12:26:41 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-20 15:14:51 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 |