Skip to content

Commit

Permalink
add: modal-edit support for inline-object tables
Browse files Browse the repository at this point in the history
  • Loading branch information
saemideluxe committed May 23, 2022
1 parent 4a9a8a3 commit 4943cba
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
34 changes: 21 additions & 13 deletions basxconnect/core/layouts/editperson/common/addresses.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def numbers(request):


def tile_with_datatable(model, queryset, columns, request):
modal = layout.modal.Modal.with_ajax_content(
addmodal = layout.modal.Modal.with_ajax_content(
_("Add"),
ModelHref(
model,
Expand All @@ -36,23 +36,31 @@ def tile_with_datatable(model, queryset, columns, request):
),
submitlabel=_("Save"),
)

def editmodal():
return modal_with_trigger(
layout.modal.Modal.with_ajax_content(
_("Edit"),
ModelHref.from_object(hg.C("row"), "edit", query={"asajax": True}),
submitlabel=_("Save"),
),
layout.button.Button,
notext=True,
small=True,
buttontype="ghost",
icon="edit",
label=_("Edit"),
_class="bx--overflow-menu",
)

return tiling_col(
layout.datatable.DataTable.from_queryset(
queryset,
model=model,
prevent_automatic_sortingnames=True,
columns=columns,
rowactions=[
Link(
href=ModelHref(
model,
"edit",
kwargs={"pk": hg.C("row.pk")},
query={"next": request.get_full_path()},
),
iconname="edit",
label=_("Edit"),
),
editmodal(),
Link(
href=ModelHref(
model,
Expand All @@ -65,11 +73,11 @@ def tile_with_datatable(model, queryset, columns, request):
),
],
primary_button=layout.button.Button(
_("Add"), buttontype="primary", **modal.openerattributes
_("Add"), buttontype="primary", **addmodal.openerattributes
),
style="border-top: none;",
),
modal,
addmodal,
)


Expand Down
3 changes: 3 additions & 0 deletions basxconnect/core/views/person/person_modals_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ def get_layout(self):
"",
),
]
if self.ajax_urlparameter in self.request.GET:
return layout.forms.Form(hg.C("form"), *form_fields)

return layout.grid.Grid(
hg.H3(_("Edit Email")),
layout.grid.Row(
Expand Down

0 comments on commit 4943cba

Please sign in to comment.