-
-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
177 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
apps/frontend/src/lib/components/blocks/record-detail/share-record-detail-sheet.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<script lang="ts"> | ||
import { queryParam, ssp } from "sveltekit-search-params" | ||
import { getTable, viewId } from "$lib/store/table.store" | ||
import { trpc } from "$lib/trpc/client" | ||
import { createQuery } from "@tanstack/svelte-query" | ||
import { RecordDO } from "@undb/table" | ||
import { derived } from "svelte/store" | ||
import { preferences } from "$lib/store/persisted.store" | ||
import RecordDetailSheet from "./record-detail-sheet.svelte" | ||
import { page } from "$app/stores" | ||
export let readonly = false | ||
const r = queryParam("r", ssp.string(), { pushHistory: false }) | ||
const table = getTable() | ||
const record = createQuery( | ||
derived([table, r, page], ([$table, $recordId, $page]) => ({ | ||
queryKey: [$recordId, "get", $preferences.showHiddenFields], | ||
queryFn: () => { | ||
return trpc.shareData.record.query({ | ||
shareId: $page.params.shareId, | ||
recordId: $recordId!, | ||
}) | ||
}, | ||
enabled: !!$recordId, | ||
})), | ||
) | ||
$: recordDo = $record.data?.record ? RecordDO.fromJSON($table, $record.data?.record) : undefined | ||
</script> | ||
|
||
<RecordDetailSheet {readonly} {recordDo} isLoading={$record.isLoading} /> |
36 changes: 36 additions & 0 deletions
36
apps/frontend/src/lib/components/blocks/record-detail/table-record-detail-sheet.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<script lang="ts"> | ||
import { queryParam, ssp } from "sveltekit-search-params" | ||
import { getTable, viewId } from "$lib/store/table.store" | ||
import { trpc } from "$lib/trpc/client" | ||
import { createQuery } from "@tanstack/svelte-query" | ||
import { RecordDO } from "@undb/table" | ||
import { derived } from "svelte/store" | ||
import { preferences } from "$lib/store/persisted.store" | ||
import RecordDetailSheet from "./record-detail-sheet.svelte" | ||
export let readonly = false | ||
const r = queryParam("r", ssp.string(), { pushHistory: false }) | ||
const table = getTable() | ||
const record = createQuery( | ||
derived([table, r, preferences], ([$table, $recordId, $preferences]) => ({ | ||
queryKey: [$recordId, "get", $preferences.showHiddenFields], | ||
queryFn: () => { | ||
return trpc.record.get.query({ | ||
tableId: $table?.id.value, | ||
id: $recordId!, | ||
select: $preferences.showHiddenFields | ||
? undefined | ||
: $table?.getOrderedVisibleFields($viewId).map((f) => f.id.value), | ||
}) | ||
}, | ||
enabled: !!$recordId, | ||
})), | ||
) | ||
$: recordDo = $record.data?.record ? RecordDO.fromJSON($table, $record.data?.record) : undefined | ||
</script> | ||
|
||
<RecordDetailSheet {readonly} {recordDo} isLoading={$record.isLoading} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Query, type QueryProps } from "@undb/domain" | ||
import { shareIdSchema } from "@undb/share" | ||
import { recordDTO, recordId } from "@undb/table" | ||
import { z } from "@undb/zod" | ||
|
||
export const getShareRecordByIdQuery = z.object({ | ||
shareId: shareIdSchema, | ||
recordId: recordId, | ||
}) | ||
|
||
export type IGetShareRecordByIdQuery = z.infer<typeof getShareRecordByIdQuery> | ||
|
||
export const getShareRecordByIdOutput = z.object({ | ||
record: recordDTO.nullable(), | ||
}) | ||
|
||
export type IGetShareRecordByIdOutput = z.infer<typeof getShareRecordByIdOutput> | ||
|
||
export class GetShareRecordByIdQuery extends Query implements IGetShareRecordByIdQuery { | ||
public readonly shareId: string | ||
public readonly recordId: string | ||
|
||
constructor(props: QueryProps<IGetShareRecordByIdQuery>) { | ||
super() | ||
this.shareId = props.shareId | ||
this.recordId = props.recordId | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
packages/query-handlers/src/handlers/get-share-record-by-id.query-handler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { setContextValue } from "@undb/context/server" | ||
import { queryHandler } from "@undb/cqrs" | ||
import { singleton } from "@undb/di" | ||
import type { IQueryHandler } from "@undb/domain" | ||
import { GetShareRecordByIdQuery, type IGetShareRecordByIdOutput, type IGetShareRecordByIdQuery } from "@undb/queries" | ||
import { injectShareService, type IShareService } from "@undb/share" | ||
import { injectSpaceService, type ISpaceService } from "@undb/space" | ||
|
||
@queryHandler(GetShareRecordByIdQuery) | ||
@singleton() | ||
export class GetShareRecordByIdQueryHandler | ||
implements IQueryHandler<IGetShareRecordByIdQuery, IGetShareRecordByIdOutput> | ||
{ | ||
constructor( | ||
@injectShareService() | ||
private readonly svc: IShareService, | ||
@injectSpaceService() | ||
private readonly spaceService: ISpaceService, | ||
) {} | ||
|
||
async execute(query: IGetShareRecordByIdQuery): Promise<IGetShareRecordByIdOutput> { | ||
const { shareId, recordId } = query | ||
await this.spaceService.setSpaceContext(setContextValue, { shareId }) | ||
const record = await this.svc.getShareRecordById(shareId, recordId) | ||
|
||
return { | ||
record: record.into(null), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters