fix: single relationship data editable

This commit is contained in:
Arman committed 2023-04-04 15:23:26 +02:00
1 parent 8131fce59b
commit a58547e97d
3 files changed
+17 -10

No files matched your search

@@ -93,6 +93,7 @@
value = null;
!$$slots.output && (element.value = search);
hasFocus = false;
dispatch('reset');
}
$: showClearBtn = (hasFocus && search) || value;
@@ -35,11 +35,15 @@
await teamPrefs.load($organization.$id);
documentList = await getDocuments();
if (editing && $doc?.[attribute.key] && $doc[attribute.key]?.length) {
relatedList =
$doc[attribute.key]?.map((d: Record<string, unknown>) => {
return d?.$id;
}) ?? [];
if (editing && $doc?.[attribute.key]) {
if ($doc[attribute.key]?.length) {
relatedList =
$doc[attribute.key]?.map((d: Record<string, unknown>) => {
return d?.$id;
}) ?? [];
} else {
singleRel = $doc[attribute.key]?.$id;
}
}
displayNames = $teamPrefs?.displayNames?.[attribute?.relatedCollection] ?? ['$id'];
@@ -253,6 +257,7 @@
bind:value={singleRel}
{options}
let:option={o}
on:reset={() => (value = null)}
on:select={() => (value = singleRel)}>
<SelectSearchItem data={o.data}>
{o.label}
@@ -94,13 +94,14 @@
);
return !symmetricDifference(workIds, relatedIds).length;
} else {
return workAttribute && docAttribute
? !symmetricDifference(Array.from(workAttribute), Array.from(docAttribute))
.length
: true;
const workId =
typeof workAttribute === 'string' ? workAttribute : workAttribute?.$id;
const relatedId =
typeof docAttribute === 'string' ? docAttribute : docAttribute?.$id;
return workId === relatedId;
}
}
return workAttribute === docAttribute;
}
</script>