Add basic Buefy support for row grids
possibly even "complete" support...guess we'll see
This commit is contained in:
parent
a3ca6abb7a
commit
9d6cc86e60
|
@ -123,7 +123,14 @@
|
|||
|
||||
</div>
|
||||
|
||||
${rows_grid|n}
|
||||
% if use_buefy:
|
||||
<br /><br />
|
||||
## TODO: stop using |n filter
|
||||
${rows_grid.render_buefy(allow_save_defaults=False, tools=rows_grid_tools)|n}
|
||||
% else:
|
||||
## no buefy, so do the traditional thing
|
||||
${rows_grid|n}
|
||||
% endif
|
||||
|
||||
% if master.handler.executable(batch) and not batch.executed:
|
||||
<div id="execution-options-dialog" style="display: none;">
|
||||
|
|
|
@ -6,17 +6,21 @@
|
|||
<%def name="extra_javascript()">
|
||||
${parent.extra_javascript()}
|
||||
% if master.has_rows:
|
||||
% if use_buefy:
|
||||
${h.javascript_link(request.static_url('tailbone:static/js/tailbone.buefy.gridfilters.js') + '?ver={}'.format(tailbone.__version__))}
|
||||
% else:
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
$('.grid-wrapper').gridwrapper();
|
||||
});
|
||||
</script>
|
||||
% endif
|
||||
% endif
|
||||
</%def>
|
||||
|
||||
<%def name="extra_styles()">
|
||||
${parent.extra_styles()}
|
||||
% if master.has_rows:
|
||||
% if master.has_rows and not use_buefy:
|
||||
<style type="text/css">
|
||||
.grid-wrapper {
|
||||
margin-top: 10px;
|
||||
|
@ -83,5 +87,12 @@
|
|||
</div>
|
||||
|
||||
% if master.has_rows:
|
||||
% if use_buefy:
|
||||
<br /><br />
|
||||
## TODO: stop using |n filter
|
||||
${rows_grid.render_buefy(allow_save_defaults=False, tools=rows_grid_tools)|n}
|
||||
% else:
|
||||
## no buefy, so do the traditional thing
|
||||
${rows_grid|n}
|
||||
% endif
|
||||
% endif
|
||||
|
|
|
@ -556,6 +556,8 @@ class BatchMasterView(MasterView):
|
|||
g.set_label('status_code', "Status")
|
||||
g.set_label('item_id', "Item ID")
|
||||
|
||||
g.set_link('sequence')
|
||||
|
||||
def get_row_status_enum(self):
|
||||
return self.model_row_class.STATUS
|
||||
|
||||
|
@ -650,23 +652,25 @@ class BatchMasterView(MasterView):
|
|||
# TODO: most of this logic is copied from MasterView, should refactor/merge somehow...
|
||||
if 'main_actions' not in kwargs:
|
||||
actions = []
|
||||
use_buefy = self.get_use_buefy()
|
||||
|
||||
# view action
|
||||
if self.rows_viewable:
|
||||
view = lambda r, i: self.get_row_action_url('view', r)
|
||||
actions.append(grids.GridAction('view', icon='zoomin', url=view))
|
||||
icon = 'eye' if use_buefy else 'zoomin'
|
||||
actions.append(self.make_action('view', icon=icon, url=view))
|
||||
|
||||
# edit and delete are NOT allowed after execution, or if batch is "complete"
|
||||
if not batch.executed and not batch.complete:
|
||||
|
||||
# edit action
|
||||
if self.rows_editable:
|
||||
actions.append(grids.GridAction('edit', icon='pencil', url=self.row_edit_action_url))
|
||||
actions.append(self.make_action('edit', icon='pencil', url=self.row_edit_action_url))
|
||||
|
||||
# delete action
|
||||
permission_prefix = self.get_permission_prefix()
|
||||
if self.rows_deletable and self.request.has_perm('{}.delete_row'.format(permission_prefix)):
|
||||
actions.append(grids.GridAction('delete', icon='trash', url=self.row_delete_action_url))
|
||||
actions.append(self.make_action('delete', icon='trash', url=self.row_delete_action_url))
|
||||
kwargs.setdefault('delete_speedbump', self.rows_deletable_speedbump)
|
||||
|
||||
kwargs['main_actions'] = actions
|
||||
|
|
|
@ -446,19 +446,21 @@ class MasterView(View):
|
|||
|
||||
if self.has_rows and 'main_actions' not in defaults:
|
||||
actions = []
|
||||
use_buefy = self.get_use_buefy()
|
||||
|
||||
# view action
|
||||
if self.rows_viewable:
|
||||
view = lambda r, i: self.get_row_action_url('view', r)
|
||||
actions.append(grids.GridAction('view', icon='zoomin', url=view))
|
||||
icon = 'eye' if use_buefy else 'zoomin'
|
||||
actions.append(self.make_action('view', icon=icon, url=view))
|
||||
|
||||
# edit action
|
||||
if self.rows_editable:
|
||||
actions.append(grids.GridAction('edit', icon='pencil', url=self.row_edit_action_url))
|
||||
actions.append(self.make_action('edit', icon='pencil', url=self.row_edit_action_url))
|
||||
|
||||
# delete action
|
||||
if self.rows_deletable and self.request.has_perm('{}.delete_row'.format(permission_prefix)):
|
||||
actions.append(grids.GridAction('delete', icon='trash', url=self.row_delete_action_url))
|
||||
actions.append(self.make_action('delete', icon='trash', url=self.row_delete_action_url))
|
||||
defaults['delete_speedbump'] = self.rows_deletable_speedbump
|
||||
|
||||
defaults['main_actions'] = actions
|
||||
|
@ -968,6 +970,7 @@ class MasterView(View):
|
|||
View for viewing details of an existing model record.
|
||||
"""
|
||||
self.viewing = True
|
||||
use_buefy = self.get_use_buefy()
|
||||
if instance is None:
|
||||
instance = self.get_instance()
|
||||
form = self.make_form(instance)
|
||||
|
@ -983,11 +986,14 @@ class MasterView(View):
|
|||
if self.request.GET.get('reset-to-default-filters') == 'true':
|
||||
return self.redirect(self.request.current_route_url(_query=None))
|
||||
|
||||
# return grid only, if partial page was requested
|
||||
if self.request.params.get('partial'):
|
||||
if six.PY3:
|
||||
self.request.response.content_type = 'text/html'
|
||||
else:
|
||||
self.request.response.content_type = b'text/html'
|
||||
if use_buefy:
|
||||
# render grid data only, as JSON
|
||||
return render_to_response('json', grid.get_buefy_data(),
|
||||
request=self.request)
|
||||
else: # just do traditional thing, render grid HTML
|
||||
self.request.response.content_type = str('text/html')
|
||||
self.request.response.text = grid.render_grid()
|
||||
return self.request.response
|
||||
|
||||
|
@ -1000,9 +1006,15 @@ class MasterView(View):
|
|||
}
|
||||
if hasattr(form, 'make_deform_form'):
|
||||
context['dform'] = form.make_deform_form()
|
||||
|
||||
if self.has_rows:
|
||||
if use_buefy:
|
||||
context['rows_grid'] = grid
|
||||
context['rows_grid_tools'] = HTML(self.make_row_grid_tools(instance) or '').strip()
|
||||
else:
|
||||
context['rows_grid'] = grid.render_complete(allow_save_defaults=False,
|
||||
tools=self.make_row_grid_tools(instance))
|
||||
|
||||
return self.render_to_response('view', context)
|
||||
|
||||
def image(self):
|
||||
|
|
Loading…
Reference in a new issue