diff --git a/tailbone/grids/core.py b/tailbone/grids/core.py index 6026714d..fd0ac595 100644 --- a/tailbone/grids/core.py +++ b/tailbone/grids/core.py @@ -26,6 +26,7 @@ Core Grid Classes from __future__ import unicode_literals, absolute_import +import datetime import urllib import six @@ -34,7 +35,7 @@ from sqlalchemy import orm from rattail.db import api from rattail.db.types import GPCType -from rattail.util import pretty_boolean, pretty_quantity, prettify +from rattail.util import prettify, pretty_boolean, pretty_quantity, pretty_hours import webhelpers2_grid from pyramid.renderers import render @@ -149,6 +150,8 @@ class Grid(object): self.set_renderer(key, self.render_percent) elif type_ == 'quantity': self.set_renderer(key, self.render_quantity) + elif type_ == 'duration': + self.set_renderer(key, self.render_duration) else: raise ValueError("Unsupported type for column '{}': {}".format(key, type_)) @@ -211,6 +214,12 @@ class Grid(object): value = self.obtain_value(obj, column_name) return pretty_quantity(value) + def render_duration(self, obj, column_name): + value = self.obtain_value(obj, column_name) + if value is None: + return "" + return pretty_hours(datetime.timedelta(seconds=value)) + def set_url(self, url): self.url = url diff --git a/tailbone/static/css/grids.css b/tailbone/static/css/grids.css index 98bca954..c9692c85 100644 --- a/tailbone/static/css/grids.css +++ b/tailbone/static/css/grids.css @@ -24,6 +24,7 @@ .grid-wrapper .grid-header td.tools { margin: 0; padding: 0; + text-align: right; vertical-align: bottom; white-space: nowrap; } diff --git a/tailbone/static/js/tailbone.js b/tailbone/static/js/tailbone.js index 753f10eb..334f570e 100644 --- a/tailbone/static/js/tailbone.js +++ b/tailbone/static/js/tailbone.js @@ -27,13 +27,16 @@ function disable_filter_options() { /* - * Convenience function to disable a form button. + * Convenience function to disable a UI button. */ function disable_button(button, label) { - if (label) { - $(button).html(label + ", please wait..."); + $(button).button('disable'); + if (label === undefined) { + label = "Working, please wait..."; + } + if (label) { + $(button).button('option', 'label', label); } - $(button).attr('disabled', 'disabled'); } diff --git a/tailbone/templates/master/index.mako b/tailbone/templates/master/index.mako index e417499c..a01ebfde 100644 --- a/tailbone/templates/master/index.mako +++ b/tailbone/templates/master/index.mako @@ -90,37 +90,39 @@ ## ${grid.render_complete(tools=capture(self.grid_tools).strip(), context_menu=capture(self.context_menu_items).strip())|n} -
- % if grid.filterable: - ## TODO: should this be variable sometimes? - ${grid.render_filters(allow_save_defaults=True)|n} - % endif - | - -- | - -
-
- ${self.grid_tools()}
-
- |
-
+## % if grid.filterable: +## ## TODO: should this be variable sometimes? +## ${grid.render_filters(allow_save_defaults=True)|n} +## % endif +## | +## +##+## | +## +##
+##
+## ${self.grid_tools()}
+##
+## |
+##