Added actor and tag copying to scene relations.

This commit is contained in:
2026-11-26 00:23:31 +01:00
parent 449e3c9d74
commit 7e28595a19
9 changed files with 864 additions and 80 deletions
+33
View File
@@ -62,9 +62,29 @@ function toEdit(relation) {
type: relation.type,
direction: relation.direction,
comment: relation.comment || null,
share: relation.share || null,
};
}
const shareModeLabels = {
from: 'from',
to: 'to',
both: 'both ways',
};
// e.g. 'Copies tags both ways, actors from'
function getShareSummary(relation) {
const share = getEditRelation(relation)?.share;
if (!share) {
return null;
}
const summary = Object.entries(share).map(([field, mode]) => `${field} ${shareModeLabels[mode] || mode}`).join(', ');
return `Copies ${summary} the related scene`.replace(/ both ways the related scene$/, ' both ways');
}
// adding an existing relation again replaces its comment
function addRelation(relation) {
showDialog.value = false;
@@ -116,6 +136,13 @@ watch(() => props.scene, () => {
>&nbsp;({{ getComment(relation) }})</span>
</span>
<Icon
v-if="getShareSummary(relation)"
v-tooltip="getShareSummary(relation)"
icon="copy"
class="shared"
/>
<Icon
v-if="edits.relations && !isIncluded(relation)"
icon="checkmark"
@@ -251,6 +278,12 @@ watch(() => props.scene, () => {
text-decoration: inherit;
}
.shared {
height: auto;
padding: .25rem .3rem;
fill: var(--primary);
}
.relation-comment {
display: inline-block;
max-width: 15rem;
+47 -1
View File
@@ -254,7 +254,16 @@ async function reviewRevision(revision, isApproved) {
revisionId: revision.id,
});
revisions.value = revisions.value.map((rev) => (rev.id === updatedRevision.revision.id ? updatedRevision.revision : rev));
// revisions generated by sharing a relation were reviewed along with this one
const childIds = new Set(updatedRevision.revision.childRevisions?.map((child) => child.id) || []);
const updatedChildren = await Promise.all(revisions.value
.filter((rev) => childIds.has(rev.id))
.map(async (rev) => (await get(`/revisions/${domain}/${rev.id}`, { revisionId: rev.id })).revision));
const updatedById = Object.fromEntries([updatedRevision.revision, ...updatedChildren].map((rev) => [rev.id, rev]));
childIds.forEach((childId) => reviewedRevisions.value.add(childId));
revisions.value = revisions.value.map((rev) => updatedById[rev.id] || rev);
}
catch (error) {
reviewedRevisions.value.delete(revision.id);
@@ -351,6 +360,11 @@ async function banEditor(revision) {
class="nolink"
>{{ rev.review.username }}</a>&nbsp;{{ format(rev.review.reviewedAt, 'yyyy-MM-dd hh:mm') }}</span>
<span
v-else-if="rev.parentRevisionId && context === 'admin'"
class="rev-parent"
>Reviewed with #{{ rev.parentRevisionId }}</span>
<template v-else-if="context === 'admin'">
<Icon
v-tooltip="{ content: 'Ban user from submitting revisions', ariaId: `rev-ban-${rev.id}` }"
@@ -462,6 +476,26 @@ async function banEditor(revision) {
>
{{ rev.comment }}
</div>
<div
v-if="rev.parentRevisionId || rev.childRevisions?.length > 0"
class="rev-shared"
>
<template v-if="rev.parentRevisionId">Generated by sharing a relation in revision #{{ rev.parentRevisionId }}, reviewed and applied with it.</template>
<template v-else>
Also applies
<template
v-for="(child, index) in rev.childRevisions"
:key="`rev-${rev.id}-child-${child.id}`"
>{{ index > 0 ? ', ' : '' }}<a
:href="`/${domain.slice(0, -1)}/${child.sceneId}`"
target="_blank"
class="link"
>#{{ child.id }} to scene {{ child.sceneId }}</a></template>
for sharing a relation.
</template>
</div>
</template>
<div
@@ -751,6 +785,18 @@ async function banEditor(revision) {
border-top: solid 1px var(--glass-weak-30);
}
.rev-shared {
padding: .5rem;
border-top: solid 1px var(--glass-weak-30);
color: var(--glass-strong-10);
font-size: .9rem;
}
.rev-parent {
color: var(--glass-strong-10);
font-size: .9rem;
}
.rev-compact {
display: flex;
align-items: stretch;