Skip to content

Commit

Permalink
Add NullableBooleanInput (#792)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamsorcerer authored Oct 2, 2023
1 parent 0d9a302 commit 8a8be4f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 4 additions & 3 deletions admin-js/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import {
BooleanField, DateField, NumberField, ReferenceField, ReferenceManyField,
ReferenceOneField, SelectField, TextField,
// Inputs
BooleanInput, DateInput, DateTimeInput, NumberInput, SelectInput, TextInput,
BooleanInput, DateInput, DateTimeInput, NullableBooleanInput, NumberInput,
SelectInput, TextInput,
TimeInput as _TimeInput, ReferenceInput as _ReferenceInput,
// Filters
email, maxLength, maxValue, minLength, minValue, regex, required,
Expand Down Expand Up @@ -65,8 +66,8 @@ const COMPONENTS = {
BooleanField, DateField, NumberField, ReferenceField, ReferenceManyField,
ReferenceOneField, SelectField, TextField, TimeField,

BooleanInput, DateInput, DateTimeInput, NumberInput, ReferenceInput, SelectInput,
TextInput, TimeInput
BooleanInput, DateInput, DateTimeInput, NullableBooleanInput, NumberInput,
ReferenceInput, SelectInput, TextInput, TimeInput
};
const FUNCTIONS = {email, maxLength, maxValue, minLength, minValue, regex, required};
const _body = document.querySelector("body");
Expand Down
3 changes: 3 additions & 0 deletions aiohttp_admin/backends/sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ def __init__(self, db: AsyncEngine, model_or_table: Union[sa.Table, type[Declara
else:
field, inp, props = get_components(c.type)

if inp == "BooleanInput" and c.nullable:
inp = "NullableBooleanInput"

props["source"] = c.name
if isinstance(c.type, sa.Enum):
props["choices"] = tuple({"id": e.value, "name": e.name}
Expand Down

0 comments on commit 8a8be4f

Please sign in to comment.