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-117 #2136

Merged
merged 17 commits into from
Nov 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Changelog

## v1.0.0-117

## v1.0.0-116


Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ UNDB is a no-code platform that can also serve as a Backend as a Service (BaaS).

![kanban](./docs/images/kanban.jpeg)
![gallery](./docs/images/gallery.jpeg)
![form](./docs/images/form.jpeg)
![calendar](./docs/images/calendar.jpeg)
![pivot](./docs/images/pivot.jpeg)
![form](./docs/images/form.jpeg)
![openapi](./docs/images/openapi.jpeg)

## Quick start
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 19 additions & 1 deletion apps/backend/src/modules/openapi/record.openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { CommandBus, QueryBus } from "@undb/cqrs"
import { inject, singleton } from "@undb/di"
import { Option, type ICommandBus, type IQueryBus, type PaginatedDTO } from "@undb/domain"
import { injectQueryBuilder, type IQueryBuilder } from "@undb/persistence"
import { GetReadableRecordByIdQuery, GetReadableRecordsQuery } from "@undb/queries"
import { GetPivotDataQuery, GetReadableRecordByIdQuery, GetReadableRecordsQuery } from "@undb/queries"
import { RecordDO, type IRecordReadableValueDTO } from "@undb/table"
import Elysia, { t } from "elysia"
import { withTransaction } from "../../db"
Expand Down Expand Up @@ -79,6 +79,24 @@ export class RecordOpenApi {
},
},
)
.get(
"/views/:viewName/data",
async (ctx) => {
const baseName = decodeURIComponent(ctx.params.baseName)
const tableName = decodeURIComponent(ctx.params.tableName)
const viewName = decodeURIComponent(ctx.params.viewName)

return await this.queryBus.execute(new GetPivotDataQuery({ baseName, tableName, viewName }))
},
{
params: t.Object({ baseName: t.String(), tableName: t.String(), viewName: t.String() }),
detail: {
tags: ["Record"],
summary: "Get pivot view data",
description: "Get pivot view data",
},
},
)
.get(
"/views/:viewName/records/:recordId",
async (ctx) => {
Expand Down
9 changes: 9 additions & 0 deletions apps/frontend/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@ type OAuthSettings {
google: OAuthSetting
}

type PivotOption {
aggregate: String
columnLabel: String
rowLabel: String
value: String
}

type Query {
base(id: ID!): Base!
baseByShare(shareId: ID!): Base
Expand Down Expand Up @@ -283,6 +290,7 @@ type View {
kanban: KanbanOption
name: String!
option: ViewOption
pivot: PivotOption
share: Share
shareId: ID
sort: JSON
Expand All @@ -304,6 +312,7 @@ enum ViewType {
grid
kanban
list
pivot
}

type Widget {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@
$endTimestamp?.toISOString(),
],
enabled: view?.type === "calendar" && !!$startTimestamp && !!$endTimestamp && !disableRecordQuery,
queryFn: () =>
trpc.record.list.query({
tableId: $table?.id.value,
queryFn: () => {
if (shareId) {
return trpc.shareData.records.query({
shareId,
tableId: $table?.id.value,
viewId: $viewId,
q: $q ?? undefined,
filters: {
Expand All @@ -51,8 +53,14 @@
{ field: field.id.value, op: "is_after", value: $startTimestamp!.toISOString() },
{ field: field.id.value, op: "is_before", value: $endTimestamp!.toISOString() },
],
},
}),
},
})
}
return trpc.record.list.query({
tableId: $table?.id.value,
viewId: $viewId,
})
},
}
}),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,4 @@
</section>
{/if}
{/if}

{#await import("$lib/components/blocks/create-record/create-record-sheet.svelte") then { default: CreateRecordSheet }}
<CreateRecordSheet />
{/await}

{#await import("$lib/components/blocks/record-detail/table-record-detail-sheet.svelte") then { default: TableRecordDetailSheet }}
<TableRecordDetailSheet {viewId} />
{/await}

{#await import("$lib/components/blocks/view-widget/view-widget-sheet.svelte") then { default: ViewWidgetSheet }}
<ViewWidgetSheet {viewId} {shareId} />
{/await}
{/key}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<script lang="ts">
import * as Select from "$lib/components/ui/select"
import type { IDateFieldMacro } from "@undb/table"
import { isString } from "radash"
import { dateFieldMacros, isDateFieldMacro } from "@undb/table"
import { LL } from "@undb/i18n/client"

export let value: any | undefined = undefined
export let onValueChange: (v: IDateFieldMacro | undefined) => void = () => {}

$: selectedValue =
isString(value) && isDateFieldMacro(value)
? {
label: value,
value,
}
: undefined

const macros = dateFieldMacros.map((v) => ({
label: $LL.table.macros[v](),
value: v,
}))
</script>

<Select.Root
selected={selectedValue}
onSelectedChange={(v) => {
if (v) {
value = v.value
} else {
value = undefined
}

onValueChange(v?.value)
}}
>
<Select.Trigger>
<Select.Value class="text-xs" placeholder="Select a macro..." />
</Select.Trigger>
<Select.Content>
{#each macros as macro}
<Select.Item class="text-xs text-gray-600" value={macro.value}>
{macro.label}
</Select.Item>
{/each}
</Select.Content>
</Select.Root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<script lang="ts">
import type { IDateFieldMacro } from "@undb/table"

export let value: IDateFieldMacro | undefined = undefined
</script>

{#if value}
<span class="rounded-md border-blue-200 bg-blue-100 px-1 py-0.5 text-xs text-blue-500">{value}</span>
{/if}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import { Calendar } from "$lib/components/ui/calendar"
import * as Popover from "$lib/components/ui/popover"
import { isDate, isString } from "radash"
import { DateField } from "@undb/table"
import { DateField, isDateFieldMacro } from "@undb/table"
import DateMacroPicker from "../date/date-macro-picker.svelte"
import DateMacro from "../date/date-macro.svelte"

export let readonly = false
export let disabled = false
Expand All @@ -16,6 +18,8 @@

export let value: string | Date | undefined = undefined
function parse(value: string) {
if (isDateFieldMacro(value)) return value

try {
return parseDate(value)
} catch {
Expand All @@ -38,13 +42,25 @@
>
<CalendarIcon class="mr-2 h-4 w-4" />
{#if value}
{formatter(value)}
{#if isString(value) && isDateFieldMacro(value)}
<DateMacro {value} />
{:else}
{formatter(value)}
{/if}
{/if}
</Button>
</Popover.Trigger>
<Popover.Content class="p-0" side="bottom" align="start">
<div class="p-1">
<DateMacroPicker
onValueChange={() => {
open = false
}}
bind:value
/>
</div>
<Calendar
value={internalDate}
value={isString(internalDate) && isDateFieldMacro(internalDate) ? undefined : internalDate}
onValueChange={(v) => {
if (v) {
value = v.toString()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<script lang="ts">
import { Checkbox } from "$lib/components/ui/checkbox"
import NumberInput from "$lib/components/ui/input/number-input.svelte"
import { Label } from "$lib/components/ui/label/index.js"
import { Separator } from "$lib/components/ui/separator"
import type { IDateFieldConstraint, INumberFieldConstraint } from "@undb/table"
import { isDateFieldMacro, type IDateFieldConstraint } from "@undb/table"
import * as Popover from "$lib/components/ui/popover"
import { Button } from "$lib/components/ui/button"
import { cn } from "$lib/utils"
import { CalendarIcon } from "lucide-svelte"
import { DateFormatter, getLocalTimeZone, parseDate } from "@internationalized/date"
import { isDate, isString } from "radash"
import { Calendar } from "$lib/components/ui/calendar"
import DateMacroPicker from "../date/date-macro-picker.svelte"
import DateMacro from "../date/date-macro.svelte"

const df = new DateFormatter("en-US", {
dateStyle: "long",
Expand All @@ -30,7 +31,9 @@
}
}
$: internalDate = isString(defaultValue)
? parse(defaultValue)
? isDateFieldMacro(defaultValue)
? defaultValue
: parse(defaultValue)
: isDate(defaultValue)
? parseDate(defaultValue.toISOString())
: undefined
Expand All @@ -53,19 +56,31 @@
)}
builders={[builder]}
>
<CalendarIcon class="mr-2 h-4 w-4" />
{#if internalDate}
{df.format(internalDate.toDate(getLocalTimeZone()))}
{#if isString(internalDate) && isDateFieldMacro(internalDate)}
<DateMacro value={internalDate} />
{:else}
<span class="text-muted-foreground text-xs">
{placeholder}
</span>
<CalendarIcon class="mr-2 h-4 w-4" />
{#if internalDate}
{df.format(internalDate.toDate(getLocalTimeZone()))}
{:else}
<span class="text-muted-foreground text-xs">
{placeholder}
</span>
{/if}
{/if}
</Button>
</Popover.Trigger>
<Popover.Content class="p-0" align="start">
<div class="p-1">
<DateMacroPicker
onValueChange={(v) => {
open = false
}}
bind:value={defaultValue}
/>
</div>
<Calendar
value={internalDate}
value={isString(internalDate) && isDateFieldMacro(internalDate) ? undefined : internalDate}
onValueChange={(v) => {
if (v) {
defaultValue = v.toString()
Expand Down
Loading
Loading