forked from MapComplete/MapComplete
		
	First part of a huge refactoring
This commit is contained in:
		
							parent
							
								
									0c22b15c8d
								
							
						
					
					
						commit
						11150a258d
					
				
					 56 changed files with 1425 additions and 1324 deletions
				
			
		|  | @ -4,9 +4,13 @@ import {Utils} from "../../Utils"; | |||
| import LZString from "lz-string"; | ||||
| import LayoutConfig from "../../Models/ThemeConfig/LayoutConfig"; | ||||
| 
 | ||||
| /** | ||||
|  * Gives an overview of themes that are installed in the user preferences | ||||
|  */ | ||||
| export default class InstalledThemes { | ||||
|     public installedThemes: UIEventSource<{ layout: LayoutConfig; definition: string }[]>; | ||||
| 
 | ||||
|      | ||||
|     constructor(osmConnection: OsmConnection) { | ||||
|         this.installedThemes = osmConnection.preferencesHandler.preferences.map<{ layout: LayoutConfig, definition: string }[]>(allPreferences => { | ||||
|             const installedThemes: { layout: LayoutConfig, definition: string }[] = []; | ||||
|  |  | |||
|  | @ -10,7 +10,7 @@ import RelationsTracker from "../Osm/RelationsTracker"; | |||
| import {BBox} from "../BBox"; | ||||
| import Loc from "../../Models/Loc"; | ||||
| import LayerConfig from "../../Models/ThemeConfig/LayerConfig"; | ||||
| import AllKnownLayers from "../../Customizations/AllKnownLayers"; | ||||
| import Constants from "../../Models/Constants"; | ||||
| 
 | ||||
| 
 | ||||
| export default class OverpassFeatureSource implements FeatureSource { | ||||
|  | @ -122,7 +122,7 @@ export default class OverpassFeatureSource implements FeatureSource { | |||
|             if (typeof (layer) === "string") { | ||||
|                 throw "A layer was not expanded!" | ||||
|             } | ||||
|             if(AllKnownLayers.priviliged_layers.indexOf(layer.id) >= 0){ | ||||
|             if(Constants.priviliged_layers.indexOf(layer.id) >= 0){ | ||||
|                 continue | ||||
|             } | ||||
|             if (this.state.locationControl.data.zoom < layer.minzoom) { | ||||
|  |  | |||
|  | @ -29,7 +29,7 @@ export default class TitleHandler { | |||
|                     } | ||||
|                     if (layer.source.osmTags.matchesProperties(tags)) { | ||||
|                         const tagsSource = state.allElements.getEventSourceById(tags.id) ?? new UIEventSource<any>(tags) | ||||
|                         const title = new TagRenderingAnswer(tagsSource, layer.title) | ||||
|                         const title = new TagRenderingAnswer(tagsSource, layer.title, {}) | ||||
|                         return new Combine([defaultTitle, " | ", title]).ConstructElement()?.innerText ?? defaultTitle; | ||||
|                     } | ||||
|                 } | ||||
|  |  | |||
|  | @ -10,7 +10,9 @@ import {UIEventSource} from "./UIEventSource"; | |||
| import {LocalStorageSource} from "./Web/LocalStorageSource"; | ||||
| import LZString from "lz-string"; | ||||
| import * as personal from "../assets/themes/personal/personal.json"; | ||||
| import LegacyJsonConvert from "../Models/ThemeConfig/LegacyJsonConvert"; | ||||
| import {FixLegacyTheme} from "../Models/ThemeConfig/LegacyJsonConvert"; | ||||
| import {LayerConfigJson} from "../Models/ThemeConfig/Json/LayerConfigJson"; | ||||
| import SharedTagRenderings from "../Customizations/SharedTagRenderings"; | ||||
| 
 | ||||
| export default class DetermineLayout { | ||||
| 
 | ||||
|  | @ -43,7 +45,7 @@ export default class DetermineLayout { | |||
| 
 | ||||
| 
 | ||||
|         const path = window.location.pathname.split("/").slice(-1)[0]; | ||||
|         if (path !== "index.html" && path !== "") { | ||||
|         if (path !== "theme.html" && path !== "") { | ||||
|             layoutId = path; | ||||
|             if (path.endsWith(".html")) { | ||||
|                 layoutId = path.substr(0, path.length - 5); | ||||
|  | @ -104,7 +106,11 @@ export default class DetermineLayout { | |||
|                 } | ||||
|             } | ||||
| 
 | ||||
|             LegacyJsonConvert.fixThemeConfig(json) | ||||
|             json = new FixLegacyTheme().convertStrict({ | ||||
|                 tagRenderings: SharedTagRenderings.SharedTagRenderingJson, | ||||
|                 sharedLayers: new Map<string, LayerConfigJson>() // FIXME: actually add the layers
 | ||||
|             }, json, "While loading a dynamic theme") | ||||
|              | ||||
|             const layoutToUse = new LayoutConfig(json, false); | ||||
|             userLayoutParam.setData(layoutToUse.id); | ||||
|             return [layoutToUse, btoa(Utils.MinifyJSON(JSON.stringify(json)))]; | ||||
|  | @ -141,9 +147,12 @@ export default class DetermineLayout { | |||
| 
 | ||||
|         try { | ||||
| 
 | ||||
|             const parsed = await Utils.downloadJson(link) | ||||
|             let parsed = await Utils.downloadJson(link) | ||||
|             console.log("Got ", parsed) | ||||
|             LegacyJsonConvert.fixThemeConfig(parsed) | ||||
|             parsed = new FixLegacyTheme().convertStrict({ | ||||
|                 tagRenderings: SharedTagRenderings.SharedTagRenderingJson, | ||||
|                 sharedLayers: new Map<string, LayerConfigJson>() // FIXME: actually add the layers
 | ||||
|             }, parsed, "While loading a dynamic theme") | ||||
|             try { | ||||
|                 parsed.id = link; | ||||
|                 return new LayoutConfig(parsed, false).patchImages(link, JSON.stringify(parsed)); | ||||
|  |  | |||
|  | @ -10,7 +10,6 @@ import {LocalStorageSource} from "../Web/LocalStorageSource"; | |||
| import {Utils} from "../../Utils"; | ||||
| import ChangeToElementsActor from "../Actors/ChangeToElementsActor"; | ||||
| import PendingChangesUploader from "../Actors/PendingChangesUploader"; | ||||
| import TitleHandler from "../Actors/TitleHandler"; | ||||
| 
 | ||||
| /** | ||||
|  * The part of the state keeping track of where the elements, loading them, configuring the feature pipeline etc | ||||
|  | @ -90,7 +89,6 @@ export default class ElementsState extends FeatureSwitchState { | |||
| 
 | ||||
|         new ChangeToElementsActor(this.changes, this.allElements) | ||||
|         new PendingChangesUploader(this.changes, this.selectedElement); | ||||
|         new TitleHandler(this); | ||||
| 
 | ||||
|     } | ||||
| } | ||||
|  | @ -17,6 +17,7 @@ import {FeatureSourceForLayer, Tiled} from "../FeatureSource/FeatureSource"; | |||
| import SimpleFeatureSource from "../FeatureSource/Sources/SimpleFeatureSource"; | ||||
| import {LocalStorageSource} from "../Web/LocalStorageSource"; | ||||
| import {GeoOperations} from "../GeoOperations"; | ||||
| import TitleHandler from "../Actors/TitleHandler"; | ||||
| 
 | ||||
| /** | ||||
|  * Contains all the leaflet-map related state | ||||
|  | @ -130,6 +131,8 @@ export default class MapState extends UserRelatedState { | |||
|         this.initGpsLocation() | ||||
|         this.initUserLocationTrail() | ||||
|         this.initCurrentView() | ||||
| 
 | ||||
|         new TitleHandler(this); | ||||
|     } | ||||
| 
 | ||||
|     public AddAllOverlaysToMap(leafletMap: UIEventSource<any>) { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue