Add support for general "view click handler" for <b-table> element

plus some other tweaks for sake of revision history in profile view
This commit is contained in:
Lance Edgar 2019-07-09 14:56:33 -05:00
parent 069ccab0ae
commit c09437880f
2 changed files with 43 additions and 2 deletions

View file

@ -964,6 +964,24 @@ class Grid(object):
context['data_prop'] = data_prop
if 'grid_columns' not in context:
context['grid_columns'] = self.get_buefy_columns()
# locate the 'view' action
# TODO: this should be easier, and/or moved elsewhere?
view = None
for action in self.main_actions:
if action.key == 'view':
view = action
break
if not view:
for action in self.more_actions:
if action.key == 'view':
view = action
break
context['view_click_handler'] = None
if view and view.click_handler:
context['view_click_handler'] = view.click_handler
return render(template, context)
def get_filters_sequence(self):

View file

@ -4,13 +4,26 @@
icon-pack="fas"
striped
hoverable
narrowed>
narrowed
% if vshow is not Undefined and vshow:
v-show="${vshow}"
% endif
% if loading is not Undefined and loading:
:loading="${loading}"
% endif
>
<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>
<a :href="props.row._action_url_view"
v-html="props.row.${column['field']}"
% if view_click_handler:
@click.prevent="${view_click_handler}"
% endif
>
</a>
% else:
<span v-html="props.row.${column['field']}"></span>
% endif
@ -49,4 +62,14 @@
</section>
</template>
% if show_footer is not Undefined and show_footer:
<template slot="footer">
<b-field grouped position="is-right">
<span class="control">
{{ ${data_prop}.length.toLocaleString('en') }} records
</span>
</b-field>
</template>
% endif
</b-table>