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 <Roberto.Rosario@mayan-edms.com>
This commit is contained in:
Roberto Rosario
2018-12-27 00:33:33 -04:00
parent 8d3f26bd7f
commit 0ee82e9efe
3 changed files with 6 additions and 3 deletions

View File

@@ -75,7 +75,7 @@
{% if not hide_columns %}
{% get_source_columns source=object exclude_identifier=True as source_columns %}
{% for column in source_columns %}
<div class="text-center" style="">{% source_column_resolve column=column as column_value %}{% if column_value != '' %}{{ column.label }}: {{ column_value }}{% endif %}</div>
<div class="text-center" style="">{% source_column_resolve column=column as column_value %}{% if column_value != '' %}{% if column.include_label %}{{ column.label }}: {% endif %}{{ column_value }}{% endif %}</div>
{% endfor %}
{% endif %}

View File

@@ -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',

View File

@@ -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