Tweak how options are created for enum/choice filter value fields
This commit is contained in:
parent
6302d5a351
commit
018702159d
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue