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.
|
Renders value input as a dropdown/selectmenu of available choices.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, choices):
|
def __init__(self, options):
|
||||||
self.choices = choices
|
self.options = options
|
||||||
|
|
||||||
def render(self, value=None, **kwargs):
|
def render(self, value=None, **kwargs):
|
||||||
options = tags.Options([tags.Option(label, value=value)
|
return tags.select(self.name, [value], self.options, **kwargs)
|
||||||
for value, label in self.choices])
|
|
||||||
return tags.select(self.name, [value], options, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
class EnumValueRenderer(ChoiceValueRenderer):
|
class EnumValueRenderer(ChoiceValueRenderer):
|
||||||
|
@ -107,7 +105,7 @@ class EnumValueRenderer(ChoiceValueRenderer):
|
||||||
|
|
||||||
def __init__(self, enum):
|
def __init__(self, enum):
|
||||||
sorted_keys = sorted(enum, key=lambda k: enum[k].lower())
|
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):
|
class GridFilter(object):
|
||||||
|
|
Loading…
Reference in a new issue