From d5d9c644a26022966c7d8eec3b6635df1b21b40e Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Thu, 8 Dec 2022 18:19:32 -0600 Subject: [PATCH] Add the ViewSupplement concept also fix cell-class for grid columns. cannot use "raw" fieldname because in some cases (e.g. 'number', 'rate') Bulma may interpret that as actually meaning something, and affect the display --- tailbone/app.py | 12 +++ tailbone/templates/grids/buefy.mako | 2 +- tailbone/templates/receiving/view.mako | 8 +- tailbone/views/__init__.py | 4 +- tailbone/views/customers.py | 5 +- tailbone/views/departments.py | 12 ++- tailbone/views/master.py | 118 ++++++++++++++++++++++++- tailbone/views/subdepartments.py | 4 +- tailbone/views/vendors/core.py | 2 +- 9 files changed, 153 insertions(+), 14 deletions(-) diff --git a/tailbone/app.py b/tailbone/app.py index d7155829..1cfae6b2 100644 --- a/tailbone/app.py +++ b/tailbone/app.py @@ -177,6 +177,7 @@ def make_pyramid_config(settings, configure_csrf=True): # and some similar magic for certain master views config.add_directive('add_tailbone_index_page', 'tailbone.app.add_index_page') config.add_directive('add_tailbone_config_page', 'tailbone.app.add_config_page') + config.add_directive('add_tailbone_view_supplement', 'tailbone.app.add_view_supplement') config.add_directive('add_tailbone_websocket', 'tailbone.app.add_websocket') @@ -239,6 +240,17 @@ def add_config_page(config, route_name, label, permission): config.action(None, action) +def add_view_supplement(config, route_prefix, cls): + """ + Register a master view supplement for the app. + """ + def action(): + supplements = config.get_settings().get('tailbone_view_supplements', {}) + supplements.setdefault(route_prefix, []).append(cls) + config.add_settings({'tailbone_view_supplements': supplements}) + config.action(None, action) + + def establish_theme(settings): rattail_config = settings['rattail_config'] diff --git a/tailbone/templates/grids/buefy.mako b/tailbone/templates/grids/buefy.mako index 9d8359d9..47e9a2dc 100644 --- a/tailbone/templates/grids/buefy.mako +++ b/tailbone/templates/grids/buefy.mako @@ -221,7 +221,7 @@ % if grid.is_searchable(column['field']): searchable % endif - cell-class="${column['field']}" + cell-class="c_${column['field']}" % if grid.has_click_handler(column['field']): @click.native="${grid.click_handlers[column['field']]}" % endif diff --git a/tailbone/templates/receiving/view.mako b/tailbone/templates/receiving/view.mako index b16aa5b8..f4a90dcb 100644 --- a/tailbone/templates/receiving/view.mako +++ b/tailbone/templates/receiving/view.mako @@ -267,20 +267,20 @@ % if use_buefy: