forked from MapComplete/MapComplete
		
	Chore: formatting
This commit is contained in:
		
							parent
							
								
									35eff07c80
								
							
						
					
					
						commit
						c08fe03ed0
					
				
					 422 changed files with 31594 additions and 43019 deletions
				
			
		|  | @ -5,7 +5,7 @@ import { | |||
|     Conversion, | ||||
|     ConversionMessage, | ||||
|     DesugaringContext, | ||||
|     Pipe | ||||
|     Pipe, | ||||
| } from "../../Models/ThemeConfig/Conversion/Conversion" | ||||
| import { PrepareLayer } from "../../Models/ThemeConfig/Conversion/PrepareLayer" | ||||
| import { ValidateLayer, ValidateTheme } from "../../Models/ThemeConfig/Conversion/Validation" | ||||
|  | @ -69,7 +69,6 @@ export abstract class EditJsonState<T> { | |||
|         this.category = category | ||||
|         this.expertMode = options?.expertMode ?? new UIEventSource<boolean>(false) | ||||
| 
 | ||||
| 
 | ||||
|         const layerId = this.getId() | ||||
|         this.configuration | ||||
|             .mapD((config) => { | ||||
|  | @ -89,7 +88,6 @@ export abstract class EditJsonState<T> { | |||
|                 await this.server.update(id, config, this.category) | ||||
|             }) | ||||
|         this.messages = this.createMessagesStore() | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     public startSavingUpdates(enabled = true) { | ||||
|  | @ -158,10 +156,10 @@ export abstract class EditJsonState<T> { | |||
|             path, | ||||
|             type: "translation", | ||||
|             hints: { | ||||
|                 typehint: "translation" | ||||
|                 typehint: "translation", | ||||
|             }, | ||||
|             required: origConfig.required ?? false, | ||||
|             description: origConfig.description ?? "A translatable object" | ||||
|             description: origConfig.description ?? "A translatable object", | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  | @ -233,19 +231,21 @@ export abstract class EditJsonState<T> { | |||
| 
 | ||||
|     protected abstract getId(): Store<string> | ||||
| 
 | ||||
|     protected abstract validate(configuration: Partial<T>): Promise<ConversionMessage[]>; | ||||
|     protected abstract validate(configuration: Partial<T>): Promise<ConversionMessage[]> | ||||
| 
 | ||||
|     /** | ||||
|      * Creates a store that validates the configuration and which contains all relevant (error)-messages | ||||
|      * @private | ||||
|      */ | ||||
|     private createMessagesStore(): Store<ConversionMessage[]> { | ||||
|         return this.configuration.mapAsyncD(async (config) => { | ||||
|             if(!this.validate){ | ||||
|                 return [] | ||||
|             } | ||||
|             return await this.validate(config) | ||||
|         }).map(messages => messages ?? []) | ||||
|         return this.configuration | ||||
|             .mapAsyncD(async (config) => { | ||||
|                 if (!this.validate) { | ||||
|                     return [] | ||||
|                 } | ||||
|                 return await this.validate(config) | ||||
|             }) | ||||
|             .map((messages) => messages ?? []) | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  | @ -311,7 +311,7 @@ export default class EditLayerState extends EditJsonState<LayerConfigJson> { | |||
|     public readonly imageUploadManager = { | ||||
|         getCountsFor() { | ||||
|             return 0 | ||||
|         } | ||||
|         }, | ||||
|     } | ||||
|     public readonly layout: { getMatchingLayer: (key: any) => LayerConfig } | ||||
|     public readonly featureSwitches: { | ||||
|  | @ -327,8 +327,8 @@ export default class EditLayerState extends EditJsonState<LayerConfigJson> { | |||
|         properties: this.testTags.data, | ||||
|         geometry: { | ||||
|             type: "Point", | ||||
|             coordinates: [3.21, 51.2] | ||||
|         } | ||||
|             coordinates: [3.21, 51.2], | ||||
|         }, | ||||
|     } | ||||
| 
 | ||||
|     constructor( | ||||
|  | @ -346,10 +346,10 @@ export default class EditLayerState extends EditJsonState<LayerConfigJson> { | |||
|                 } catch (e) { | ||||
|                     return undefined | ||||
|                 } | ||||
|             } | ||||
|             }, | ||||
|         } | ||||
|         this.featureSwitches = { | ||||
|             featureSwitchIsDebugging: new UIEventSource<boolean>(true) | ||||
|             featureSwitchIsDebugging: new UIEventSource<boolean>(true), | ||||
|         } | ||||
| 
 | ||||
|         this.addMissingTagRenderingIds() | ||||
|  | @ -426,8 +426,9 @@ export default class EditLayerState extends EditJsonState<LayerConfigJson> { | |||
|         }) | ||||
|     } | ||||
| 
 | ||||
|     protected async validate(configuration: Partial<LayerConfigJson>): Promise<ConversionMessage[]> { | ||||
| 
 | ||||
|     protected async validate( | ||||
|         configuration: Partial<LayerConfigJson> | ||||
|     ): Promise<ConversionMessage[]> { | ||||
|         const layers = AllSharedLayers.getSharedLayersConfigs() | ||||
| 
 | ||||
|         const questions = layers.get("questions") | ||||
|  | @ -437,7 +438,7 @@ export default class EditLayerState extends EditJsonState<LayerConfigJson> { | |||
|         } | ||||
|         const state: DesugaringContext = { | ||||
|             tagRenderings: sharedQuestions, | ||||
|             sharedLayers: layers | ||||
|             sharedLayers: layers, | ||||
|         } | ||||
|         const prepare = this.buildValidation(state) | ||||
|         const context = ConversionContext.construct([], ["prepare"]) | ||||
|  | @ -475,7 +476,7 @@ export class EditThemeState extends EditJsonState<LayoutConfigJson> { | |||
|     /** Applies a few bandaids to get everything smoothed out in case of errors; a big bunch of hacks basically | ||||
|      */ | ||||
|     public setupFixers() { | ||||
|         this.configuration.addCallbackAndRunD(config => { | ||||
|         this.configuration.addCallbackAndRunD((config) => { | ||||
|             if (config.layers) { | ||||
|                 // Remove 'null' and 'undefined' values from the layer array if any are found
 | ||||
|                 for (let i = config.layers.length; i >= 0; i--) { | ||||
|  | @ -488,17 +489,16 @@ export class EditThemeState extends EditJsonState<LayoutConfigJson> { | |||
|     } | ||||
| 
 | ||||
|     protected async validate(configuration: Partial<LayoutConfigJson>) { | ||||
| 
 | ||||
|         const layers = AllSharedLayers.getSharedLayersConfigs() | ||||
| 
 | ||||
|         for (const l of configuration.layers ?? []) { | ||||
|             if(typeof l !== "string"){ | ||||
|             if (typeof l !== "string") { | ||||
|                 continue | ||||
|             } | ||||
|             if (!l.startsWith("https://")) { | ||||
|                 continue | ||||
|             } | ||||
|             const config = <LayerConfigJson> await Utils.downloadJsonCached(l, 1000*60*10) | ||||
|             const config = <LayerConfigJson>await Utils.downloadJsonCached(l, 1000 * 60 * 10) | ||||
|             layers.set(l, config) | ||||
|         } | ||||
| 
 | ||||
|  | @ -509,11 +509,11 @@ export class EditThemeState extends EditJsonState<LayoutConfigJson> { | |||
|         } | ||||
|         const state: DesugaringContext = { | ||||
|             tagRenderings: sharedQuestions, | ||||
|             sharedLayers: layers | ||||
|             sharedLayers: layers, | ||||
|         } | ||||
|         const prepare = this.buildValidation(state) | ||||
|         const context = ConversionContext.construct([], ["prepare"]) | ||||
|         if(configuration.layers){ | ||||
|         if (configuration.layers) { | ||||
|             Utils.NoNullInplace(configuration.layers) | ||||
|         } | ||||
|         try { | ||||
|  | @ -524,5 +524,4 @@ export class EditThemeState extends EditJsonState<LayoutConfigJson> { | |||
|         } | ||||
|         return context.messages | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue