Skip to content

Commit

Permalink
fix: fix ui
Browse files Browse the repository at this point in the history
  • Loading branch information
nichenqin committed Sep 11, 2024
1 parent 940eb3c commit 545dc80
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
let records = recordsStore.records
</script>

<div class="grid h-full w-full gap-4 overflow-y-auto md:grid-cols-5">
<div class="grid w-full gap-4 overflow-y-auto md:grid-cols-5">
{#each $records as record (record.id.value)}
<GalleryViewCard {record} {fieldId} {fields} />
{/each}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { FieldIdVo } from "@undb/table"
import SelectKanbanRequiresSingle from "./select-kanban-requires-single.svelte"
import KanbanOptionButton from "./kanban-option-button.svelte"
import { createRecordsStore, setRecordsStore } from "$lib/store/records.store"
const table = getTable()
export let viewId: Readable<string>
Expand All @@ -16,10 +17,15 @@
$: view = $table.views.getViewById($viewId) as KanbanView
$: fieldId = view.type === "kanban" ? view.field.into(undefined) : undefined
$: field = fieldId ? $table.schema.getFieldById(new FieldIdVo(fieldId)).into(undefined) : undefined
const recordsStore = createRecordsStore()
setRecordsStore(recordsStore)
</script>

<TableTools>
<KanbanOptionButton {view} />
{#if !shareId}
<KanbanOptionButton {view} />
{/if}
</TableTools>
{#if view.type === "kanban"}
{#if field?.type === "select"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import { cn } from "$lib/utils"
import { kanbanStore } from "$lib/store/kanban.store"
import SelectKanbanCollapsedLane from "./select-kanban-collapsed-lane.svelte"
import { queryParam } from "sveltekit-search-params"
const table = getTable()
const recordsStore = getRecordsStore()
Expand All @@ -58,10 +59,13 @@
$: color = view.color.into(undefined)
const q = queryParam("q")
const getRecords = ({ pageParam = 1 }) => {
if (shareId) {
return trpc.shareData.records.query({
shareId,
q: $q,
filters: {
conjunction: "and",
children: [{ field: fieldId, op: "eq", value: option ? option.id : null }],
Expand All @@ -76,6 +80,7 @@
return trpc.record.list.query({
tableId,
viewId: $viewId,
q: $q ?? undefined,
filters: {
conjunction: "and",
children: [{ field: fieldId, op: "eq", value: option ? option.id : null }],
Expand All @@ -91,10 +96,10 @@
$: isLaneCollapsed = $getIsLaneCollapsed($viewId, option?.id ?? "") ?? false
const query = createInfiniteQuery(
derived([table, viewId], ([$table, $viewId]) => {
derived([table, viewId, q], ([$table, $viewId, $q]) => {
const view = $table.views.getViewById($viewId)
return {
queryKey: [$table.id.value, $viewId, fieldId, "getRecords", option?.id],
queryKey: [$table.id.value, $viewId, fieldId, "getRecords", option?.id, $q],
queryFn: getRecords,
initialPageParam: 1,
getNextPageParam: (lastPage, pages) => {
Expand Down Expand Up @@ -356,10 +361,12 @@
</div>
</div>
<div class="mt-2 flex w-full items-center justify-between px-2 py-0.5">
<Button variant="outline" size="xs" on:click={onCreateRecord}>
<PlusIcon class="text-muted-foreground mr-2 h-3 w-3 font-semibold" />
New Record
</Button>
{#if !shareId}
<Button variant="outline" size="xs" on:click={onCreateRecord}>
<PlusIcon class="text-muted-foreground mr-2 h-3 w-3 font-semibold" />
New Record
</Button>
{/if}

{#if $query.isFetchedAfterMount}
<p class="text-muted-foreground text-xs">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import * as Popover from "$lib/components/ui/popover"
import OptionEditor from "../option/option-editor.svelte"
import { invalidate } from "$app/navigation"
import { createRecordsStore, setRecordsStore } from "$lib/store/records.store"
const table = getTable()
Expand Down Expand Up @@ -96,17 +95,13 @@
},
})
}
const recordsStore = createRecordsStore()
setRecordsStore(recordsStore)
</script>

<div class="flex-1 overflow-x-auto overflow-y-hidden p-4">
<div bind:this={lanesContainer} class="flex h-full space-x-2 overflow-y-hidden pr-2">
<SelectKanbanLane {field} {readonly} tableId={$table.id.value} {viewId} {fieldId} option={null} {shareId} {view} />
{#each options as option (option.id)}
<SelectKanbanLane {field} {readonly} tableId={$table.id.value} {viewId} {fieldId} {option} {shareId} {view} />

{/each}
{#if !shareId}
<div class="flex w-[350px] shrink-0 flex-col space-y-2 rounded-sm px-2 pt-2 transition-all">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<script lang="ts">
import type { Readable } from "svelte/store"
import GalleryView from "../gallery-view/gallery-view.svelte"
export let viewId: Readable<string>
export let shareId: string
</script>

<GalleryView {shareId} {viewId} />
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import ShareGridView from "./share-grid-view.svelte"
import { getTable } from "$lib/store/table.store"
import ShareKanbanView from "./share-kanban-view.svelte"
import ShareGalleryView from "./share-gallery-view.svelte"
const table = getTable()
export let viewId: Readable<string>
Expand All @@ -15,4 +16,6 @@
<ShareGridView {viewId} />
{:else if view.type === "kanban"}
<ShareKanbanView {viewId} {shareId} />
{:else if view.type === "gallery"}
<ShareGalleryView {viewId} {shareId} />
{/if}
3 changes: 3 additions & 0 deletions apps/frontend/src/routes/(share)/s/v/[shareId]/+layout.gql
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ query GetViewShareData($shareId: ID!) {
kanban {
field
}
gallery {
field
}
}
schema {
constraint
Expand Down
8 changes: 0 additions & 8 deletions packages/i18n/src/i18n/i18n-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,6 @@ type RootTranslation = {
* K​a​n​b​a​n
*/
kanban: string
/**
* G​a​l​l​e​r​y
*/
gallery: string
}
}
}
Expand Down Expand Up @@ -770,10 +766,6 @@ export type TranslationFunctions = {
* Kanban
*/
kanban: () => LocalizedString
/**
* Gallery
*/
gallery: () => LocalizedString
}
}
}
Expand Down

0 comments on commit 545dc80

Please sign in to comment.