forked from MapComplete/MapComplete
		
	Fix: search fields in a filter are now wrapped into parentheses, allowing for OR as regex
This commit is contained in:
		
							parent
							
								
									de699b6ea3
								
							
						
					
					
						commit
						fb250fb928
					
				
					 2 changed files with 14 additions and 7 deletions
				
			
		| 
						 | 
				
			
			@ -60,8 +60,8 @@ export default class FilterConfig {
 | 
			
		|||
            }
 | 
			
		||||
 | 
			
		||||
            const fields: { name: string; type: ValidatorType }[] = (option.fields ?? []).map((f, i) => {
 | 
			
		||||
                const type = <ValidatorType> f.type ?? "string"
 | 
			
		||||
                if(Validators.availableTypes.indexOf(type) < 0){
 | 
			
		||||
                const type = <ValidatorType>f.type ?? "string"
 | 
			
		||||
                if (Validators.availableTypes.indexOf(type) < 0) {
 | 
			
		||||
                    throw `Invalid filter: type is not a valid validator. Did you mean one of ${Utils.sortedByLevenshteinDistance(type, <any>Validators.availableTypes, x => x).slice(0, 3)}`
 | 
			
		||||
                }
 | 
			
		||||
                // Type is validated against 'ValidatedTextField' in Validation.ts, in ValidateFilterConfig
 | 
			
		||||
| 
						 | 
				
			
			@ -70,12 +70,12 @@ export default class FilterConfig {
 | 
			
		|||
                }
 | 
			
		||||
                return {
 | 
			
		||||
                    name: f.name,
 | 
			
		||||
                    type,
 | 
			
		||||
                    type
 | 
			
		||||
                }
 | 
			
		||||
            })
 | 
			
		||||
 | 
			
		||||
            for (const field of fields) {
 | 
			
		||||
                for (let ln in question.translations) {
 | 
			
		||||
                for (const ln in question.translations) {
 | 
			
		||||
                    const txt = question.translations[ln]
 | 
			
		||||
                    if (ln.startsWith("_")) {
 | 
			
		||||
                        continue
 | 
			
		||||
| 
						 | 
				
			
			@ -111,7 +111,7 @@ export default class FilterConfig {
 | 
			
		|||
                question: question,
 | 
			
		||||
                osmTags: osmTags,
 | 
			
		||||
                fields,
 | 
			
		||||
                originalTagsSpec: option.osmTags,
 | 
			
		||||
                originalTagsSpec: option.osmTags
 | 
			
		||||
            }
 | 
			
		||||
        })
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -223,7 +223,7 @@ export default class FilterConfig {
 | 
			
		|||
                        opt.osmTags?.asHumanString() ?? "",
 | 
			
		||||
                        opt.fields?.length > 0
 | 
			
		||||
                            ? opt.fields.map((f) => f.name + " (" + f.type + ")").join(" ")
 | 
			
		||||
                            : undefined,
 | 
			
		||||
                            : undefined
 | 
			
		||||
                    ])
 | 
			
		||||
                )
 | 
			
		||||
            })
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue