forked from MapComplete/MapComplete
		
	Refactored out 'layout.ts'
This commit is contained in:
		
							parent
							
								
									36f5e896df
								
							
						
					
					
						commit
						73f32e0ecf
					
				
					 30 changed files with 465 additions and 400 deletions
				
			
		|  | @ -2,35 +2,9 @@ import {AndOrTagConfigJson} from "./TagConfigJson"; | |||
| import {And, Or, RegexTag, Tag, TagsFilter} from "../../Logic/Tags"; | ||||
| 
 | ||||
| import {Utils} from "../../Utils"; | ||||
| import {Translation} from "../../UI/i18n/Translation"; | ||||
| 
 | ||||
| export class FromJSON { | ||||
| 
 | ||||
| 
 | ||||
|     public static Translation(json: string | any): Translation { | ||||
|         if (json === undefined) { | ||||
|             return undefined; | ||||
|         } | ||||
|         if (typeof (json) === "string") { | ||||
|             return new Translation({"*": json}); | ||||
|         } | ||||
|         if(json.render !== undefined){ | ||||
|             console.error("Using a 'render' where a translation is expected. Content is", json.render); | ||||
|             throw "ERROR: using a 'render' where none is expected" | ||||
|         } | ||||
|         const tr = {}; | ||||
|         let keyCount = 0; | ||||
|         for (let key in json) { | ||||
|             keyCount++; | ||||
|             tr[key] = json[key]; // I'm doing this wrong, I know
 | ||||
|         } | ||||
|         if(keyCount == 0){ | ||||
|             return undefined; | ||||
|         } | ||||
|         const transl = new Translation(tr); | ||||
|         return transl; | ||||
|     } | ||||
| 
 | ||||
|     public static SimpleTag(json: string): Tag { | ||||
|         const tag = Utils.SplitFirst(json, "="); | ||||
|         return new Tag(tag[0], tag[1]); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue