Refactor time sheet, schedule filter forms to use colander/deform
also add "print employee schedule" feature, didn't realize that was missing
This commit is contained in:
parent
d30e5e2b02
commit
4191e50456
10 changed files with 225 additions and 100 deletions
tailbone/templates
|
@ -20,4 +20,14 @@
|
|||
}
|
||||
);
|
||||
</script>
|
||||
|
||||
<script tal:condition="selected_callback" type="text/javascript">
|
||||
deform.addCallback(
|
||||
'${oid}',
|
||||
function (oid) {
|
||||
$('#' + oid).datepicker('option', 'onSelect', ${selected_callback});
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -41,6 +41,15 @@
|
|||
return true;
|
||||
}
|
||||
|
||||
function date_selected(dateText, inst) {
|
||||
if (confirm_leave()) {
|
||||
$('#filter-form').submit();
|
||||
} else {
|
||||
// revert date value
|
||||
$('.week-picker input[name="date"]').val($('.week-picker').data('week'));
|
||||
}
|
||||
}
|
||||
|
||||
$(function() {
|
||||
|
||||
$('#filter-form').submit(function() {
|
||||
|
@ -69,17 +78,7 @@
|
|||
|
||||
$('.week-picker button.nav').click(function() {
|
||||
if (confirm_leave()) {
|
||||
$('.week-picker #date').val($(this).data('date'));
|
||||
$('#filter-form').submit();
|
||||
}
|
||||
});
|
||||
|
||||
$('.week-picker #date').datepicker({
|
||||
dateFormat: 'mm/dd/yy',
|
||||
changeYear: true,
|
||||
changeMonth: true,
|
||||
showButtonPanel: true,
|
||||
onSelect: function(dateText, inst) {
|
||||
$('.week-picker input[name="date"]').val($(this).data('date'));
|
||||
$('#filter-form').submit();
|
||||
}
|
||||
});
|
||||
|
@ -134,8 +133,8 @@
|
|||
<%def name="timesheet_wrapper(with_edit_form=False, change_employee=None)">
|
||||
<div class="timesheet-wrapper">
|
||||
|
||||
${form.begin(id='filter-form')}
|
||||
${form.csrf_token()}
|
||||
${h.form(request.current_route_url(_query=False), id='filter-form')}
|
||||
${h.csrf_token(request)}
|
||||
|
||||
<table class="timesheet-header">
|
||||
<tbody>
|
||||
|
@ -147,26 +146,31 @@
|
|||
<div class="field-wrapper employee">
|
||||
<label>Employee</label>
|
||||
<div class="field">
|
||||
% if request.has_perm('{}.viewall'.format(permission_prefix)):
|
||||
${autocomplete('employee', url('employees.autocomplete'),
|
||||
field_value=employee.uuid if employee else None,
|
||||
field_display=unicode(employee or ''),
|
||||
selected='employee_selected',
|
||||
change_clicked=change_employee)}
|
||||
% else:
|
||||
${form.hidden('employee', value=employee.uuid)}
|
||||
${employee}
|
||||
% endif
|
||||
${dform['employee'].serialize(text=six.text_type(employee), selected_callback='employee_selected')|n}
|
||||
</div>
|
||||
</div>
|
||||
% endif
|
||||
|
||||
% if store_options is not Undefined:
|
||||
${form.field_div('store', h.select('store', store.uuid if store else None, store_options))}
|
||||
<div class="field-wrapper store">
|
||||
<div class="field-row">
|
||||
<label for="store">Store</label>
|
||||
<div class="field">
|
||||
${dform['store'].serialize()|n}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
% endif
|
||||
|
||||
% if department_options is not Undefined:
|
||||
${form.field_div('department', h.select('department', department.uuid if department else None, department_options))}
|
||||
<div class="field-wrapper department">
|
||||
<div class="field-row">
|
||||
<label for="department">Department</label>
|
||||
<div class="field">
|
||||
${dform['department'].serialize()|n}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
% endif
|
||||
|
||||
<div class="field-wrapper week">
|
||||
|
@ -190,11 +194,11 @@
|
|||
<tr>
|
||||
<td class="tools">
|
||||
<div class="grid-tools">
|
||||
<div class="week-picker">
|
||||
<button type="button" class="nav" data-date="${prev_sunday.strftime('%m/%d/%Y')}">« Previous</button>
|
||||
<button type="button" class="nav" data-date="${next_sunday.strftime('%m/%d/%Y')}">Next »</button>
|
||||
<div class="week-picker" data-week="${sunday.strftime('%Y-%m-%d')}">
|
||||
<button type="button" class="nav" data-date="${prev_sunday.strftime('%Y-%m-%d')}">« Previous</button>
|
||||
<button type="button" class="nav" data-date="${next_sunday.strftime('%Y-%m-%d')}">Next »</button>
|
||||
<label>Jump to week:</label>
|
||||
${form.text('date', value=sunday.strftime('%m/%d/%Y'))}
|
||||
${dform['date'].serialize(extra_options={'showButtonPanel': True}, selected_callback='date_selected')|n}
|
||||
</div>
|
||||
</div><!-- grid-tools -->
|
||||
</td><!-- tools -->
|
||||
|
@ -203,7 +207,7 @@
|
|||
</tbody>
|
||||
</table><!-- timesheet-header -->
|
||||
|
||||
${form.end()}
|
||||
${h.end_form()}
|
||||
|
||||
% if with_edit_form:
|
||||
${self.edit_form()}
|
||||
|
|
|
@ -6,7 +6,11 @@
|
|||
<li>${h.link_to("Edit Schedule", url('schedule.edit'))}</li>
|
||||
% endif
|
||||
% if request.has_perm('schedule.print'):
|
||||
<li>${h.link_to("Print Schedule", url('schedule.print'), target='_blank')}</li>
|
||||
% if employee is Undefined:
|
||||
<li>${h.link_to("Print Schedule", url('schedule.print'), target='_blank')}</li>
|
||||
% else:
|
||||
<li>${h.link_to("Print this Schedule", url('schedule.employee.print'), target='_blank')}</li>
|
||||
% endif
|
||||
% endif
|
||||
% if request.has_perm('timesheet.view'):
|
||||
<li>${h.link_to("View this Time Sheet", url('schedule.goto.timesheet'), class_='goto')}</li>
|
||||
|
|
20
tailbone/templates/shifts/schedule_print_employee.mako
Normal file
20
tailbone/templates/shifts/schedule_print_employee.mako
Normal file
|
@ -0,0 +1,20 @@
|
|||
## -*- coding: utf-8; -*-
|
||||
<%namespace file="/shifts/base.mako" import="timesheet" />
|
||||
<%namespace file="/shifts/schedule.mako" import="render_day" />
|
||||
<html>
|
||||
<head>
|
||||
## TODO: this seems a little hacky..?
|
||||
${h.stylesheet_link(request.static_url('tailbone:static/css/normalize.css'), media='all')}
|
||||
${h.stylesheet_link(request.static_url('tailbone:static/css/base.css'), media='all')}
|
||||
${h.stylesheet_link(request.static_url('tailbone:static/css/grids.css'), media='all')}
|
||||
${h.stylesheet_link(request.static_url('tailbone:static/css/timesheet.css'), media='all')}
|
||||
${h.stylesheet_link(request.static_url('tailbone:static/css/schedule_print.css'), media='print')}
|
||||
</head>
|
||||
<body>
|
||||
<h1>
|
||||
${employee} -
|
||||
${week_of}
|
||||
</h1>
|
||||
${timesheet(render_day=render_day)}
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue