Studio: some fixes, show user id when running localhost
This commit is contained in:
parent
26214ed2a3
commit
09ea799ad4
2 changed files with 45 additions and 22 deletions
|
@ -1,29 +1,30 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { UIEventSource } from "../../Logic/UIEventSource"
|
import { UIEventSource } from "../../Logic/UIEventSource"
|
||||||
import { OsmConnection } from "../../Logic/Osm/OsmConnection"
|
import { OsmConnection } from "../../Logic/Osm/OsmConnection"
|
||||||
import Marker from "../Map/Marker.svelte"
|
import Marker from "../Map/Marker.svelte"
|
||||||
import NextButton from "../Base/NextButton.svelte"
|
import NextButton from "../Base/NextButton.svelte"
|
||||||
import { AllKnownLayouts } from "../../Customizations/AllKnownLayouts"
|
import { AllKnownLayouts } from "../../Customizations/AllKnownLayouts"
|
||||||
import { AllSharedLayers } from "../../Customizations/AllSharedLayers"
|
import { AllSharedLayers } from "../../Customizations/AllSharedLayers"
|
||||||
import { createEventDispatcher } from "svelte"
|
import { createEventDispatcher } from "svelte"
|
||||||
|
|
||||||
export let info: { id: string; owner: number }
|
export let info: { id: string; owner: number }
|
||||||
export let category: "layers" | "themes"
|
export let category: "layers" | "themes"
|
||||||
export let osmConnection: OsmConnection
|
export let osmConnection: OsmConnection
|
||||||
|
|
||||||
let displayName = UIEventSource.FromPromise(
|
let displayName = UIEventSource.FromPromise(
|
||||||
osmConnection.getInformationAboutUser(info.owner)
|
osmConnection.getInformationAboutUser(info.owner),
|
||||||
).mapD((response) => response.display_name)
|
).mapD((response) => response.display_name)
|
||||||
|
|
||||||
let selfId = osmConnection.userDetails.mapD((ud) => ud.uid)
|
let selfId = osmConnection.userDetails.mapD((ud) => ud.uid)
|
||||||
function fetchIconDescription(layerId): any {
|
|
||||||
if (category === "themes") {
|
function fetchIconDescription(layerId): any {
|
||||||
return AllKnownLayouts.allKnownLayouts.get(layerId).icon
|
if (category === "themes") {
|
||||||
|
return AllKnownLayouts.allKnownLayouts.get(layerId).icon
|
||||||
|
}
|
||||||
|
return AllSharedLayers.getSharedLayersConfigs().get(layerId)?._layerIcon
|
||||||
}
|
}
|
||||||
return AllSharedLayers.getSharedLayersConfigs().get(layerId)?._layerIcon
|
|
||||||
}
|
|
||||||
|
|
||||||
const dispatch = createEventDispatcher<{ layerSelected: string }>()
|
const dispatch = createEventDispatcher<{ layerSelected: string }>()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<NextButton clss="small" on:click={() => dispatch("layerSelected", info)}>
|
<NextButton clss="small" on:click={() => dispatch("layerSelected", info)}>
|
||||||
|
@ -32,6 +33,14 @@
|
||||||
</div>
|
</div>
|
||||||
<b class="px-1">{info.id}</b>
|
<b class="px-1">{info.id}</b>
|
||||||
{#if info.owner && info.owner !== $selfId}
|
{#if info.owner && info.owner !== $selfId}
|
||||||
(made by {$displayName ?? info.owner})
|
{#if $displayName}
|
||||||
|
(made by {$displayName}
|
||||||
|
{#if window.location.host.startsWith("127.0.0.1")}
|
||||||
|
- {info.owner}
|
||||||
|
{/if}
|
||||||
|
)
|
||||||
|
{:else }
|
||||||
|
({info.owner})
|
||||||
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
</NextButton>
|
</NextButton>
|
||||||
|
|
|
@ -299,6 +299,9 @@ export default class EditLayerState extends EditJsonState<LayerConfigJson> {
|
||||||
|
|
||||||
|
|
||||||
function cleanArray(data: object, key: string): boolean{
|
function cleanArray(data: object, key: string): boolean{
|
||||||
|
if(!data){
|
||||||
|
return false
|
||||||
|
}
|
||||||
if (data[key]) {
|
if (data[key]) {
|
||||||
// A bit of cleanup
|
// A bit of cleanup
|
||||||
const lBefore = data[key].length
|
const lBefore = data[key].length
|
||||||
|
@ -312,7 +315,18 @@ export default class EditLayerState extends EditJsonState<LayerConfigJson> {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.configuration.addCallbackAndRunD((layer) => {
|
this.configuration.addCallbackAndRunD((layer) => {
|
||||||
const changed = cleanArray(layer, "tagRenderings") || cleanArray(layer, "pointRenderings")
|
let changed = cleanArray(layer, "tagRenderings") || cleanArray(layer, "pointRenderings")
|
||||||
|
for (const tr of layer.tagRenderings ?? []) {
|
||||||
|
if(typeof tr === "string"){
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
const qtr = (<QuestionableTagRenderingConfigJson> tr)
|
||||||
|
if(qtr.freeform && Object.keys(qtr.freeform ).length === 0){
|
||||||
|
delete qtr.freeform
|
||||||
|
changed = true
|
||||||
|
}
|
||||||
|
}
|
||||||
if(changed){
|
if(changed){
|
||||||
this.configuration.ping()
|
this.configuration.ping()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue