Added relation comment. Changed relation dialog order.

This commit is contained in:
2026-11-21 04:23:09 +01:00
parent 206fe91e27
commit 6176007b06
8 changed files with 164 additions and 35 deletions
+32 -6
View File
@@ -43,8 +43,17 @@ function getLabel(relation) {
return `${label.charAt(0).toLowerCase()}${label.slice(1)}`;
}
function getEditRelation(relation) {
return props.edits.relations?.find((editRelation) => getRelationKey(editRelation) === getRelationKey(relation));
}
function isIncluded(relation) {
return props.edits.relations?.some((editRelation) => getRelationKey(editRelation) === getRelationKey(relation));
return !!getEditRelation(relation);
}
// show the comment as edited, or as it was when the relation is removed
function getComment(relation) {
return getEditRelation(relation)?.comment ?? relation.comment;
}
function toEdit(relation) {
@@ -52,21 +61,21 @@ function toEdit(relation) {
sceneId: relation.sceneId,
type: relation.type,
direction: relation.direction,
comment: relation.comment || null,
};
}
// adding an existing relation again replaces its comment
function addRelation(relation) {
showDialog.value = false;
if (isIncluded(relation)) {
return;
}
if (![...props.item.value, ...newRelations.value].some((existingRelation) => getRelationKey(existingRelation) === getRelationKey(relation))) {
newRelations.value = newRelations.value.concat(relation);
}
emit('relations', props.edits.relations.concat(toEdit(relation)));
emit('relations', props.edits.relations
.filter((editRelation) => getRelationKey(editRelation) !== getRelationKey(relation))
.concat(toEdit(relation)));
}
function openDialog() {
@@ -99,6 +108,12 @@ watch(() => props.scene, () => {
target="_blank"
class="relation-name link"
>{{ relation.scene?.title || `#${relation.sceneId}` }}</a>
<span
v-if="getComment(relation)"
v-tooltip="getComment(relation)"
class="relation-comment"
>&nbsp;({{ getComment(relation) }})</span>
</span>
<Icon
@@ -235,4 +250,15 @@ watch(() => props.scene, () => {
color: inherit;
text-decoration: inherit;
}
.relation-comment {
display: inline-block;
max-width: 15rem;
overflow: hidden;
color: var(--glass-strong-10);
font-style: italic;
white-space: nowrap;
text-overflow: ellipsis;
vertical-align: bottom;
}
</style>