Skip to content

Commit

Permalink
Merge pull request #274 from maxfordham/271-editgrid-from-autoui-shou…
Browse files Browse the repository at this point in the history
…ldnt-inherit-autoform-stuff

🐛 if root model is `EditGrid` don't inherit `SaveButtonBar` or `ShowN…
  • Loading branch information
jgunstone authored Feb 5, 2024
2 parents 8eb24db + 9359778 commit 26532ea
Showing 1 changed file with 30 additions and 19 deletions.
49 changes: 30 additions & 19 deletions src/ipyautoui/autoui.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
)
from ipyautoui.autobox import AutoBox
from ipyautoui.autoform import TitleDescription, WrapSaveButtonBar, ShowRaw, ShowNull

from ipyautoui.custom.editgrid import EditGrid
logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -229,24 +229,35 @@ def get_autoui(schema: ty.Union[ty.Type[BaseModel], dict], **kwargs):
schema, widgets_map=get_containers_map(), fail_on_error=True
)
is_container = True

class AutoUi(
caller.autoui,
ShowRaw,
ShowNull,
TitleDescription,
WrapSaveButtonBar,
AutoUiFileMethods,
):
def _set_children(self):
self.children = [
self.savebuttonbar,
w.HBox([self.bn_showraw, self.bn_shownull, self.html_title]),
self.html_description,
self.vbx_error,
self.vbx_widget,
self.vbx_showraw,
]
if issubclass(caller.autoui, EditGrid):
li = [caller.autoui, TitleDescription, ShowRaw, AutoUiFileMethods]
class AutoUi(*li):
def _set_children(self):
self.children = [
w.HBox([self.bn_showraw, self.html_title]),
self.html_description,
self.vbx_error,
self.vbx_widget,
self.vbx_showraw,
]
else:
class AutoUi(
caller.autoui,
ShowRaw,
ShowNull,
TitleDescription,
WrapSaveButtonBar,
AutoUiFileMethods,
):
def _set_children(self):
self.children = [
self.savebuttonbar,
w.HBox([self.bn_showraw, self.bn_shownull, self.html_title]),
self.html_description,
self.vbx_error,
self.vbx_widget,
self.vbx_showraw,
]

if model is not None:
return wrapped_partial(
Expand Down

0 comments on commit 26532ea

Please sign in to comment.