diff --git a/tailbone/forms/validators.py b/tailbone/forms/validators.py index 013a70d1..e99bc37f 100644 --- a/tailbone/forms/validators.py +++ b/tailbone/forms/validators.py @@ -48,7 +48,18 @@ class ModelValidator(fe.validators.FancyValidator): obj = Session.query(self.model_class).get(value) if obj: return obj - raise formencode.Invalid("{} not found".format(self.model_name), value, state) + raise fe.Invalid("{} not found".format(self.model_name), value, state) + + def _from_python(self, value, state): + obj = value + if not obj: + return '' + return obj.uuid + + def validate_python(self, value, state): + obj = value + if obj is not None and not isinstance(obj, self.model_class): + raise fe.Invalid("Value must be a valid {} object".format(self.model_name), value, state) class ValidStore(ModelValidator): diff --git a/tailbone/static/css/timesheet.css b/tailbone/static/css/timesheet.css index 547f2138..3ce4ed9f 100644 --- a/tailbone/static/css/timesheet.css +++ b/tailbone/static/css/timesheet.css @@ -3,24 +3,50 @@ * styles for time sheets / schedules **********************************************************************/ +/****************************** + * header table + ******************************/ + .timesheet-header { - overflow: auto; - position: relative; + width: 100%; } -.timesheet-header .week-picker { - bottom: 0.5em; - position: absolute; - right: 0; +.timesheet-header td.filters { + vertical-align: bottom; + width: 100%; +} + +.timesheet-header td.filters .field { + width: auto; +} + +.timesheet-header td.menu { + padding: 0.5em; + vertical-align: top; + white-space: nowrap; +} + +.timesheet-header td.tools { + margin: 0; + padding: 0; + text-align: right; + vertical-align: bottom; + white-space: nowrap; } .timesheet-header .week-picker label { margin-left: 1em; } +/****************************** + * timesheet table + ******************************/ + .timesheet { border-bottom: 1px solid black; border-right: 1px solid black; + clear: both; + margin-top: 0.3em; width: 100%; } diff --git a/tailbone/templates/shifts/base.mako b/tailbone/templates/shifts/base.mako index 7b662f63..9a9a652c 100644 --- a/tailbone/templates/shifts/base.mako +++ b/tailbone/templates/shifts/base.mako @@ -8,124 +8,148 @@ $(function() { - $('.timesheet-header select').selectmenu(); + $('.timesheet-wrapper form').submit(function() { + $('.timesheet-header').mask("Fetching data"); + }); + + $('.timesheet-header select').selectmenu({ + change: function(event, ui) { + $(ui.item.element).parents('form').submit(); + } + }); + + $('.timesheet-header a.goto').click(function() { + $('.timesheet-header').mask("Fetching data"); + }); + + $('.week-picker button.nav').click(function() { + $('.week-picker #date').val($(this).data('date')); + }); $('.week-picker #date').datepicker({ - dateFormat: 'yy-mm-dd', + dateFormat: 'mm/dd/yy', changeYear: true, changeMonth: true, showButtonPanel: true, onSelect: function(dateText, inst) { - $(this).focus().select(); + $(this).parents('form').submit(); } }); - $('.week-picker form').submit(function() { - location.href = '?date=' + $('.week-picker #date').val(); - return false; - }); - }); %def> -<%def name="timesheet(employees, employee_column=True)"> +<%def name="context_menu()">%def> + +<%def name="timesheet(employee_column=True)"> -
-
-
-
+ ##
- ${week_of}
-
-
+ ##
+ ##
-
+ ${form.field_div('store', h.select('store', store.uuid if store else None, store_options))}
-
+ ## ${employee}
+ ##
+ ##
- ${h.form(request.current_route_url())}
- ${h.link_to(u"« Previous", '?date=' + prev_sunday.strftime('%Y-%m-%d'), class_='button')}
- ${h.link_to(u"Next »", '?date=' + next_sunday.strftime('%Y-%m-%d'), class_='button')}
-
- ${h.text('date', value=sunday.strftime('%Y-%m-%d'))}
- ${h.submit('go', "Go")}
- ${h.end_form()}
-
+ ${form.field_div('department', h.select('department', department.uuid if department else None, department_options))}
-
+
+
+
-
+ ${week_of}
+
+
| |||||||||||||||||||
${len(employees)} employees | + % for day in weekdays: ++ % endfor + | + | |||||||||||||||||
${day['hours_display']} | + % endfor +${employee.hours_display} | +