fix external resource merging; better diff view
This commit is contained in:
parent
3e93ff5973
commit
c6c3981a39
2 changed files with 40 additions and 7 deletions
|
@ -736,7 +736,7 @@ class Item(PolymorphicModel):
|
|||
if not getattr(self, k) or ignore_existing_content:
|
||||
setattr(self, k, v)
|
||||
elif k in self.METADATA_MERGE_LIST:
|
||||
setattr(self, k, uniq((v or []) + getattr(self, k, [])))
|
||||
setattr(self, k, uniq(getattr(self, k, []) + (v or [])))
|
||||
if p.cover and (not self.has_cover() or ignore_existing_content):
|
||||
self.cover = p.cover
|
||||
|
||||
|
|
|
@ -21,16 +21,43 @@
|
|||
main>div {
|
||||
margin-bottom: 4rem;
|
||||
}
|
||||
|
||||
/* diff viewer */
|
||||
.diffview pre {
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
word-break: break-all;
|
||||
background: unset;
|
||||
}
|
||||
.diffview td {
|
||||
vertical-align: top;
|
||||
}
|
||||
.diffview td div{
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
<script src="{{ cdn_url }}/npm/json5@2.2.3/dist/index.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
function parse_json(j){
|
||||
try {
|
||||
j = JSON5.parse(j);
|
||||
} catch (e) {
|
||||
if (j == 'None' || j == '-' || j == '') j = undefined;
|
||||
if (j == 'True') j = true;
|
||||
if (j == 'False') j = false;
|
||||
}
|
||||
return JSON.stringify(j, null, 2);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
{% include "_header.html" %}
|
||||
<main>
|
||||
<div class="grid__main">
|
||||
<h4>{{ item.display_title }} - {% trans "revision history" %}</h4>
|
||||
<table class="table table-striped table-bordered">
|
||||
<table class="diffview">
|
||||
<thead>
|
||||
<tr style="background:#eee;">
|
||||
<tr>
|
||||
<th>Field</th>
|
||||
<th style="width:40%;">From</th>
|
||||
<th style="width:40%;">To</th>
|
||||
|
@ -42,7 +69,7 @@
|
|||
<td colspan="3">
|
||||
<b title="#{{ log.id }}">
|
||||
{% if request.user.is_staff or log.actor.preference.show_last_edit %}
|
||||
{{ log.actor.username }}
|
||||
{{ log.actor.username|default:'-' }}
|
||||
{% else %}
|
||||
<i class="fa-solid fa-user-secret"></i>
|
||||
{% endif %}
|
||||
|
@ -51,10 +78,16 @@
|
|||
</td>
|
||||
</tr>
|
||||
{% for key, value in log.changes_dict.items %}
|
||||
<tr {% cycle 'style="background:#eee;"' '' %}>
|
||||
<tr>
|
||||
<td>{{ key }}</td>
|
||||
<td>{{ value.0|default:"-" }}</td>
|
||||
<td>{{ value.1|default:"-" }}</td>
|
||||
<td _='init set x to innerText of first in me then set innerHTML of last in me to parse_json(x)'>
|
||||
<div class="hidden">{{ value.0|default:"-" }}</div>
|
||||
<pre></pre>
|
||||
</td>
|
||||
<td _='init set x to innerText of first in me then set innerHTML of last in me to parse_json(x)'>
|
||||
<div class="hidden">{{ value.1|default:"-" }}</div>
|
||||
<pre></pre>
|
||||
</td>
|
||||
</tr>
|
||||
{% empty %}
|
||||
<tr>
|
||||
|
|
Loading…
Add table
Reference in a new issue