forked from MapComplete/MapComplete
Feature(create_copy): add layer filter lock
This commit is contained in:
parent
6a200e04bc
commit
d78207c98a
3 changed files with 48 additions and 2 deletions
|
@ -24,7 +24,9 @@ export default class FilteredLayer {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if some filter is set.
|
* Indicates if some filter is set.
|
||||||
* If this is the case, adding a new element of this type might be a bad idea
|
* If this is the case, adding a new element of this type might be a bad idea.
|
||||||
|
*
|
||||||
|
* Does not include the global filters
|
||||||
*/
|
*/
|
||||||
readonly hasFilter: Store<boolean>
|
readonly hasFilter: Store<boolean>
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,12 @@ export class MenuState {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.pageStates.filter.addCallback(opened => {
|
||||||
|
if(!opened){
|
||||||
|
this.highlightedLayerInFilters.set(undefined)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public openMenuIfNeeded(shouldShowWelcomeMessage: boolean, themeid: string) {
|
public openMenuIfNeeded(shouldShowWelcomeMessage: boolean, themeid: string) {
|
||||||
|
|
|
@ -22,6 +22,9 @@
|
||||||
import Loading from "../../Base/Loading.svelte"
|
import Loading from "../../Base/Loading.svelte"
|
||||||
import CreateNewNodeAction from "../../../Logic/Osm/Actions/CreateNewNodeAction"
|
import CreateNewNodeAction from "../../../Logic/Osm/Actions/CreateNewNodeAction"
|
||||||
import DocumentDuplicate from "@babeard/svelte-heroicons/solid/DocumentDuplicate"
|
import DocumentDuplicate from "@babeard/svelte-heroicons/solid/DocumentDuplicate"
|
||||||
|
import type { GlobalFilter } from "../../../Models/GlobalFilter"
|
||||||
|
import { EyeOffIcon } from "@rgossiaux/svelte-heroicons/solid"
|
||||||
|
import Layers from "../../../assets/svg/Layers.svelte"
|
||||||
|
|
||||||
export let state: ThemeViewState
|
export let state: ThemeViewState
|
||||||
export let layer: LayerConfig
|
export let layer: LayerConfig
|
||||||
|
@ -46,6 +49,8 @@
|
||||||
let creatingCopy = new UIEventSource(false)
|
let creatingCopy = new UIEventSource(false)
|
||||||
|
|
||||||
const t = Translations.t.copy
|
const t = Translations.t.copy
|
||||||
|
let globalFilter: UIEventSource<GlobalFilter[]> = state.layerState.globalFilters
|
||||||
|
let hasFilter = state.layerState.filteredLayers.get(layer.id).hasFilter
|
||||||
|
|
||||||
async function createCopy() {
|
async function createCopy() {
|
||||||
creatingCopy.set(true)
|
creatingCopy.set(true)
|
||||||
|
@ -84,12 +89,45 @@
|
||||||
state.mapProperties.location.setData(location)
|
state.mapProperties.location.setData(location)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function abort(){
|
||||||
|
showPopup.set(false)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Popup shown={showPopup} fullscreen>
|
<Popup shown={showPopup} fullscreen>
|
||||||
<Tr slot="header" t={t.title} />
|
<Tr slot="header" t={t.title} />
|
||||||
|
|
||||||
{#if $creatingCopy}
|
{#if $globalFilter?.length >0 }
|
||||||
|
{#if $hasFilter}
|
||||||
|
<!-- Some filters are enabled. The feature to add might already be mapped, but hidden -->
|
||||||
|
<div class="alert flex items-center justify-center">
|
||||||
|
<EyeOffIcon class="w-8" />
|
||||||
|
<Tr t={Translations.t.general.add.disableFiltersExplanation} />
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-wrap-reverse md:flex-nowrap">
|
||||||
|
<button
|
||||||
|
class="primary flex w-full gap-x-1"
|
||||||
|
on:click={() => {
|
||||||
|
abort()
|
||||||
|
state.layerState.filteredLayers.get(layer.id).disableAllFilters()
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<EyeOffIcon class="w-12" />
|
||||||
|
<Tr t={Translations.t.general.add.disableFilters} />
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
class="flex w-full gap-x-1"
|
||||||
|
on:click={() => {
|
||||||
|
abort()
|
||||||
|
state.guistate.openFilterView(layer)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Layers class="w-12" />
|
||||||
|
<Tr t={Translations.t.general.add.openLayerControl} />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
{:else if $creatingCopy}
|
||||||
<div class="h-full flex flex-col justify-center">
|
<div class="h-full flex flex-col justify-center">
|
||||||
<div class="h-fit flex justify-center">
|
<div class="h-fit flex justify-center">
|
||||||
<Loading>
|
<Loading>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue