Skip to content

Commit

Permalink
did: some formatting improvments
Browse files Browse the repository at this point in the history
  • Loading branch information
saemideluxe committed Nov 7, 2023
1 parent 0503d5e commit 6f699e6
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions basxbread/layout/components/history_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,16 @@ def oldfieldvalue(c, model):
return c["change"].old


def diff_table(model, historylist, showObjectLabel=None):
def diff_table(model, historylist):
from ...layout import localize, localtime

def historyentries(c):
entries = historylist(c)
if len(entries) == 0:
return ()
return (
(i, j)
for i, j in pairwise(chain(historylist(c), [type(historylist(c)[0])()]))
for i, j in pairwise(chain(entries, [type(entries.first())()]))
if haschanges(i, j)
)

Expand All @@ -87,7 +90,8 @@ def historyentries(c):
hg.BaseElement(
localize(localtime(hg.C("row")[0].history_date).date()),
hg.If(
hg.F(lambda c: c["row"][1].history_date is None), _("Created")
hg.F(lambda c: c["row"][1].history_date is None),
hg.BaseElement(" (", _("Created"), ")"),
),
),
),
Expand All @@ -99,16 +103,6 @@ def historyentries(c):
_("User"),
hg.C("row")[0].history_user,
),
*(
[
DataTableColumn(
_("Object"),
hg.F(lambda c: showObjectLabel(c["row"][0].instance)),
)
]
if showObjectLabel is not None
else []
),
DataTableColumn(
_("Changes"),
hg.UL(
Expand All @@ -124,12 +118,13 @@ def historyentries(c):
hg.SPAN(
hg.If(
hg.C("change").old,
hg.F(lambda c: oldfieldvalue(c, model(c))),
settings.HTML_NONE,
hg.BaseElement(
hg.F(lambda c: oldfieldvalue(c, model(c))),
" -> ",
),
),
style="text-decoration: line-through;",
),
" -> ",
hg.SPAN(
hg.If(
hg.C("change").new,
Expand Down

0 comments on commit 6f699e6

Please sign in to comment.