forked from MapComplete/MapComplete
Refactoring: split AndOrTagConfigJson into an AndTagConfig and an OrTagConfig
This commit is contained in:
parent
e225b8e45b
commit
9ae40d8af2
10 changed files with 41 additions and 32 deletions
|
@ -1,4 +1,4 @@
|
|||
import {AndOrTagConfigJson} from "./TagConfigJson";
|
||||
import {TagConfigJson} from "./TagConfigJson";
|
||||
|
||||
export default interface FilterConfigJson {
|
||||
/**
|
||||
|
@ -13,7 +13,7 @@ export default interface FilterConfigJson {
|
|||
*/
|
||||
options: {
|
||||
question: string | any;
|
||||
osmTags?: AndOrTagConfigJson | string,
|
||||
osmTags?: TagConfigJson,
|
||||
default?: boolean,
|
||||
fields?: {
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import {TagRenderingConfigJson} from "./TagRenderingConfigJson";
|
||||
import {AndOrTagConfigJson} from "./TagConfigJson";
|
||||
import {TagConfigJson} from "./TagConfigJson";
|
||||
|
||||
/**
|
||||
* The PointRenderingConfig gives all details onto how to render a single point of a feature.
|
||||
|
@ -39,7 +39,7 @@ export default interface PointRenderingConfigJson {
|
|||
* Note: strings are interpreted as icons, so layering and substituting is supported. You can use `circle:white;./my_icon.svg` to add a background circle
|
||||
*/
|
||||
iconBadges?: {
|
||||
if: string | AndOrTagConfigJson,
|
||||
if: TagConfigJson,
|
||||
/**
|
||||
* Badge to show
|
||||
* Type: icon
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {AndOrTagConfigJson} from "./TagConfigJson";
|
||||
import {TagConfigJson} from "./TagConfigJson";
|
||||
import {TagRenderingConfigJson} from "./TagRenderingConfigJson";
|
||||
|
||||
|
||||
|
@ -7,7 +7,7 @@ export interface MappingConfigJson {
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
if: AndOrTagConfigJson | string,
|
||||
if: TagConfigJson,
|
||||
/**
|
||||
* Shown if the 'if is fulfilled
|
||||
* Type: rendered
|
||||
|
@ -89,7 +89,7 @@ export interface MappingConfigJson {
|
|||
* hideInAnswer: "_country!=be"
|
||||
* }
|
||||
*/
|
||||
hideInAnswer?: boolean | string | AndOrTagConfigJson,
|
||||
hideInAnswer?: boolean | TagConfigJson,
|
||||
/**
|
||||
* Only applicable if 'multiAnswer' is set.
|
||||
* This is for situations such as:
|
||||
|
@ -98,7 +98,7 @@ export interface MappingConfigJson {
|
|||
* Note that we can not explicitly render this negative case to the user, we cannot show `does _not_ accept coins`.
|
||||
* If this is important to your usecase, consider using multiple radiobutton-fields without `multiAnswer`
|
||||
*/
|
||||
ifnot?: AndOrTagConfigJson | string
|
||||
ifnot?: TagConfigJson
|
||||
|
||||
/**
|
||||
* If chosen as answer, these tags will be applied as well onto the object.
|
||||
|
@ -117,7 +117,7 @@ export interface MappingConfigJson {
|
|||
* 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
|
||||
priorityIf?: TagConfigJson
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,22 @@
|
|||
/**
|
||||
* A small interface to combine tags and tagsfilters.
|
||||
*
|
||||
* The main representation of Tags.
|
||||
* See https://github.com/pietervdvn/MapComplete/blob/develop/Docs/Tags_format.md for more documentation
|
||||
*/
|
||||
export type TagConfigJson = string | AndTagConfigJson | OrTagConfigJson
|
||||
|
||||
|
||||
/**
|
||||
* Chain many tags, to match, all of these should be true
|
||||
* See https://github.com/pietervdvn/MapComplete/blob/develop/Docs/Tags_format.md for documentation
|
||||
*/
|
||||
export interface AndOrTagConfigJson {
|
||||
and?: (string | AndOrTagConfigJson)[]
|
||||
or?: (string | AndOrTagConfigJson)[]
|
||||
}
|
||||
export type OrTagConfigJson = {
|
||||
or: TagConfigJson[]
|
||||
}
|
||||
/**
|
||||
* Chain many tags, to match, a single of these should be true
|
||||
* See https://github.com/pietervdvn/MapComplete/blob/develop/Docs/Tags_format.md for documentation
|
||||
*/
|
||||
export type AndTagConfigJson = {
|
||||
and: TagConfigJson[]
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {AndOrTagConfigJson} from "./TagConfigJson";
|
||||
import {TagConfigJson} from "./TagConfigJson";
|
||||
|
||||
/**
|
||||
* A TagRenderingConfigJson is a single piece of code which converts one ore more tags into a HTML-snippet.
|
||||
|
@ -39,7 +39,7 @@ export interface TagRenderingConfigJson {
|
|||
*
|
||||
* This is useful to ask a follow-up question. E.g. if there is a diaper table, then ask a follow-up question on diaper tables...
|
||||
* */
|
||||
condition?: AndOrTagConfigJson | string;
|
||||
condition?: TagConfigJson;
|
||||
|
||||
/**
|
||||
* Allow freeform text input from the user
|
||||
|
@ -66,7 +66,7 @@ export interface TagRenderingConfigJson {
|
|||
*
|
||||
* This can be an substituting-tag as well, e.g. {'if': 'addr:street:={_calculated_nearby_streetname}', 'then': '{_calculated_nearby_streetname}'}
|
||||
*/
|
||||
if: AndOrTagConfigJson | string,
|
||||
if: TagConfigJson,
|
||||
/**
|
||||
* If the condition `if` is met, the text `then` will be rendered.
|
||||
* If not known yet, the user will be presented with `then` as an option
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue