forked from MapComplete/MapComplete
		
	Fix: better error handling and handling of changes
This commit is contained in:
		
							parent
							
								
									7b73578f88
								
							
						
					
					
						commit
						7813653265
					
				
					 8 changed files with 36 additions and 10 deletions
				
			
		| 
						 | 
					@ -164,7 +164,11 @@ export default class MetaTagging {
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (somethingChanged) {
 | 
					            if (somethingChanged) {
 | 
				
			||||||
                featurePropertiesStores?.getStore(feature.properties.id)?.ping()
 | 
					                try {
 | 
				
			||||||
 | 
					                    featurePropertiesStores?.getStore(feature.properties.id)?.ping()
 | 
				
			||||||
 | 
					                } catch (e) {
 | 
				
			||||||
 | 
					                    console.error("Could not ping a store for a changed property due to", e)
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
                atLeastOneFeatureChanged = true
 | 
					                atLeastOneFeatureChanged = true
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -15,7 +15,6 @@ import BaseUIElement from "../BaseUIElement"
 | 
				
			||||||
import Img from "../Base/Img"
 | 
					import Img from "../Base/Img"
 | 
				
			||||||
import Title from "../Base/Title"
 | 
					import Title from "../Base/Title"
 | 
				
			||||||
import { CheckBox } from "../Input/Checkboxes"
 | 
					import { CheckBox } from "../Input/Checkboxes"
 | 
				
			||||||
import Minimap from "../Base/Minimap"
 | 
					 | 
				
			||||||
import SearchAndGo from "./SearchAndGo"
 | 
					import SearchAndGo from "./SearchAndGo"
 | 
				
			||||||
import Toggle from "../Input/Toggle"
 | 
					import Toggle from "../Input/Toggle"
 | 
				
			||||||
import List from "../Base/List"
 | 
					import List from "../Base/List"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -72,6 +72,9 @@
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Stores.Chronic(50).addCallback(_ => stabilize());
 | 
					  Stores.Chronic(50).addCallback(_ => stabilize());
 | 
				
			||||||
 | 
					  floors.addCallback(floors => {
 | 
				
			||||||
 | 
					    forceIndex = floors.findIndex(s => s === value.data)
 | 
				
			||||||
 | 
					  })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  let image: HTMLImageElement;
 | 
					  let image: HTMLImageElement;
 | 
				
			||||||
  $:{
 | 
					  $:{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -50,7 +50,7 @@
 | 
				
			||||||
  let layerIsDisplayed: UIEventSource<boolean> | undefined = undefined;
 | 
					  let layerIsDisplayed: UIEventSource<boolean> | undefined = undefined;
 | 
				
			||||||
  let layerHasFilters: Store<boolean> | undefined = undefined;
 | 
					  let layerHasFilters: Store<boolean> | undefined = undefined;
 | 
				
			||||||
  let globalFilter: UIEventSource<GlobalFilter[]> = state.layerState.globalFilters;
 | 
					  let globalFilter: UIEventSource<GlobalFilter[]> = state.layerState.globalFilters;
 | 
				
			||||||
  let _globalFilter: GlobalFilter[];
 | 
					  let _globalFilter: GlobalFilter[] = [];
 | 
				
			||||||
  onDestroy(globalFilter.addCallbackAndRun(globalFilter => {
 | 
					  onDestroy(globalFilter.addCallbackAndRun(globalFilter => {
 | 
				
			||||||
    console.log("Global filters are", globalFilter);
 | 
					    console.log("Global filters are", globalFilter);
 | 
				
			||||||
    _globalFilter = globalFilter ?? [];
 | 
					    _globalFilter = globalFilter ?? [];
 | 
				
			||||||
| 
						 | 
					@ -85,7 +85,7 @@
 | 
				
			||||||
    creating = true;
 | 
					    creating = true;
 | 
				
			||||||
    const location: { lon: number; lat: number } = preciseCoordinate.data;
 | 
					    const location: { lon: number; lat: number } = preciseCoordinate.data;
 | 
				
			||||||
    const snapTo: WayId | undefined = <WayId>snappedToObject.data;
 | 
					    const snapTo: WayId | undefined = <WayId>snappedToObject.data;
 | 
				
			||||||
    const tags: Tag[] = selectedPreset.preset.tags.concat(..._globalFilter.map(f => f.onNewPoint.tags));
 | 
					    const tags: Tag[] = selectedPreset.preset.tags.concat(..._globalFilter.map(f => f?.onNewPoint?.tags ?? []));
 | 
				
			||||||
    console.log("Creating new point at", location, "snapped to", snapTo, "with tags", tags);
 | 
					    console.log("Creating new point at", location, "snapped to", snapTo, "with tags", tags);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let snapToWay: undefined | OsmWay = undefined;
 | 
					    let snapToWay: undefined | OsmWay = undefined;
 | 
				
			||||||
| 
						 | 
					@ -249,7 +249,7 @@
 | 
				
			||||||
        <Tr t={t.backToSelect} />
 | 
					        <Tr t={t.backToSelect} />
 | 
				
			||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
    </SubtleButton>
 | 
					    </SubtleButton>
 | 
				
			||||||
  {:else if _globalFilter.length > checkedOfGlobalFilters}
 | 
					  {:else if _globalFilter?.length > 0 && _globalFilter?.length > checkedOfGlobalFilters}
 | 
				
			||||||
      <Tr t={_globalFilter[checkedOfGlobalFilters].onNewPoint?.safetyCheck} />
 | 
					      <Tr t={_globalFilter[checkedOfGlobalFilters].onNewPoint?.safetyCheck} />
 | 
				
			||||||
      <SubtleButton on:click={() => {checkedOfGlobalFilters = checkedOfGlobalFilters + 1}}>
 | 
					      <SubtleButton on:click={() => {checkedOfGlobalFilters = checkedOfGlobalFilters + 1}}>
 | 
				
			||||||
        <img slot="image" src={_globalFilter[checkedOfGlobalFilters].onNewPoint?.icon ?? "./assets/svg/confirm.svg"} class="w-12 h-12">
 | 
					        <img slot="image" src={_globalFilter[checkedOfGlobalFilters].onNewPoint?.icon ?? "./assets/svg/confirm.svg"} class="w-12 h-12">
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -61,6 +61,7 @@ export default class TagApplyButton implements AutoAction, SpecialVisualization
 | 
				
			||||||
            if (kv.length == 2) {
 | 
					            if (kv.length == 2) {
 | 
				
			||||||
                tgsSpec.push(<[string, string]>kv)
 | 
					                tgsSpec.push(<[string, string]>kv)
 | 
				
			||||||
            } else if (kv.length < 2) {
 | 
					            } else if (kv.length < 2) {
 | 
				
			||||||
 | 
					                console.error("Invalid key spec: no '=' found in " + spec)
 | 
				
			||||||
                throw "Invalid key spec: no '=' found in " + spec
 | 
					                throw "Invalid key spec: no '=' found in " + spec
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                throw "Invalid key spec: multiple '=' found in " + spec
 | 
					                throw "Invalid key spec: multiple '=' found in " + spec
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,6 +11,7 @@
 | 
				
			||||||
  import LayerConfig from "../../../Models/ThemeConfig/LayerConfig";
 | 
					  import LayerConfig from "../../../Models/ThemeConfig/LayerConfig";
 | 
				
			||||||
  import WeblateLink from "../../Base/WeblateLink.svelte";
 | 
					  import WeblateLink from "../../Base/WeblateLink.svelte";
 | 
				
			||||||
  import FromHtml from "../../Base/FromHtml.svelte";
 | 
					  import FromHtml from "../../Base/FromHtml.svelte";
 | 
				
			||||||
 | 
					  import BaseUIElement from "../../BaseUIElement";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * The 'specialTranslation' renders a `Translation`-object, but interprets the special values as well
 | 
					   * The 'specialTranslation' renders a `Translation`-object, but interprets the special values as well
 | 
				
			||||||
| 
						 | 
					@ -27,10 +28,26 @@
 | 
				
			||||||
  }));
 | 
					  }));
 | 
				
			||||||
  let specs: RenderingSpecification[] = [];
 | 
					  let specs: RenderingSpecification[] = [];
 | 
				
			||||||
  $: {
 | 
					  $: {
 | 
				
			||||||
    if (txt !== undefined) {
 | 
					    try {
 | 
				
			||||||
      specs = SpecialVisualizations.constructSpecification(txt);
 | 
					
 | 
				
			||||||
 | 
					      if (txt !== undefined) {
 | 
				
			||||||
 | 
					        specs = SpecialVisualizations.constructSpecification(txt);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    } catch (e) {
 | 
				
			||||||
 | 
					      console.error("Could not construct a specification and with arguments", txt);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  function createVisualisation(specpart: Exclude<RenderingSpecification, string>): BaseUIElement {
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      try {
 | 
				
			||||||
 | 
					        return specpart.func.constr(state, tags, specpart.args, feature, layer);
 | 
				
			||||||
 | 
					      } catch (e) {
 | 
				
			||||||
 | 
					        console.error("Could not construct a special visualisation with specification", specpart, "and tags", tags);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
{#each specs as specpart}
 | 
					{#each specs as specpart}
 | 
				
			||||||
| 
						 | 
					@ -40,6 +57,6 @@
 | 
				
			||||||
    <WeblateLink context={t.context} />
 | 
					    <WeblateLink context={t.context} />
 | 
				
			||||||
    </span>
 | 
					    </span>
 | 
				
			||||||
  {:else if $tags !== undefined }
 | 
					  {:else if $tags !== undefined }
 | 
				
			||||||
    <ToSvelte construct={specpart.func.constr(state, tags, specpart.args, feature, layer)}></ToSvelte>
 | 
					    <ToSvelte construct={createVisualisation(specpart)}></ToSvelte>
 | 
				
			||||||
  {/if}
 | 
					  {/if}
 | 
				
			||||||
{/each}
 | 
					{/each}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,7 +22,9 @@
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  export let layer: LayerConfig;
 | 
					  export let layer: LayerConfig;
 | 
				
			||||||
  let trs: { then: Translation; icon?: string; iconClass?: string }[];
 | 
					  let trs: { then: Translation; icon?: string; iconClass?: string }[];
 | 
				
			||||||
  $: trs = Utils.NoNull(config?.GetRenderValues(_tags));
 | 
					  $:{
 | 
				
			||||||
 | 
					    trs = Utils.NoNull(config?.GetRenderValues(_tags));
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
  let classes = ""
 | 
					  let classes = ""
 | 
				
			||||||
  $:classes = config?.classes?.join(" ") ?? "";
 | 
					  $:classes = config?.classes?.join(" ") ?? "";
 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -121,7 +121,7 @@
 | 
				
			||||||
  </If>
 | 
					  </If>
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<If condition={selectedViewElement.map(v => v !== undefined)}>
 | 
					<If condition={selectedViewElement.map(v => v !== undefined && selectedLayer.data !== undefined,[ selectedLayer] )}>
 | 
				
			||||||
  <ModalRight on:close={() => {selectedElement.setData(undefined)}}>
 | 
					  <ModalRight on:close={() => {selectedElement.setData(undefined)}}>
 | 
				
			||||||
    <ToSvelte construct={new VariableUiElement(selectedViewElement)}></ToSvelte>
 | 
					    <ToSvelte construct={new VariableUiElement(selectedViewElement)}></ToSvelte>
 | 
				
			||||||
  </ModalRight>
 | 
					  </ModalRight>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue