Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,16 @@
{#if 'format' in attribute && attribute.format}
<span class="u-capitalize">{attribute.format}</span>
{:else}
<span class="u-capitalize">{attribute.type}</span>
{#if isRelationship(attribute)}
<span>
with <a
href={`${base}/project-${page.params.region}-${page.params.project}/databases/database-${databaseId}/collection-${attribute?.relatedCollection}`}
><b data-private>{attribute?.key}</b></a>
</span>
{/if}
<p>
<span class="u-capitalize">{attribute.type}</span>
{#if isRelationship(attribute)}
<span>
with <a
href={`${base}/project-${page.params.region}-${page.params.project}/databases/database-${databaseId}/collection-${attribute?.relatedCollection}`}
><b data-private>{attribute?.key}</b></a>
</span>
{/if}
</p>
{/if}
<span>
{attribute.array ? '[]' : ''}
Expand All @@ -167,20 +169,22 @@
<Button text icon ariaLabel="more options" on:click={toggle}>
<Icon icon={IconDotsHorizontal} size="s" />
</Button>
<ActionMenu.Root slot="tooltip">
<ActionMenu.Root slot="tooltip" let:toggle>
<ActionMenu.Item.Button
leadingIcon={IconPencil}
on:click={() => {
selectedAttribute = attribute;
on:click={(event) => {
toggle(event);
showEdit = true;
selectedAttribute = attribute;
showDropdown[index] = false;
}}>
Update
</ActionMenu.Item.Button>
{#if !isRelationship(attribute)}
<ActionMenu.Item.Button
leadingIcon={IconPlus}
on:click={() => {
on:click={(event) => {
toggle(event);
selectedAttribute = attribute;
showCreateIndex = true;
showDropdown[index] = false;
Expand All @@ -191,10 +195,11 @@
{#if attribute.status !== 'processing'}
<ActionMenu.Item.Button
leadingIcon={IconTrash}
on:click={() => {
selectedAttribute = attribute;
on:click={(event) => {
toggle(event);
showDelete = true;
showDropdown[index] = false;
selectedAttribute = attribute;
trackEvent(Click.DatabaseAttributeDelete);
}}>
Delete
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
data: Partial<Models.AttributeRelationship>
) {
if (!isValueOfStringEnum(RelationshipType, data.relationType)) {
throw new Error(`Invalid relationship type: ${data.relationType}`);
throw new Error(
`Invalid relationship type${data.relationType ? ` : ${data.relationType}` : ''}`
);
}
if (!isValueOfStringEnum(RelationMutate, data.onDelete)) {
throw new Error(`Invalid on delete: ${data.onDelete}`);
throw new Error(`Invalid deletion method${data.onDelete ? ` : ${data.onDelete}` : ''}`);
}

await sdk
Expand Down Expand Up @@ -137,7 +139,7 @@
$: search = data.relatedCollection || undefined;

$: if (search) {
const exists = collectionList.collections?.some((c) =>
const exists = collectionList?.collections?.some((c) =>
c.$id.toLocaleLowerCase().includes(search.toLocaleLowerCase())
);

Expand All @@ -157,17 +159,15 @@
name="one"
value="one"
icon={IconArrowSmRight}>
<p>One Relation attribute within this collection</p>
One Relation attribute within this collection
</Card.Selector>
<Card.Selector
title="Two-way relationship"
bind:group={way}
name="two"
value="two"
icon={IconSwitchHorizontal}>
<p>
One Relation attribute within this collection and another within the related collection
</p>
One Relation attribute within this collection and another within the related collection
</Card.Selector>
</Layout.Stack>

Expand All @@ -179,6 +179,7 @@
bind:value={data.relatedCollection}
on:change={updateKeyName}
options={collections?.map((n) => ({ value: n.$id, label: `${n.name} (${n.$id})` })) ?? []} />

{#if data?.relatedCollection}
<InputText
id="key"
Expand Down Expand Up @@ -207,14 +208,15 @@
placeholder="Select a relation"
options={relationshipType}
disabled={editing} />

<div class="u-flex u-flex-vertical u-gap-16">
<Box>
<div class="u-flex u-align u-cross-center u-main-center u-gap-32">
<span data-private>{camelize($collection.name)}</span>
{#if data.twoWay}
<img src={arrowTwo} alt={'Two way relationship'} />
{:else}
<img src={arrowOne} alt={'One way realationship'} />
<img src={arrowOne} alt={'One way relationship'} />
{/if}
<span>{data.key}</span>
</div>
Expand Down
Loading