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_WRITE = 'read-write'
VISIBILITY_READ_ONLY = 'read-only' VISIBILITY_READ_ONLY = 'read-only'
VISIBILITY_HIDDEN = 'hidden' VISIBILITY_HIDDEN = 'hidden'
VISIBILITY_HIDDEN_IFUNSET = 'hidden-ifunset'
CHOICES = ( CHOICES = (
(VISIBILITY_READ_WRITE, 'Read/Write'), (VISIBILITY_READ_WRITE, 'Read/Write'),
(VISIBILITY_READ_ONLY, 'Read-only'), (VISIBILITY_READ_ONLY, 'Read-only'),
(VISIBILITY_HIDDEN, 'Hidden'), (VISIBILITY_HIDDEN, 'Hidden'),
(VISIBILITY_HIDDEN_IFUNSET, 'Hidden if unset'),
) )

View File

@ -131,21 +131,25 @@
</td> </td>
</tr> </tr>
{% for field, value in fields.items %} {% for field, value in fields.items %}
<tr> {% if field.ui_visibility == 'hidden-ifunset' and not value %}
<th scope="row">{{ field }} <!-- Skip hidden fields -->
{% if field.description %} {% else %}
<i <tr>
class="mdi mdi-information text-primary" <th scope="row">{{ field }}
data-bs-toggle="tooltip" {% if field.description %}
data-bs-placement="right" <i
title="{{ field.description|escape }}" class="mdi mdi-information text-primary"
></i> data-bs-toggle="tooltip"
{% endif %} data-bs-placement="right"
</th> title="{{ field.description|escape }}"
<td> ></i>
{% customfield_value field value %} {% endif %}
</td> </th>
</tr> <td>
{% customfield_value field value %}
</td>
</tr>
{% endif %}
{% endfor %} {% endfor %}
{% endfor %} {% endfor %}
</table> </table>

View File

@ -11,21 +11,25 @@
{% endif %} {% endif %}
<table class="table table-hover attr-table"> <table class="table table-hover attr-table">
{% for field, value in fields.items %} {% for field, value in fields.items %}
<tr> {% if field.ui_visibility == 'hidden-ifunset' and not value %}
<th scope="row">{{ field }} <!-- Skip hidden fields -->
{% if field.description %} {% else %}
<i <tr>
class="mdi mdi-information text-primary" <th scope="row">{{ field }}
data-bs-toggle="tooltip" {% if field.description %}
data-bs-placement="right" <i
title="{{ field.description|escape }}" class="mdi mdi-information text-primary"
></i> data-bs-toggle="tooltip"
{% endif %} data-bs-placement="right"
</th> title="{{ field.description|escape }}"
<td> ></i>
{% customfield_value field value %} {% endif %}
</td> </th>
</tr> <td>
{% customfield_value field value %}
</td>
</tr>
{% endif %}
{% endfor %} {% endfor %}
</table> </table>
{% endfor %} {% endfor %}