Skip to content
Draft
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
3 changes: 2 additions & 1 deletion src/lib/stores/preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ function createPreferences() {
loadTeamPrefs: loadTeamPreferences,

getDisplayNames: (tableId: string) => {
return teamPreferences?.displayNames?.[tableId] ?? ['$id'];
const names = teamPreferences?.displayNames?.[tableId];
return Array.isArray(names) && names.length > 0 ? names : ['$id'];
},

setDisplayNames: async (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
tables: []
});

const sortedTables = $derived.by(() => tables?.tables);
const sortedTables = $derived.by(() =>
tables?.tables?.slice().sort((a, b) => a.name.localeCompare(b.name))
);

const selectedTable = $derived.by(() =>
sortedTables?.find((table: Models.Table) => table.$id === tableId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,24 @@
}
}

function getRelationshipTypeForColumn(column: Columns): string | null {
if (!isRelationship(column)) {
return null;
}

const relationshipMap = {
oneToOne: 'One to one',
oneToMany: 'One to many',
manyToOne: 'Many to one',
manyToMany: 'Many to many'
};

const relationType = (column as Models.ColumnRelationship).relationType;
const formattedType = relationshipMap[relationType] || relationType;

return `Type: ${formattedType}`;
}

onDestroy(() => ($showCreateColumnSheet.show = false));

$effect(() => {
Expand Down Expand Up @@ -222,7 +240,6 @@
<Spreadsheet.Header.Cell column="actions" {root} />
</svelte:fragment>

<!-- TODO: variable and terminology changes -->
{#each updatedColumnsForSheet as column, index}
{@const option = columnOptions.find((option) => option.type === column.type)}
{@const isSelectable =
Expand Down Expand Up @@ -290,12 +307,19 @@
</Layout.Stack>
</Layout.Stack>
{@const minMaxSize = getMinMaxSizeForColumn(column)}
{@const relationType = getRelationshipTypeForColumn(column)}
{#if minMaxSize}
<Typography.Caption
variant="400"
color="--fgcolor-neutral-tertiary">
{minMaxSize}
</Typography.Caption>
{:else if relationType}
<Typography.Caption
variant="400"
color="--fgcolor-neutral-tertiary">
{relationType}
</Typography.Caption>
{/if}
</Layout.Stack>
</Spreadsheet.Cell>
Expand Down