From 018702159d9149e8ed70591126283d75777bc32c Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Thu, 6 Jul 2017 21:01:23 -0500 Subject: [PATCH] Tweak how options are created for enum/choice filter value fields --- tailbone/newgrids/filters.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tailbone/newgrids/filters.py b/tailbone/newgrids/filters.py index fae3d445..e1bde681 100644 --- a/tailbone/newgrids/filters.py +++ b/tailbone/newgrids/filters.py @@ -91,13 +91,11 @@ class ChoiceValueRenderer(FilterValueRenderer): Renders value input as a dropdown/selectmenu of available choices. """ - def __init__(self, choices): - self.choices = choices + def __init__(self, options): + self.options = options def render(self, value=None, **kwargs): - options = tags.Options([tags.Option(label, value=value) - for value, label in self.choices]) - return tags.select(self.name, [value], options, **kwargs) + return tags.select(self.name, [value], self.options, **kwargs) class EnumValueRenderer(ChoiceValueRenderer): @@ -107,7 +105,7 @@ class EnumValueRenderer(ChoiceValueRenderer): def __init__(self, enum): sorted_keys = sorted(enum, key=lambda k: enum[k].lower()) - self.choices = [(k, enum[k]) for k in sorted_keys] + self.options = [tags.Option(enum[k], k) for k in sorted_keys] class GridFilter(object):