diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt index e666323931..179875227f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt @@ -95,6 +95,16 @@ table.struct-diff ul.diff-obj li { white-space: nowrap; } + /* Catalog log info column (biblio JSON payload) */ + div.loginfo-struct { + font-family: monospace; + font-size: 0.85em; + } + div.loginfo-struct ul.diff-obj { + list-style: none; + margin: 0; + padding: 0 0 0 0.8em; + } [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/viewlog.js b/koha-tmpl/intranet-tmpl/prog/js/viewlog.js index 399732f0e2..c2b45ebea6 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/viewlog.js +++ b/koha-tmpl/intranet-tmpl/prog/js/viewlog.js @@ -21,6 +21,56 @@ function collectDiffEntries(node, prefix) { return entries; } +/** + * Pretty-print a parsed JSON value as nested
block for non-Struct::Diff JSON or plain text.
@@ -40,39 +90,16 @@ function renderStructDiff(raw) {
var entries = collectDiffEntries(diff.D, "");
if (!entries.length) return "";
- function fmt(v) {
- if (v === undefined || v === null) return "";
- if (typeof v !== "object") return $("").text(String(v)).html();
- if (Array.isArray(v)) {
- var items = v
- .map(function (item) {
- return "- " + fmt(item) + "
";
- })
- .join("");
- return '' + items + "
";
- }
- var items = Object.keys(v)
- .map(function (k) {
- return (
- "- " +
- $("").text(k).html() +
- ": " +
- fmt(v[k]) +
- "
"
- );
- })
- .join("");
- return '' + items + "
";
- }
-
var rows = entries
.map(function (e) {
var before =
e.before !== undefined
- ? "" + fmt(e.before) + ""
+ ? "" + fmtJsonValue(e.before) + ""
: "";
var after =
- e.after !== undefined ? "" + fmt(e.after) + "" : "";
+ e.after !== undefined
+ ? "" + fmtJsonValue(e.after) + ""
+ : "";
return (
"" +
'' +
@@ -269,6 +296,14 @@ $(document).ready(function () {
$(this).html(renderStructDiff(raw));
}
});
+
+ $("div.loginfo").each(function () {
+ var raw = $(this).text().trim();
+ var rendered = renderCatalogInfo(raw);
+ if (rendered) {
+ $(this).html(rendered);
+ }
+ });
patron_autocomplete($("#user"), {
"on-select-callback": function (event, ui) {
$("#user").val(ui.item.patron_id);