Add <b-table>
element template for simple grids with "static" data
This commit is contained in:
parent
e5472a6fae
commit
1c07508f39
|
@ -946,6 +946,18 @@ class Grid(object):
|
||||||
|
|
||||||
return self.render_complete(template=template, **kwargs)
|
return self.render_complete(template=template, **kwargs)
|
||||||
|
|
||||||
|
def render_buefy_table_element(self, template='/grids/b-table.mako', data_prop='gridData', **kwargs):
|
||||||
|
"""
|
||||||
|
This is intended for ad-hoc "small" grids with static data. Renders
|
||||||
|
just a ``<b-table>`` element instead of the typical "full" grid.
|
||||||
|
"""
|
||||||
|
context = dict(kwargs)
|
||||||
|
context['grid'] = self
|
||||||
|
context['data_prop'] = data_prop
|
||||||
|
if 'grid_columns' not in context:
|
||||||
|
context['grid_columns'] = self.get_buefy_columns()
|
||||||
|
return render(template, context)
|
||||||
|
|
||||||
def get_filters_sequence(self):
|
def get_filters_sequence(self):
|
||||||
"""
|
"""
|
||||||
Returns a list of filter keys (strings) in the sequence with which they
|
Returns a list of filter keys (strings) in the sequence with which they
|
||||||
|
@ -1133,6 +1145,8 @@ class Grid(object):
|
||||||
# set action URL(s) for row, as needed
|
# set action URL(s) for row, as needed
|
||||||
self.set_action_urls(row, rowobj, i)
|
self.set_action_urls(row, rowobj, i)
|
||||||
|
|
||||||
|
# set extra row class if applicable
|
||||||
|
if self.extra_row_class:
|
||||||
status = self.extra_row_class(rowobj, i)
|
status = self.extra_row_class(rowobj, i)
|
||||||
if status:
|
if status:
|
||||||
status_map[i] = status
|
status_map[i] = status
|
||||||
|
|
46
tailbone/templates/grids/b-table.mako
Normal file
46
tailbone/templates/grids/b-table.mako
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
## -*- coding: utf-8; -*-
|
||||||
|
<b-table
|
||||||
|
:data="${data_prop}"
|
||||||
|
icon-pack="fas"
|
||||||
|
striped
|
||||||
|
hoverable
|
||||||
|
narrowed>
|
||||||
|
|
||||||
|
<template slot-scope="props">
|
||||||
|
% for column in grid_columns:
|
||||||
|
<b-table-column field="${column['field']}" label="${column['label']}" ${'sortable' if column['sortable'] else ''}>
|
||||||
|
% if grid.is_linked(column['field']):
|
||||||
|
<a :href="props.row._action_url_view" v-html="props.row.${column['field']}"></a>
|
||||||
|
% else:
|
||||||
|
<span v-html="props.row.${column['field']}"></span>
|
||||||
|
% endif
|
||||||
|
</b-table-column>
|
||||||
|
% endfor
|
||||||
|
|
||||||
|
% if grid.main_actions or grid.more_actions:
|
||||||
|
<b-table-column field="actions" label="Actions">
|
||||||
|
% for action in grid.main_actions:
|
||||||
|
<a :href="props.row._action_url_${action.key}"><i class="fas fa-${action.icon}"></i>
|
||||||
|
${action.label}
|
||||||
|
</a>
|
||||||
|
% endfor
|
||||||
|
</b-table-column>
|
||||||
|
% endif
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template slot="empty">
|
||||||
|
<section class="section">
|
||||||
|
<div class="content has-text-grey has-text-centered">
|
||||||
|
<p>
|
||||||
|
<b-icon
|
||||||
|
pack="fas"
|
||||||
|
icon="fas fa-sad-tear"
|
||||||
|
size="is-large">
|
||||||
|
</b-icon>
|
||||||
|
</p>
|
||||||
|
<p>Nothing here.</p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
</b-table>
|
Loading…
Reference in a new issue