forked from MapComplete/MapComplete
		
	Add priority-search to the searchable element
This commit is contained in:
		
							parent
							
								
									c916d5fe66
								
							
						
					
					
						commit
						07973e37a6
					
				
					 14 changed files with 5349 additions and 244 deletions
				
			
		|  | @ -107,10 +107,18 @@ export interface MappingConfigJson { | |||
|     addExtraTags?: string[] | ||||
| 
 | ||||
|     /** | ||||
|      * Searchterms (per language) to easily find an option if there are many options | ||||
|      * If there are many options, the mappings-radiobuttons will be replaced by an element with a searchfunction | ||||
|      *  | ||||
|      * Searchterms (per language) allow to easily find an option if there are many options | ||||
|      */ | ||||
|     searchTerms?: Record<string, string[]> | ||||
| 
 | ||||
|     /** | ||||
|      * If the searchable selector is picked, mappings with this item will have priority and show up even if the others are hidden | ||||
|      * Use this sparingly | ||||
|      */ | ||||
|     priorityIf?: string | AndOrTagConfigJson | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  |  | |||
|  | @ -14,6 +14,7 @@ import List from "../../UI/Base/List"; | |||
| import {MappingConfigJson, QuestionableTagRenderingConfigJson} from "./Json/QuestionableTagRenderingConfigJson"; | ||||
| import {FixedUiElement} from "../../UI/Base/FixedUiElement"; | ||||
| import {Paragraph} from "../../UI/Base/Paragraph"; | ||||
| import UserDetails from "../../Logic/Osm/OsmConnection"; | ||||
| 
 | ||||
| export interface Mapping { | ||||
|     readonly if: TagsFilter, | ||||
|  | @ -23,7 +24,8 @@ export interface Mapping { | |||
|     readonly iconClass: string | "small"  | "medium" | "large" | "small-height" | "medium-height" | "large-height", | ||||
|     readonly hideInAnswer: boolean | TagsFilter | ||||
|     readonly addExtraTags: Tag[], | ||||
|     readonly searchTerms?: Record<string, string[]> | ||||
|     readonly searchTerms?: Record<string, string[]>, | ||||
|     readonly priorityIf?: TagsFilter | ||||
| } | ||||
| 
 | ||||
| /*** | ||||
|  | @ -287,6 +289,11 @@ export default class TagRenderingConfig { | |||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * const tr = TagRenderingConfig.ExtractMapping({if: "a=b", then: "x", priorityIf: "_country=be"}, 0, "test","test", false,true) | ||||
|      * tr.if // => new Tag("a","b")
 | ||||
|      * tr.priorityIf // => new Tag("_country","be")
 | ||||
|      */ | ||||
|     public static ExtractMapping(mapping: MappingConfigJson, i: number, translationKey: string, | ||||
|                                  context: string, | ||||
|                                  multiAnswer?: boolean, isQuestionable?: boolean, commonSize: string = "small") { | ||||
|  | @ -337,6 +344,7 @@ export default class TagRenderingConfig { | |||
|                 iconClass = mapping.icon["class"] ?? iconClass | ||||
|             } | ||||
|         } | ||||
|         const prioritySearch = mapping.priorityIf !== undefined ? TagUtils.Tag(mapping.priorityIf) : undefined; | ||||
|         const mp = <Mapping>{ | ||||
|             if: TagUtils.Tag(mapping.if, `${ctx}.if`), | ||||
|             ifnot: (mapping.ifnot !== undefined ? TagUtils.Tag(mapping.ifnot, `${ctx}.ifnot`) : undefined), | ||||
|  | @ -345,7 +353,8 @@ export default class TagRenderingConfig { | |||
|             icon, | ||||
|             iconClass, | ||||
|             addExtraTags, | ||||
|             searchTerms: mapping.searchTerms | ||||
|             searchTerms: mapping.searchTerms, | ||||
|             priorityIf: prioritySearch | ||||
|         }; | ||||
|         if (isQuestionable) { | ||||
|             if (hideInAnswer !== true && mp.if !== undefined && !mp.if.isUsableAsAnswer()) { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue