Refactor (coalesce) all batch-related templates

This commit is contained in:
Lance Edgar 2017-07-14 22:08:48 -05:00
parent 951057d8c2
commit 965dac9f43
22 changed files with 164 additions and 322 deletions

View file

@ -1,12 +1,4 @@
## -*- coding: utf-8 -*-
<%inherit file="/crud.mako" />
<%def name="title()">New ${batch_display}</%def>
<%def name="context_menu_items()">
% if request.has_perm('{0}.view'.format(permission_prefix)):
<li>${h.link_to("Back to {0}".format(batch_display_plural), url(route_prefix))}</li>
% endif
</%def>
## -*- coding: utf-8; -*-
<%inherit file="/master/create.mako" />
${parent.body()}

View file

@ -1,82 +0,0 @@
## -*- coding: utf-8 -*-
<%inherit file="/crud.mako" />
<%def name="title()">${"View" if form.readonly else "Edit"} ${batch_display}</%def>
<%def name="head_tags()">
<script type="text/javascript">
$(function() {
$('#rows-wrapper').load('${url('{0}.rows'.format(route_prefix), uuid=batch.uuid)}', function() {
// TODO: It'd be nice if we didn't have to do this here.
$(this).find('button').button();
$(this).find('input[type=submit]').button();
});
$('#save-refresh').click(function() {
$('#batch-form').append($('<input type="hidden" name="refresh" value="true" />'));
$('#batch-form').submit();
});
});
</script>
<style type="text/css">
#rows-wrapper {
margin-top: 10px;
}
.grid tr.notice.odd {
background-color: #fe8;
}
.grid tr.notice.even {
background-color: #fd6;
}
.grid tr.notice.hovering {
background-color: #ec7;
}
.grid tr.warning.odd {
background-color: #ebb;
}
.grid tr.warning.even {
background-color: #fcc;
}
.grid tr.warning.hovering {
background-color: #daa;
}
</style>
</%def>
<%def name="context_menu_items()">
<li>${h.link_to("Back to {0}".format(batch_display_plural), url(route_prefix))}</li>
% if not batch.executed:
% if form.updating:
<li>${h.link_to("View this {0}".format(batch_display), url('{0}.view'.format(route_prefix), uuid=batch.uuid))}</li>
% endif
% if form.readonly and request.has_perm('{0}.edit'.format(permission_prefix)):
<li>${h.link_to("Edit this {0}".format(batch_display), url('{0}.edit'.format(route_prefix), uuid=batch.uuid))}</li>
% endif
% endif
% if request.has_perm('{0}.delete'.format(permission_prefix)):
<li>${h.link_to("Delete this {0}".format(batch_display), url('{0}.delete'.format(route_prefix), uuid=batch.uuid))}</li>
% endif
</%def>
<div class="form-wrapper">
<ul class="context-menu">
${self.context_menu_items()}
</ul>
${form.render(form_id='batch-form', buttons=capture(buttons))|n}
</div>
<%def name="buttons()">
<div class="buttons">
% if not form.readonly and batch.refreshable:
${h.submit('save-refresh', "Save & Refresh Data")}
% endif
% if not batch.executed and request.has_perm('{0}.execute'.format(permission_prefix)):
## ${h.link_to(execute_title, url('{0}.execute'.format(route_prefix), uuid=batch.uuid))}
<button type="button" onclick="location.href = '${url('{0}.execute'.format(route_prefix), uuid=batch.uuid)}';"${'' if execute_enabled else ' disabled="disabled"'}">${execute_title}</button>
% endif
</div>
</%def>
<div id="rows-wrapper"></div>

View file

@ -1,3 +1,77 @@
## -*- coding: utf-8 -*-
<%inherit file="/batch/crud.mako" />
${parent.body()}
## -*- coding: utf-8; -*-
<%inherit file="/master/edit.mako" />
<%def name="extra_javascript()">
${parent.extra_javascript()}
${h.javascript_link(request.static_url('tailbone:static/js/jquery.ui.tailbone.js'))}
${h.javascript_link(request.static_url('tailbone:static/js/tailbone.batch.js'))}
<script type="text/javascript">
var has_execution_options = ${'true' if master.has_execution_options else 'false'};
$(function() {
$('#save-refresh').click(function() {
var form = $(this).parents('form');
form.append($('<input type="hidden" name="refresh" value="true" />'));
form.submit();
});
});
</script>
</%def>
<%def name="extra_styles()">
${parent.extra_styles()}
<style type="text/css">
.grid-wrapper {
margin-top: 10px;
}
</style>
</%def>
<%def name="buttons()">
<div class="buttons">
% if master.refreshable:
${h.submit('save-refresh', "Save & Refresh Data")}
% endif
% if not batch.executed and request.has_perm('{}.execute'.format(permission_prefix)):
<button type="button" id="execute-batch"${'' if execute_enabled else ' disabled="disabled"'}>${execute_title}</button>
% endif
</div>
</%def>
<%def name="grid_tools()">
% if not batch.executed:
<p>${h.link_to("Delete all rows matching current search", url('{}.delete_rows'.format(route_prefix), uuid=batch.uuid))}</p>
% endif
</%def>
<ul id="context-menu">
${self.context_menu_items()}
</ul>
<div class="form-wrapper">
## TODO: clean this up or fix etc..?
## % if master.edit_with_rows:
## ${form.render(buttons=capture(buttons))|n}
## % else:
${form.render()|n}
## % endif
</div>
% if master.edit_with_rows:
${rows_grid.render_complete(allow_save_defaults=False, tools=capture(self.grid_tools))|n}
% endif
<div id="execution-options-dialog" style="display: none;">
${h.form(url('{}.execute'.format(route_prefix), uuid=batch.uuid), name='batch-execution')}
% if master.has_execution_options:
${rendered_execution_options|n}
% endif
${h.end_form()}
</div>

View file

@ -1,5 +1,5 @@
## -*- coding: utf-8; -*-
<%inherit file="/newbatch/index.mako" />
<%inherit file="/batch/index.mako" />
<%def name="extra_javascript()">
${parent.extra_javascript()}

View file

@ -1,10 +0,0 @@
## -*- coding: utf-8 -*-
<%inherit file="/crud.mako" />
<%def name="title()">${batch_display} Row</%def>
<%def name="context_menu_items()">
<li>${h.link_to("Back to {0}".format(batch_display), url('{0}.view'.format(route_prefix), uuid=row.batch_uuid))}</li>
</%def>
${parent.body()}

View file

@ -1,22 +0,0 @@
## -*- coding: utf-8 -*-
<div class="grid-wrapper">
<table class="grid-header">
<tr>
<td rowspan="2" class="form">
${search.render()}
</td>
</tr>
<tr>
<td class="tools">
## TODO: Fix this check for edit mode.
% if not batch.executed and request.referrer.endswith('/edit'):
<p>${h.link_to("Delete all rows matching current search", url('{0}.rows.bulk_delete'.format(route_prefix), uuid=batch.uuid))}</p>
% endif
</td>
</tr>
</table>
${grid}
</div>

View file

