Refactory Buefy templates to use WholePage and ThisPage components
plus add `GridFilter.set_choices()` method
This commit is contained in:
parent
c64fca852c
commit
1bb0330ab5
36 changed files with 806 additions and 613 deletions
|
@ -149,6 +149,7 @@ class GridFilter(object):
|
|||
|
||||
value_renderer_factory = DefaultValueRenderer
|
||||
data_type = 'string' # default, but will be set from value renderer
|
||||
choices = {}
|
||||
|
||||
def __init__(self, key, label=None, verbs=None, value_enum=None, value_renderer=None,
|
||||
default_active=False, default_verb=None, default_value=None,
|
||||
|
@ -187,6 +188,27 @@ class GridFilter(object):
|
|||
return verbs
|
||||
return ['equal', 'not_equal', 'is_null', 'is_not_null', 'is_any']
|
||||
|
||||
def set_choices(self, choices):
|
||||
"""
|
||||
Set the value choices for the filter, post-construction. Note that
|
||||
this also will set the value renderer to one which supports choices.
|
||||
"""
|
||||
# first must normalize choices
|
||||
if isinstance(choices, OrderedDict):
|
||||
normalized = choices
|
||||
elif isinstance(choices, dict):
|
||||
normalized = OrderedDict([
|
||||
(key, choices[value])
|
||||
for key in sorted(choices)])
|
||||
elif isinstance(choices, list):
|
||||
normalized = OrderedDict([
|
||||
(key, key)
|
||||
for key in choices])
|
||||
|
||||
# store normalized choices, and set renderer
|
||||
self.choices = normalized
|
||||
self.set_value_renderer(ChoiceValueRenderer(self.choices))
|
||||
|
||||
def set_value_renderer(self, renderer):
|
||||
"""
|
||||
Set the value renderer for the filter, post-construction.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue