Make radio form components reusable for nested checkboxes

For the template folders permission editing we need a nested
checkboxes form that is similar to "move folder" input, except
it's using checkboxes instead of radio buttons.

This moves most of the macros into a shared "select-input" components
file, which are wrapped by the existing radios.html by setting the
required input type.
This commit is contained in:
Alexey Bezhan
2019-02-25 14:55:26 +00:00
parent 9bdcd81c65
commit 194756bc2e
3 changed files with 113 additions and 100 deletions

View File

@@ -837,10 +837,7 @@ class RadioFieldWithNoneOption(FieldWithNoneOption, RadioField):
pass
class NestedRadioField(RadioFieldWithNoneOption):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
class NestedFieldMixin:
def children(self):
# start map with root option as a single child entry
child_map = {None: [option for option in self
@@ -864,6 +861,14 @@ class NestedRadioField(RadioFieldWithNoneOption):
return child_map
class NestedRadioField(RadioFieldWithNoneOption, NestedFieldMixin):
pass
class NestedCheckboxesField(SelectMultipleField, NestedFieldMixin):
pass
class HiddenFieldWithNoneOption(FieldWithNoneOption, HiddenField):
pass