Honor enum sort order where possible, for grid filter values
This commit is contained in:
parent
43122381f5
commit
f755aefbfa
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# Rattail -- Retail Software Framework
|
# Rattail -- Retail Software Framework
|
||||||
# Copyright © 2010-2018 Lance Edgar
|
# Copyright © 2010-2019 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Rattail.
|
# This file is part of Rattail.
|
||||||
#
|
#
|
||||||
|
@ -108,6 +108,9 @@ class EnumValueRenderer(ChoiceValueRenderer):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, enum):
|
def __init__(self, enum):
|
||||||
|
if isinstance(enum, OrderedDict):
|
||||||
|
sorted_keys = list(enum.keys())
|
||||||
|
else:
|
||||||
sorted_keys = sorted(enum, key=lambda k: enum[k].lower())
|
sorted_keys = sorted(enum, key=lambda k: enum[k].lower())
|
||||||
self.options = [tags.Option(enum[k], six.text_type(k)) for k in sorted_keys]
|
self.options = [tags.Option(enum[k], six.text_type(k)) for k in sorted_keys]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue