Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mechanism for displaying fields conditionally based on tags #5583

Merged
merged 5 commits into from
Dec 19, 2018

Conversation

quincylvania
Copy link
Collaborator

Closes #5581.

This is a bare-bones implementation of the issue. It adds a prerequisiteTag property to the field schema that can restrict fields to show only in one of the following cases:

  • A given key/value tag is present
  • A given key is present with any value
  • A given key is present but it does not have the given value

For example, this hides the Denomination field unless there is already a religion tag.

{
    "key": "denomination",
    "type": "combo",
    "label": "Denomination",
    "prerequisiteTag": {
        "key": "religion"
    }
}

This hides the Internet Access Fee field unless the feature has an internet_access tag not equal to no.

{
    "key": "internet_access:fee",
    "type": "check",
    "label": "Internet Access Fee",
    "prerequisiteTag": {
        "key": "internet_access",
        "valueNot": "no"
    }
}

I tried to keep it simple. If more complex conditionals are needed in the future, we can revise or build upon the design.

@quincylvania quincylvania self-assigned this Dec 10, 2018
@mmd-osm
Copy link
Contributor

mmd-osm commented Dec 10, 2018

For the first example, what happens to those 8000 existing pois where denomination is set, but no religion? How would you know religion is missing, if you can't see either one?

@quincylvania quincylvania added the field An issue with a field in the user interface label Dec 10, 2018
@quincylvania
Copy link
Collaborator Author

@mmd-osm Thanks for your feedback!

Fields with values are shown even if the tag prerequisite isn't met. So if there is a denomination tag, the Denomination field will appear even if there is no religion tag. If the denomination tag is removed before a religion tag is set, the Denomination field will disappear.

Also, fields defined in fields or moreFields without prerequisites will still show up. So for the School preset, the Religion fields would still appear even if empty, no matter the value of denomination or any other tag.

@bhousel
Copy link
Member

bhousel commented Dec 18, 2018

Looks good to me, thanks @quincylvania - feel free to merge 👍

@bhousel bhousel merged commit 7db6133 into openstreetmap:master Dec 19, 2018
@quincylvania quincylvania deleted the field-prerequisite-tags branch December 19, 2018 22:52
bhousel added a commit that referenced this pull request Jan 11, 2019
(closes #5690)

This change also makes sure to use the latest copy of the entity in
field.isAllowed() to ensure the prerequisite field check works
and fieldsArr is filtered properly for #5583
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
field An issue with a field in the user interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants