Skip to content

Commit

Permalink
fix: fix calendar view share data
Browse files Browse the repository at this point in the history
  • Loading branch information
nichenqin committed Nov 21, 2024
1 parent ce0f563 commit 9286b70
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,22 @@
.otherwise(() => undefined)
return {
queryKey: ["records", $table?.id.value, $viewId, scope, dateString, $search],
queryFn: ({ pageParam = 1 }) =>
trpc.record.list.query({
queryFn: ({ pageParam = 1 }) => {
if (shareId) {
return trpc.shareData.records.query({
shareId,
tableId: $table?.id.value,
viewId: $viewId,
filters: merged,
ignoreView: true,
q: $search,
pagination: {
page: pageParam,
limit: 20,
},
})
}
return trpc.record.list.query({
tableId: $table?.id.value,
viewId: $viewId,
filters: merged,
Expand All @@ -119,7 +133,8 @@
page: pageParam,
limit: 20,
},
}),
})
},
initialPageParam: 1,
getNextPageParam: (lastPage, pages) => {
const current = pages.reduce<number>((acc, cur) => acc + cur.records.length, 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@
export let viewId: Readable<string | undefined>
export let view: CalendarView
export let readonly = false
export let shareId: string | undefined
</script>

<div class="flex justify-between gap-2 border-b px-2 py-2">
<div class="flex items-center gap-2">
<CreateRecordButton size="xs" />
<CalendarViewMiniMonthControl bind:view />
<Button variant="outline" size="xs" on:click={() => calendarStore.reset()}>Today</Button>
<CalendarTimescalePicker size="xs" bind:view />
{#if !shareId}
<CalendarTimescalePicker size="xs" bind:view />
{/if}
</div>

<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</script>

{#key $table.id.value}
<CalendarViewToolbar {viewId} bind:view {readonly} />
<CalendarViewToolbar {viewId} bind:view {readonly} {shareId} />
{#if view.type === "calendar"}
{#if field}
{#if timeScale === "month"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
/>
<FieldFilterControl
class="col-span-8 overflow-hidden"
{disabled}
disabled={disabled || readonly}
{field}
bind:option={child.option}
bind:op={child.op}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,10 @@
value = today(getLocalTimeZone()).toString()
onValueChange(value)
save(value)
}}>Today</Button
}}
>
{includeTime ? "Now" : "Today"}
</Button>
{#if !field.required}
<Button
class="flex-1"
Expand Down

0 comments on commit 9286b70

Please sign in to comment.