From be6a1d916ff480891538579c71b650cc229eebe5 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 21 May 2019 18:40:08 -0500 Subject: [PATCH] Add Buefy support for enum grid filters --- tailbone/grids/core.py | 8 ++++++++ tailbone/grids/filters.py | 1 + tailbone/templates/grids/buefy.mako | 11 +++++++++++ 3 files changed, 20 insertions(+) diff --git a/tailbone/grids/core.py b/tailbone/grids/core.py index ce4a4cd8..830caf2f 100644 --- a/tailbone/grids/core.py +++ b/tailbone/grids/core.py @@ -963,6 +963,12 @@ class Grid(object): valueless = [v for v in filtr.valueless_verbs if v in filtr.verbs] + choices = [] + choice_labels = {} + if self.enums and filtr.key in self.enums: + choices = list(self.enums[filtr.key]) + choice_labels = self.enums[filtr.key] + data[filtr.key] = { 'key': filtr.key, 'label': filtr.label, @@ -974,6 +980,8 @@ class Grid(object): 'verb': filtr.verb or filtr.default_verb or filtr.verbs[0], 'value': six.text_type(filtr.value) if filtr.value is not None else "", 'data_type': filtr.data_type, + 'choices': choices, + 'choice_labels': choice_labels, } return data diff --git a/tailbone/grids/filters.py b/tailbone/grids/filters.py index 623c4793..f6740623 100644 --- a/tailbone/grids/filters.py +++ b/tailbone/grids/filters.py @@ -99,6 +99,7 @@ class ChoiceValueRenderer(FilterValueRenderer): """ Renders value input as a dropdown/selectmenu of available choices. """ + data_type = 'choice' def __init__(self, options): self.options = options diff --git a/tailbone/templates/grids/buefy.mako b/tailbone/templates/grids/buefy.mako index 41a7daef..70d7ea12 100644 --- a/tailbone/templates/grids/buefy.mako +++ b/tailbone/templates/grids/buefy.mako @@ -36,6 +36,17 @@ ref="valueInput"> + + + +