Tweak how options are created for enum/choice filter value fields

This commit is contained in:
Lance Edgar 2017-07-06 21:01:23 -05:00
parent 6302d5a351
commit 018702159d

View file

@ -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):