@ -1,34 +1,88 @@
## -*- coding: utf-8 -*-
<%inherit file="/batch/crud.mako" />
## -*- coding: utf-8; -*-
<%inherit file="/master/view.mako" />
<%def name="head_tags()">
${parent.head_tags()}
<%def name="extra_javascript()">
${parent.extra_javascript()}
${h.javascript_link(request.static_url('tailbone:static/js/jquery.ui.tailbone.js'))}
${h.javascript_link(request.static_url('tailbone:static/js/tailbone.batch.js'))}
<script type="text/javascript">
var has_execution_options = ${'true' if master.has_execution_options else 'false'};
$(function() {
$('#execute-batch').click(function() {
$(this).button('option', 'label', "Executing, please wait...").button('disable');
location.href = '${url('{0}.execute'.format(route_prefix), uuid=batch.uuid)}';
$('#refresh-data').click(function() {
$(this)
.button('option', 'disabled', true)
.button('option', 'label', "Working, please wait...");
location.href = '${url('{}.refresh'.format(route_prefix), uuid=batch.uuid)}';
});
});
</script>
</%def>
<%def name="extra_styles()">
${parent.extra_styles()}
<style type="text/css">
.grid-wrapper {
margin-top: 10px;
}
</style>
</%def>
<%def name="context_menu_items()">
${parent.context_menu_items()}
% if request.has_perm('{0}.csv'.format(permission_prefix)):
<li>${h.link_to("Download this {0} as CSV".format(batch_display), url('{0}.csv'.format(route_prefix), uuid=batch.uuid))}</li>
% if master.rows_downloadable and request.has_perm('{}.csv'.format(permission_prefix)):
<li>${h.link_to("Download row data as CSV", url('{}.csv'.format(route_prefix), uuid=batch.uuid))}</li>
% endif
% if master.cloneable and request.has_perm('{}.clone'.format(permission_prefix)):
<li>${h.link_to("Clone as new batch", url('{}.clone'.format(route_prefix), uuid=batch.uuid))}</li>
% endif
</%def>
<%def name="buttons()">
<div class="buttons">
% if not form.readonly and batch.refreshable:
${h.submit('save-refresh', "Save & Refresh Data")}
% endif
% if not batch.executed and request.has_perm('{0}.execute'.format(permission_prefix)):
<button type="button" id="execute-batch"${'' if execute_enabled else ' disabled="disabled"'}>${execute_title}</button>
% endif
${self.leading_buttons()}
${refresh_button()}
${execute_button()}
</div>
</%def>
${parent.body()}
<%def name="leading_buttons()"></%def>
<%def name="refresh_button()">
% if master.viewing and master.batch_refreshable(batch) and request.has_perm('{}.refresh'.format(permission_prefix)):
<button type="button" id="refresh-data">Refresh data</button>
% endif
</%def>
<%def name="execute_button()">
% if not batch.executed and request.has_perm('{}.execute'.format(permission_prefix)):
<button type="button" id="execute-batch"${'' if execute_enabled else ' disabled="disabled"'}>${execute_title}</button>
% endif
</%def>
<ul id="context-menu">
${self.context_menu_items()}
</ul>
<div class="form-wrapper">
${form.render(form_id='batch-form', buttons=capture(buttons))|n}
</div><!-- form-wrapper -->
${rows_grid|n}
% if not batch.executed:
<div id="execution-options-dialog" style="display: none;">
${h.form(url('{}.execute'.format(route_prefix), uuid=batch.uuid), name='batch-execution')}
${h.csrf_token(request)}
% if master.has_execution_options:
${rendered_execution_options|n}
% endif
${h.end_form()}
</div>
% endif

View file

@ -1,5 +1,5 @@
## -*- coding: utf-8; -*-
<%inherit file="/mobile/newbatch/view.mako" />
<%inherit file="/mobile/batch/view.mako" />
<%def name="title()">${h.link_to("Inventory", url('mobile.batch.inventory'))} &raquo; ${batch.id_str}</%def>

View file

@ -1,5 +1,5 @@
## -*- coding: utf-8; -*-
<%inherit file="/mobile/newbatch/view_row.mako" />
<%inherit file="/mobile/batch/view_row.mako" />
<%namespace file="/mobile/keypad.mako" import="keypad" />
## TODO: this is broken for actual page (header) title

View file

@ -1,3 +0,0 @@
## -*- coding: utf-8 -*-
<%inherit file="/master/create.mako" />
${parent.body()}

View file

@ -1,73 +0,0 @@
## -*- coding: utf-8 -*-
<%inherit file="/master/edit.mako" />
<%def name="head_tags()">
${parent.head_tags()}
${h.javascript_link(request.static_url('tailbone:static/js/jquery.ui.tailbone.js'))}
${h.javascript_link(request.static_url('tailbone:static/js/tailbone.batch.js'))}
<script type="text/javascript">
var has_execution_options = ${'true' if master.has_execution_options else 'false'};
$(function() {
$('#save-refresh').click(function() {
var form = $(this).parents('form');
form.append($('<input type="hidden" name="refresh" value="true" />'));
form.submit();
});
});
</script>
<style type="text/css">
.grid-wrapper {
margin-top: 10px;
}
</style>
</%def>
<%def name="buttons()">
<div class="buttons">
% if master.refreshable:
${h.submit('save-refresh', "Save & Refresh Data")}
% endif
% if not batch.executed and request.has_perm('{}.execute'.format(permission_prefix)):
<button type="button" id="execute-batch"${'' if execute_enabled else ' disabled="disabled"'}>${execute_title}</button>
% endif
</div>
</%def>
<%def name="grid_tools()">
% if not batch.executed:
<p>${h.link_to("Delete all rows matching current search", url('{}.delete_rows'.format(route_prefix), uuid=batch.uuid))}</p>
% endif
</%def>
<ul id="context-menu">
${self.context_menu_items()}
</ul>
<div class="form-wrapper">
## TODO: clean this up or fix etc..?
## % if master.edit_with_rows:
## ${form.render(buttons=capture(buttons))|n}
## % else:
${form.render()|n}
## % endif
</div>
% if master.edit_with_rows:
${rows_grid.render_complete(allow_save_defaults=False, tools=capture(self.grid_tools))|n}
% endif
<div id="execution-options-dialog" style="display: none;">
${h.form(url('{}.execute'.format(route_prefix), uuid=batch.uuid), name='batch-execution')}
% if master.has_execution_options:
${rendered_execution_options|n}
% endif
${h.end_form()}
</div>

View file

@ -1,88 +0,0 @@
## -*- coding: utf-8; -*-
<%inherit file="/master/view.mako" />
<%def name="extra_javascript()">
${parent.extra_javascript()}
${h.javascript_link(request.static_url('tailbone:static/js/jquery.ui.tailbone.js'))}
${h.javascript_link(request.static_url('tailbone:static/js/tailbone.batch.js'))}
<script type="text/javascript">
var has_execution_options = ${'true' if master.has_execution_options else 'false'};
$(function() {
$('#refresh-data').click(function() {
$(this)
.button('option', 'disabled', true)
.button('option', 'label', "Working, please wait...");
location.href = '${url('{}.refresh'.format(route_prefix), uuid=batch.uuid)}';
});
});
</script>
</%def>
<%def name="extra_styles()">
${parent.extra_styles()}
<style type="text/css">
.grid-wrapper {
margin-top: 10px;
}
</style>
</%def>
<%def name="context_menu_items()">
${parent.context_menu_items()}
% if master.rows_downloadable and request.has_perm('{}.csv'.format(permission_prefix)):
<li>${h.link_to("Download row data as CSV", url('{}.csv'.format(route_prefix), uuid=batch.uuid))}</li>
% endif
% if master.cloneable and request.has_perm('{}.clone'.format(permission_prefix)):
<li>${h.link_to("Clone as new batch", url('{}.clone'.format(route_prefix), uuid=batch.uuid))}</li>
% endif
</%def>
<%def name="buttons()">
<div class="buttons">
${self.leading_buttons()}
${refresh_button()}
${execute_button()}
</div>
</%def>
<%def name="leading_buttons()"></%def>
<%def name="refresh_button()">
% if master.viewing and master.batch_refreshable(batch) and request.has_perm('{}.refresh'.format(permission_prefix)):
<button type="button" id="refresh-data">Refresh data</button>
% endif
</%def>
<%def name="execute_button()">
% if not batch.executed and request.has_perm('{}.execute'.format(permission_prefix)):
<button type="button" id="execute-batch"${'' if execute_enabled else ' disabled="disabled"'}>${execute_title}</button>
% endif
</%def>
<ul id="context-menu">
${self.context_menu_items()}
</ul>
<div class="form-wrapper">
${form.render(form_id='batch-form', buttons=capture(buttons))|n}
</div><!-- form-wrapper -->
${rows_grid|n}
% if not batch.executed:
<div id="execution-options-dialog" style="display: none;">
${h.form(url('{}.execute'.format(route_prefix), uuid=batch.uuid), name='batch-execution')}
${h.csrf_token(request)}
% if master.has_execution_options:
${rendered_execution_options|n}
% endif
${h.end_form()}
</div>
% endif

View file

@ -1,5 +1,5 @@
## -*- coding: utf-8; -*-
<%inherit file="/newbatch/create.mako" />
<%inherit file="/batch/create.mako" />
<%def name="extra_javascript()">
${parent.extra_javascript()}

View file

@ -1,5 +1,5 @@
## -*- coding: utf-8; -*-
<%inherit file="/newbatch/view.mako" />
<%inherit file="/batch/view.mako" />
<%def name="extra_javascript()">
${parent.extra_javascript()}

View file

@ -1,5 +1,5 @@
## -*- coding: utf-8; -*-
<%inherit file="/newbatch/create.mako" />
<%inherit file="/batch/create.mako" />
<%def name="extra_javascript()">
${parent.extra_javascript()}

View file

@ -1,5 +1,5 @@
## -*- coding: utf-8; -*-
<%inherit file="/master/index.mako" />
<%inherit file="/batch/index.mako" />
<%def name="context_menu_items()">
${parent.context_menu_items()}

View file

@ -1,5 +1,5 @@
## -*- coding: utf-8 -*-
<%inherit file="/newbatch/view.mako" />
## -*- coding: utf-8; -*-
<%inherit file="/batch/view.mako" />
<%def name="extra_javascript()">
${parent.extra_javascript()}

View file

@ -1,8 +1,8 @@
## -*- coding: utf-8 -*-
<%inherit file="/newbatch/create.mako" />
## -*- coding: utf-8; -*-
<%inherit file="/batch/create.mako" />
<%def name="head_tags()">
${parent.head_tags()}
<%def name="extra_javascript()">
${parent.extra_javascript()}
<script type="text/javascript">
var vendormap = {

View file

@ -411,11 +411,11 @@ class BatchMasterView(MasterView):
def get_fallback_templates(self, template, mobile=False):
if mobile:
return [
'/mobile/newbatch/{}.mako'.format(template),
'/mobile/batch/{}.mako'.format(template),
'/mobile/master/{}.mako'.format(template),
]
return [
'/newbatch/{}.mako'.format(template),
'/batch/{}.mako'.format(template),
'/master/{}.mako'.format(template),
]