diff --git a/tailbone/grids/core.py b/tailbone/grids/core.py index 7c71ca0e..8f6e45df 100644 --- a/tailbone/grids/core.py +++ b/tailbone/grids/core.py @@ -1003,7 +1003,10 @@ class Grid(object): choices = [] choice_labels = {} - if self.enums and filtr.key in self.enums: + if filtr.choices: + choices = list(filtr.choices) + choices_labels = dict(filtr.choices) + elif self.enums and filtr.key in self.enums: choices = list(self.enums[filtr.key]) choice_labels = self.enums[filtr.key] diff --git a/tailbone/grids/filters.py b/tailbone/grids/filters.py index f6740623..0014c750 100644 --- a/tailbone/grids/filters.py +++ b/tailbone/grids/filters.py @@ -149,6 +149,7 @@ class GridFilter(object): value_renderer_factory = DefaultValueRenderer data_type = 'string' # default, but will be set from value renderer + choices = {} def __init__(self, key, label=None, verbs=None, value_enum=None, value_renderer=None, default_active=False, default_verb=None, default_value=None, @@ -187,6 +188,27 @@ class GridFilter(object): return verbs return ['equal', 'not_equal', 'is_null', 'is_not_null', 'is_any'] + def set_choices(self, choices): + """ + Set the value choices for the filter, post-construction. Note that + this also will set the value renderer to one which supports choices. + """ + # first must normalize choices + if isinstance(choices, OrderedDict): + normalized = choices + elif isinstance(choices, dict): + normalized = OrderedDict([ + (key, choices[value]) + for key in sorted(choices)]) + elif isinstance(choices, list): + normalized = OrderedDict([ + (key, key) + for key in choices]) + + # store normalized choices, and set renderer + self.choices = normalized + self.set_value_renderer(ChoiceValueRenderer(self.choices)) + def set_value_renderer(self, renderer): """ Set the value renderer for the filter, post-construction. diff --git a/tailbone/static/js/tailbone.buefy.grid.js b/tailbone/static/js/tailbone.buefy.grid.js index 36790feb..13fb8f00 100644 --- a/tailbone/static/js/tailbone.buefy.grid.js +++ b/tailbone/static/js/tailbone.buefy.grid.js @@ -174,9 +174,3 @@ let TailboneGrid = { } } } - - -let GridPage = { - template: '#grid-page-template', - methods: {} -} diff --git a/tailbone/templates/about.mako b/tailbone/templates/about.mako index 8c0bd67a..ef27c19c 100644 --- a/tailbone/templates/about.mako +++ b/tailbone/templates/about.mako @@ -1,14 +1,19 @@ -## -*- coding: utf-8 -*- -<%inherit file="/base.mako" /> +## -*- coding: utf-8; -*- +<%inherit file="/page.mako" /> <%namespace name="base_meta" file="/base_meta.mako" /> <%def name="title()">About ${base_meta.app_title()}%def> -
Please see rattailproject.org for more info.
+Please see rattailproject.org for more info.
+%def> + + +${parent.body()} diff --git a/tailbone/templates/appsettings.mako b/tailbone/templates/appsettings.mako index 983f679b..36783c69 100644 --- a/tailbone/templates/appsettings.mako +++ b/tailbone/templates/appsettings.mako @@ -1,5 +1,5 @@ ## -*- coding: utf-8; -*- -<%inherit file="/base.mako" /> +<%inherit file="/page.mako" /> <%def name="title()">App Settings%def> @@ -33,150 +33,164 @@ % endif %def> +<%def name="context_menu_items()"> + % if request.has_perm('settings.list'): ++ ${message} ++%def> -
-${message} -+ +${parent.body()} diff --git a/tailbone/templates/form.mako b/tailbone/templates/form.mako index 0a2dbd0f..6a89b048 100644 --- a/tailbone/templates/form.mako +++ b/tailbone/templates/form.mako @@ -45,15 +45,15 @@ %def> -<%def name="render_this_page_buefy()"> +<%def name="render_this_page_template()"> % if form is not Underined: ${self.render_form()} % endif - ${parent.render_this_page_buefy()} + ${parent.render_this_page_template()} %def> -<%def name="finalize_page_components()"> - ${parent.finalize_page_components()} +<%def name="finalize_this_page_vars()"> + ${parent.finalize_this_page_vars()} % if form is not Undefined: -%def> - -<%def name="make_tailbone_grid_app()"> - ${self.modify_tailbone_grid()} - +%def> - Vue.component('grid-page', GridPage) +<%def name="make_this_page_component()"> + ${parent.make_this_page_component()} + %def> +<%def name="render_this_page()"> + ${self.page_content()} +%def> + +<%def name="render_this_page_template()"> + ${parent.render_this_page_template()} + + ## TODO: stop using |n filter + ${grid.render_buefy(tools=capture(self.grid_tools).strip(), context_menu=capture(self.context_menu_items).strip())|n} +%def> + % if use_buefy: - ## TODO: stop using |n filter - ${grid.render_buefy(tools=capture(self.grid_tools).strip(), context_menu=capture(self.context_menu_items).strip())|n} - - - -
Please select the type of report you wish to generate.
+Please select the type of report you wish to generate.
-Please select the type of report you wish to generate.
@@ -81,9 +79,7 @@The guest role is implied for all anonymous users, i.e. when not logged in.
+ % elif instance is authenticated_role: +The authenticated role is implied for all users, but only when logged in.
+ % elif users: +The following users are assigned to this role:
+ ${users.render_grid()|n} + % else: +There are no users assigned to this role.
+ % endif +%def> + + ${parent.body()} - -The guest role is implied for all anonymous users, i.e. when not logged in.
-% elif instance is authenticated_role: -The authenticated role is implied for all users, but only when logged in.
-% elif users: -The following users are assigned to this role:
- ${users.render_grid()|n} -% else: -There are no users assigned to this role.
-% endif diff --git a/tailbone/templates/settings/email/view.mako b/tailbone/templates/settings/email/view.mako index 35b06ed4..1b527ec4 100644 --- a/tailbone/templates/settings/email/view.mako +++ b/tailbone/templates/settings/email/view.mako @@ -41,94 +41,96 @@