Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release version v1.0.0-70 #2023

Merged
merged 4 commits into from
Sep 13, 2024
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
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# Changelog


## v1.0.0-70


### 🩹 Fixes

- Fix share view ([f87cc32](https://github.com/undb-io/undb/commit/f87cc32))

### ❤️ Contributors

- Nichenqin ([@nichenqin](http://github.com/nichenqin))

## v1.0.0-69


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,31 @@
const currentPage = writable(1)
const q = queryParam("q")

const getRecords = createQuery(
const getRecords = () => {
if (shareId) {
return trpc.shareData.records.query({
shareId,
tableId: $table?.id.value,
viewId: $viewId,
q: $q ?? undefined,
pagination: { limit: $perPage, page: $currentPage },
})
}
return trpc.record.list.query({
tableId: $table?.id.value,
viewId: $viewId,
q: $q ?? undefined,
pagination: { limit: $perPage, page: $currentPage },
})
}

const getRecordsQuery = createQuery(
derived([table, viewId, perPage, currentPage, q], ([$table, $viewId, $perPage, $currentPage, $q]) => {
const view = $table.views.getViewById($viewId)
return {
queryKey: ["records", $table?.id.value, $viewId, $q, $currentPage, $perPage],
enabled: view?.type === "gallery",
queryFn: () =>
trpc.record.list.query({
tableId: $table?.id.value,
viewId: $viewId,
q: $q ?? undefined,
pagination: { limit: $perPage, page: $currentPage },
}),
queryFn: getRecords,
}
}),
)
Expand All @@ -44,12 +56,12 @@
setRecordsStore(recordsStore)

// $: records = (($getRecords.data as any)?.records as IRecordsDTO) ?? []
let records = derived([getRecords], ([$getRecords]) => {
let records = derived([getRecordsQuery], ([$getRecords]) => {
return (($getRecords.data as any)?.records as IRecordsDTO) ?? []
})
$: recordsStore.setRecords(Records.fromJSON($table, $records), $getRecords.dataUpdatedAt)
$: recordsStore.setRecords(Records.fromJSON($table, $records), $getRecordsQuery.dataUpdatedAt)

$: total = ($getRecords.data as any)?.total
$: total = ($getRecordsQuery.data as any)?.total
</script>

<TableTools />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@
{#each fields as field}
<div class="flex w-full items-center gap-2">
<Tooltip.Root>
<Tooltip.Trigger class="w-full">
<Tooltip.Trigger class="w-full text-left">
<FieldValue
{field}
tableId={$table.id.value}
recordId={record.id.value}
value={values[field.id.value]}
type={field.type}
displayValue={displayValues[field.id.value]}
class="w-full truncate"
class="w-full truncate text-left"
/>
</Tooltip.Trigger>
<Tooltip.Content>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@
if (shareId) {
return trpc.shareData.records.query({
shareId,
tableId,
viewId: $viewId,
q: $q,
filters: {
conjunction: "and",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<span
data-option-id={option.id}
class={cn(
"inline-flex items-center rounded-md border bg-gray-50 px-2 py-0.5 text-xs font-medium text-gray-600 ring-1 ring-inset ring-gray-500/10",
"inline-flex items-center justify-start rounded-md border bg-gray-50 px-2 py-0.5 text-left text-xs font-medium text-gray-600 ring-1 ring-inset ring-gray-500/10",
getBgColor(option.color),
getTextColor(option.color),
getRingColor(option.color),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<script lang="ts">
import { page } from "$app/stores"
import GridViewDataTable from "$lib/components/blocks/grid-view/grid-view-data-table.svelte"
import { createRecordsStore, setRecordsStore } from "$lib/store/records.store"
import { createRecordsStore, setRecordsStore, type RecordsStore } from "$lib/store/records.store"
import { getTable } from "$lib/store/table.store"
import { trpc } from "$lib/trpc/client"
import { createQuery } from "@tanstack/svelte-query"
import { Records, type IRecordsDTO } from "@undb/table"
import { onMount } from "svelte"
import ShareTableTools from "$lib/components/blocks/table-tools/share-table-tools.svelte"
import { derived, writable, type Readable } from "svelte/store"

export let viewId: Readable<string>
Expand All @@ -21,6 +23,8 @@
queryFn: () =>
trpc.shareData.records.query({
shareId: $page.params.shareId,
tableId: $table.id.value,
viewId: $viewId,
pagination: {
page: $currentPage,
limit: $perPage,
Expand All @@ -32,18 +36,22 @@

$: records = (($getRecords.data as any)?.records as IRecordsDTO) ?? []

let store = createRecordsStore()
setRecordsStore(store)

$: if ($getRecords.isSuccess) {
const store = createRecordsStore()
store.setRecords(Records.fromJSON($t, records), $getRecords.dataUpdatedAt)
setRecordsStore(store)
}
</script>

<GridViewDataTable
{viewId}
readonly
{perPage}
{currentPage}
isLoading={$getRecords.isLoading}
total={$getRecords.data?.total ?? 0}
/>
{#if store}
<ShareTableTools />
<GridViewDataTable
{viewId}
readonly
{perPage}
{currentPage}
isLoading={$getRecords.isLoading}
total={$getRecords.data?.total ?? 0}
/>
{/if}
7 changes: 7 additions & 0 deletions apps/frontend/src/routes/(share)/s/b/[shareId]/+layout.gql
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@ query GetShareBaseData($shareId: ID!) {
views {
id
name
type
isDefault
kanban {
field
}
gallery {
field
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ query GetBaseTableShareData($shareId: ID!, $tableId: ID!) {
name
isDefault
fields
type
kanban {
field
}
gallery {
field
}
}
schema {
constraint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
const table = writable<TableDo>()
$: {
if (!fetching && tableDTO) {
// @ts-ignore
table.set(new TableCreator().fromJSON(tableDTO))
setTable(table)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script lang="ts">
import { page } from "$app/stores"
import GridViewDataTable from "$lib/components/blocks/grid-view/grid-view-data-table.svelte"
import ShareTableTools from "$lib/components/blocks/table-tools/share-table-tools.svelte"
import { getTable } from "$lib/store/table.store"
import { trpc } from "$lib/trpc/client"
import { createQuery } from "@tanstack/svelte-query"
Expand All @@ -13,16 +12,22 @@
import ShareTableHeader from "$lib/components/blocks/table-header/share-table-header.svelte"
import FormsReadonly from "$lib/components/blocks/forms/forms-readonly.svelte"
import { createRecordsStore, setRecordsStore } from "$lib/store/records.store"
import ShareGridView from "$lib/components/blocks/share/share-grid-view.svelte"
import ShareGalleryView from "$lib/components/blocks/share/share-gallery-view.svelte"
import ShareKanbanView from "$lib/components/blocks/share/share-kanban-view.svelte"

let RecordDetailSheet: ComponentType

let viewId = derived(page, (page) => page.params.viewId)
let shareId = derived(page, (page) => page.params.shareId)
onMount(async () => {
RecordDetailSheet = (await import("$lib/components/blocks/record-detail/share-record-detail-sheet.svelte")).default
})

const t = getTable()

$: view = $t.views.getViewById($viewId)

const perPage = writable(50)
const currentPage = writable(1)
const q = queryParam("q")
Expand All @@ -44,26 +49,24 @@

$: records = (($getRecords.data as any)?.records as IRecordsDTO) ?? []

const store = createRecordsStore()
setRecordsStore(store)
$: if ($getRecords.isSuccess) {
const store = createRecordsStore()
store.setRecords(Records.fromJSON($t, records), $getRecords.dataUpdatedAt)
setRecordsStore(store)
}
</script>

<div class="flex flex-1 flex-col">
<ShareTableHeader />
<ShareTableTools />

{#if $isDataTab}
<GridViewDataTable
{viewId}
readonly
{perPage}
{currentPage}
isLoading={$getRecords.isLoading}
total={$getRecords.data?.total ?? 0}
/>
{#if view?.type === "grid"}
<ShareGridView {viewId} />
{:else if view.type === "kanban"}
<ShareKanbanView {viewId} shareId={$shareId} />
{:else if view.type === "gallery"}
<ShareGalleryView {viewId} shareId={$shareId} />
{/if}
{:else if $isFormTab}
<FormsReadonly />
{/if}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "undb",
"version": "1.0.0-69",
"version": "1.0.0-70",
"private": true,
"scripts": {
"build": "NODE_ENV=production bun --bun turbo build",
Expand Down
8 changes: 8 additions & 0 deletions packages/i18n/src/i18n/i18n-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,10 @@ type RootTranslation = {
* K​a​n​b​a​n
*/
kanban: string
/**
* G​a​l​l​e​r​y
*/
gallery: string
}
}
}
Expand Down Expand Up @@ -766,6 +770,10 @@ export type TranslationFunctions = {
* Kanban
*/
kanban: () => LocalizedString
/**
* Gallery
*/
gallery: () => LocalizedString
}
}
}
Expand Down
Loading