Allow optional row grid title for master view

This commit is contained in:
Lance Edgar 2022-07-23 22:18:17 -05:00
parent 28238c6fb5
commit e656f769b1
2 changed files with 11 additions and 0 deletions

View file

@ -104,6 +104,9 @@
% if master.has_rows: % if master.has_rows:
% if use_buefy: % if use_buefy:
<br /> <br />
% if rows_title:
<h4 class="block is-size-4">${rows_title}</h4>
% endif
<tailbone-grid ref="rowGrid" id="rowGrid"></tailbone-grid> <tailbone-grid ref="rowGrid" id="rowGrid"></tailbone-grid>
% else: % else:
${rows_grid|n} ${rows_grid|n}

View file

@ -166,6 +166,7 @@ class MasterView(View):
has_rows = False has_rows = False
model_row_class = None model_row_class = None
rows_title = None
rows_pageable = True rows_pageable = True
rows_sortable = True rows_sortable = True
rows_filterable = True rows_filterable = True
@ -224,6 +225,12 @@ class MasterView(View):
""" """
return getattr(cls, 'grid_factory', grids.Grid) return getattr(cls, 'grid_factory', grids.Grid)
@classmethod
def get_rows_title(cls):
# nb. we do not provide a default value for this, since it
# will not always make sense to show a row title
return cls.rows_title
@classmethod @classmethod
def get_row_grid_factory(cls): def get_row_grid_factory(cls):
""" """
@ -2208,6 +2215,7 @@ class MasterView(View):
context['grid_count'] = self.grid_count context['grid_count'] = self.grid_count
if self.has_rows: if self.has_rows:
context['rows_title'] = self.get_rows_title()
context['row_permission_prefix'] = self.get_row_permission_prefix() context['row_permission_prefix'] = self.get_row_permission_prefix()
context['row_model_title'] = self.get_row_model_title() context['row_model_title'] = self.get_row_model_title()
context['row_model_title_plural'] = self.get_row_model_title_plural() context['row_model_title_plural'] = self.get_row_model_title_plural()