From 0ee82e9efe7863425d277e1e33afd56607110154 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Thu, 27 Dec 2018 00:33:33 -0400 Subject: [PATCH] Add support for SourceColumn label display Update the class to disable displaying the column label by default and only so when the include_label argument is True. Signed-off-by: Roberto Rosario --- .../templates/appearance/generic_list_items_subtemplate.html | 2 +- mayan/apps/documents/apps.py | 4 +++- mayan/apps/navigation/classes.py | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/mayan/apps/appearance/templates/appearance/generic_list_items_subtemplate.html b/mayan/apps/appearance/templates/appearance/generic_list_items_subtemplate.html index 1299170791..62af0e0833 100644 --- a/mayan/apps/appearance/templates/appearance/generic_list_items_subtemplate.html +++ b/mayan/apps/appearance/templates/appearance/generic_list_items_subtemplate.html @@ -75,7 +75,7 @@ {% if not hide_columns %} {% get_source_columns source=object exclude_identifier=True as source_columns %} {% for column in source_columns %} -
{% source_column_resolve column=column as column_value %}{% if column_value != '' %}{{ column.label }}: {{ column_value }}{% endif %}
+
{% source_column_resolve column=column as column_value %}{% if column_value != '' %}{% if column.include_label %}{{ column.label }}: {% endif %}{{ column_value }}{% endif %}
{% endfor %} {% endif %} diff --git a/mayan/apps/documents/apps.py b/mayan/apps/documents/apps.py index 1f102f8ed7..a92b35f402 100644 --- a/mayan/apps/documents/apps.py +++ b/mayan/apps/documents/apps.py @@ -246,7 +246,9 @@ class DocumentsApp(MayanAppConfig): attribute='document_type', is_sortable=True, label=_('Type'), source=Document ) - SourceColumn(attribute='get_page_count', source=Document) + SourceColumn( + attribute='get_page_count', include_label=True, source=Document + ) SourceColumn( attribute='date_added', is_sortable=True, source=Document, views=( 'documents:document_list_recent_added', diff --git a/mayan/apps/navigation/classes.py b/mayan/apps/navigation/classes.py index c378b2ed67..2b91910579 100644 --- a/mayan/apps/navigation/classes.py +++ b/mayan/apps/navigation/classes.py @@ -563,7 +563,7 @@ class SourceColumn(object): return final_result - def __init__(self, source, attribute=None, empty_value=None, func=None, is_absolute_url=False, is_identifier=False, is_sortable=False, kwargs=None, label=None, order=None, views=None, widget=None): + def __init__(self, source, attribute=None, empty_value=None, func=None, include_label=False, is_absolute_url=False, is_identifier=False, is_sortable=False, kwargs=None, label=None, order=None, views=None, widget=None): self.source = source self._label = label self.attribute = attribute @@ -571,6 +571,7 @@ class SourceColumn(object): self.func = func self.kwargs = kwargs or {} self.order = order or 0 + self.include_label = include_label self.is_absolute_url = is_absolute_url self.is_identifier = is_identifier self.is_sortable = is_sortable