-
Notifications
You must be signed in to change notification settings - Fork 80
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
Adds conditional display on pages #4404
Conversation
EntitySection componentSometimes you want to display a section of the entity based on whether a given condition is met. Examples: You want to display the name of a person if they are older than 18 years old. <EntitySection show-if='{"metadata.age": { "$gt": 18 }}'>
<EntityData label-of="name" />: <EntityData value-of="name" />
</Entitysection> you want to only show the name of a person if the name exists in the entity metadata <EntitySection show-if='{"metadata.name": { "$exists": true }}'>
<EntityData label-of="name" />: <EntityData value-of="name" />
</Entitysection> You want to show the name of a person if it matches value <EntitySection show-if='{"metadata.name": "John"}'>
<EntityData label-of="name" />: <EntityData value-of="name" />
</Entitysection> Inherited properties: <EntitySection show-if='{"metadata.inherited_text": { "$in": ["something"] }}'>
<EntityData label-of="name" />: <EntityData value-of="name" />
</Entitysection> Note: The metadata is unwrapped into a JSON object with keys as the property names and values as the property values. metadata: {
name: "John",
age: 18
}
// Note that if the metadata property name has spaces, they are replaced with underscores and uppercase letters are converted to lowercase letters
// Eg: a metadata property name of "First Name" will be converted to "first_name" therefore:
metadata: {
"first_name": "John",
age: 18
} Some values takes the following format, this includes inherited values and values like multiselect: metadata: {
inherited_text: ['text value'], //Can contain more than one values depending on entities inherited from
inherited_multiselect: ['option 1', 'option 2'],
inherited_geolocation: [{ lat: 23, lon: 12}]
} Note that some values like Date added and Date modified are replaced with <EntitySection show-if='{"editDate": 12434564323 }'>
<EntityData label-of="name" />: <EntityData value-of="name" /> // This only shows if the entity
</Entitysection> |
@konzz the documentation looks neat. I would only add as a reference more complex example, ie. based on the value of an inheritance with multiple inherited values. |
Thanks, it was @grafitto driving, he has the merit here 🥇 |
f3b6dfa
to
8c2ee6e
Compare
8c2ee6e
to
0cc6d3f
Compare
…cs/uwazi into 4231-conditional-display-on-pages
fixes #4231
PR checklist:
QA checklist: