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 @@ -10,11 +10,13 @@
row = $bindable(null),
onChange = null,
onRevert = null,
noInlineEdit = false,
openSideSheet = null,
onRowStructureUpdate = null
}: {
row: Models.Row;
column: Columns;
noInlineEdit?: boolean;
openSideSheet?: () => void;
onChange?: (row: Models.DefaultRow) => void;
onRevert?: (row: Models.DefaultRow) => void;
Expand All @@ -27,6 +29,11 @@
onMount(() => {
original = structuredClone(row);

if (noInlineEdit) {
openSideSheet?.();
return;
}

const trigger = wrapperEl.querySelector('button.input') as HTMLButtonElement;
if (trigger) {
trigger.click();
Expand Down Expand Up @@ -62,5 +69,5 @@
fromSpreadsheet
label={undefined}
bind:formValues={row}
on:click={openSideSheet} />
on:click={() => openSideSheet?.()} />
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
label = undefined;
}
$: if (limited) {
$: {
column.min = isWithinSafeRange(column.min) ? column.min : Number.MIN_SAFE_INTEGER;
column.max = isWithinSafeRange(column.max) ? column.max : Number.MAX_SAFE_INTEGER;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ import { page } from '$app/state';
import type { Columns } from '../store';
import { type Models, Query } from '@appwrite.io/console';

export function isRelationshipToMany(column: Models.ColumnRelationship) {
if (!column) return false;
export function isRelationshipToMany(col: Columns) {
if (!col) return false;
if (!isRelationship(col)) return false;

const column = col as Models.ColumnRelationship;

if (!column?.relationType) return false;
if (column?.side === 'child') {
return !['oneToOne', 'oneToMany'].includes(column?.relationType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,12 @@
}
}

function openSideSheetForRelationsToMany(tableId: string, rows: string | Models.Row[]) {
$databaseRelatedRowSheetOptions.tableId = tableId;
$databaseRelatedRowSheetOptions.rows = rows;
$databaseRelatedRowSheetOptions.show = true;
}

async function onSelectSheetOption(
action: HeaderCellAction | RowCellAction,
columnId: string,
Expand Down Expand Up @@ -885,18 +891,10 @@
{/if}
{:else}
{@const itemsNum = row[columnId]?.length}
<Button.Button
variant="extra-compact"
disabled={!itemsNum}
badge={itemsNum ?? 0}
on:click={() => {
$databaseRelatedRowSheetOptions.show = true;
$databaseRelatedRowSheetOptions.rows =
row[columnId];
$databaseRelatedRowSheetOptions.tableId = columnId;
}}>
Items
</Button.Button>
Items <Badge
content={itemsNum}
variant="secondary"
size="s" />
{/if}
{:else}
{@const value = row[columnId]}
Expand Down Expand Up @@ -946,11 +944,20 @@
{row}
column={rowColumn}
onRowStructureUpdate={updateRowContents}
noInlineEdit={isRelationshipToMany(rowColumn)}
onChange={(row) => paginatedRows.update(index, row)}
onRevert={(row) => paginatedRows.update(index, row)}
openSideSheet={() => {
close(); /* closes the editor */
onSelectSheetOption('update', null, 'row', row);

if (isRelationshipToMany(rowColumn)) {
openSideSheetForRelationsToMany(
columnId,
row[columnId]
);
} else {
onSelectSheetOption('update', null, 'row', row);
}
}} />
</svelte:fragment>
</Spreadsheet.Cell>
Expand Down