adds hide-if-unset to custom field #12597

This commit is contained in:
Abhimanyu Saharan 2023-05-26 01:18:04 +05:30
parent 24a51dd86e
commit 49e4704bf7
3 changed files with 40 additions and 30 deletions

View File

@ -56,11 +56,13 @@ class CustomFieldVisibilityChoices(ChoiceSet):
VISIBILITY_READ_WRITE = 'read-write'
VISIBILITY_READ_ONLY = 'read-only'
VISIBILITY_HIDDEN = 'hidden'
VISIBILITY_HIDDEN_IFUNSET = 'hidden-ifunset'
CHOICES = (
(VISIBILITY_READ_WRITE, 'Read/Write'),
(VISIBILITY_READ_ONLY, 'Read-only'),
(VISIBILITY_HIDDEN, 'Hidden'),
(VISIBILITY_HIDDEN_IFUNSET, 'Hidden if unset'),
)

View File

@ -131,6 +131,9 @@
</td>
</tr>
{% for field, value in fields.items %}
{% if field.ui_visibility == 'hidden-ifunset' and not value %}
<!-- Skip hidden fields -->
{% else %}
<tr>
<th scope="row">{{ field }}
{% if field.description %}
@ -146,6 +149,7 @@
{% customfield_value field value %}
</td>
</tr>
{% endif %}
{% endfor %}
{% endfor %}
</table>

View File

@ -11,6 +11,9 @@
{% endif %}
<table class="table table-hover attr-table">
{% for field, value in fields.items %}
{% if field.ui_visibility == 'hidden-ifunset' and not value %}
<!-- Skip hidden fields -->
{% else %}
<tr>
<th scope="row">{{ field }}
{% if field.description %}
@ -26,6 +29,7 @@
{% customfield_value field value %}
</td>
</tr>
{% endif %}
{% endfor %}
</table>
{% endfor %}