Add Buefy support for enum grid filters
This commit is contained in:
parent
ef7b2ddbdd
commit
be6a1d916f
|
@ -963,6 +963,12 @@ class Grid(object):
|
|||
valueless = [v for v in filtr.valueless_verbs
|
||||
if v in filtr.verbs]
|
||||
|
||||
choices = []
|
||||
choice_labels = {}
|
||||
if self.enums and filtr.key in self.enums:
|
||||
choices = list(self.enums[filtr.key])
|
||||
choice_labels = self.enums[filtr.key]
|
||||
|
||||
data[filtr.key] = {
|
||||
'key': filtr.key,
|
||||
'label': filtr.label,
|
||||
|
@ -974,6 +980,8 @@ class Grid(object):
|
|||
'verb': filtr.verb or filtr.default_verb or filtr.verbs[0],
|
||||
'value': six.text_type(filtr.value) if filtr.value is not None else "",
|
||||
'data_type': filtr.data_type,
|
||||
'choices': choices,
|
||||
'choice_labels': choice_labels,
|
||||
}
|
||||
|
||||
return data
|
||||
|
|
|
@ -99,6 +99,7 @@ class ChoiceValueRenderer(FilterValueRenderer):
|
|||
"""
|
||||
Renders value input as a dropdown/selectmenu of available choices.
|
||||
"""
|
||||
data_type = 'choice'
|
||||
|
||||
def __init__(self, options):
|
||||
self.options = options
|
||||
|
|
|
@ -36,6 +36,17 @@
|
|||
ref="valueInput">
|
||||
</tailbone-datepicker>
|
||||
|
||||
<b-select v-if="filter.data_type == 'choice'"
|
||||
v-model="filter.value"
|
||||
v-show="! (filter.valueless_verbs && filter.valueless_verbs.includes(filter.verb))"
|
||||
ref="valueInput">
|
||||
<option v-for="choice in filter.choices"
|
||||
:key="choice"
|
||||
:value="choice">
|
||||
{{ filter.choice_labels[choice] || choice }}
|
||||
</option>
|
||||
</b-select>
|
||||
|
||||
<b-input v-if="filter.data_type == 'string'"
|
||||
v-model="filter.value"
|
||||
v-show="! (filter.valueless_verbs && filter.valueless_verbs.includes(filter.verb))"
|
||||
|
|
Loading…
Reference in a new issue