fix: QA from steven isRelationshipToMany func

This commit is contained in:
Arman committed 2023-04-06 14:07:53 +02:00
1 parent 6ebb3d3c7a
commit e80f228111
2 files changed
+6 -6

No files matched your search

@@ -103,6 +103,7 @@
$: getCollections(search).then((res) => (collectionList = res));
$: collections = collectionList?.collections?.filter((n) => n.$id !== $collection.$id) ?? [];
$: isToMany = isRelationshipToMany(data);
$: if (editing) {
way = data.twoWay ? 'two' : 'one';
@@ -235,9 +236,7 @@
</div>
</div>
<p class="u-text-center">
<b data-private>{camelize($collection.name)}</b> has {isRelationshipToMany(data)
? 'many'
: 'one'}
<b data-private>{camelize($collection.name)}</b> has {isToMany ? 'many' : 'one'}
<b data-private>{data.key}</b>
</p>
</div>
@@ -4,10 +4,11 @@ import type { Attributes } from '../../store';
//TODO: remove `side` after SDK update
export function isRelationshipToMany(attribute: Models.AttributeRelationship & { side: string }) {
if (!attribute) return false;
if (attribute?.side === 'parent') {
return !['oneToOne', 'manyToOne'].includes(attribute?.relationType);
} else {
if (!attribute?.relationType) return false;
if (attribute?.side === 'child') {
return !['oneToOne', 'oneToMany'].includes(attribute?.relationType);
} else {
return !['oneToOne', 'manyToOne'].includes(attribute?.relationType);
}
}