-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
41 changed files
with
450 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,7 @@ enum FieldType { | |
id | ||
json | ||
longText | ||
number | ||
rating | ||
reference | ||
|
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
8 changes: 8 additions & 0 deletions
8
apps/frontend/src/lib/components/blocks/field-control/long-text-control.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,8 @@ | ||
<script lang="ts"> | ||
import Textarea from "$lib/components/ui/textarea/textarea.svelte" | ||
export let value: string | ||
export let readonly = false | ||
</script> | ||
|
||
<Textarea rows={5} bind:value {...$$restProps} on:change disabled={readonly} /> |
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
42 changes: 42 additions & 0 deletions
42
apps/frontend/src/lib/components/blocks/field-options/long-text-field-option.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,42 @@ | ||
<script lang="ts"> | ||
import Checkbox from "$lib/components/ui/checkbox/checkbox.svelte" | ||
import Input from "$lib/components/ui/input/input.svelte" | ||
import { Label } from "$lib/components/ui/label/index.js" | ||
import Separator from "$lib/components/ui/separator/separator.svelte" | ||
import * as Alert from "$lib/components/ui/alert/index.js" | ||
import { StringFieldConstraint, type ILongTextFieldConstraint, type IStringFieldConstraint } from "@undb/table" | ||
export let constraint: ILongTextFieldConstraint | undefined | ||
export let defaultValue: string | undefined | ||
$: c = constraint ? new StringFieldConstraint(constraint) : undefined | ||
$: isDefaultValueValid = c && defaultValue ? c.schema.safeParse(defaultValue).success : true | ||
</script> | ||
|
||
<div class="space-y-2"> | ||
<div class="space-y-1"> | ||
<Label for="defaultValue" class="text-xs font-normal">Default value</Label> | ||
<Input | ||
id="defaultValue" | ||
class="bg-background flex-1 text-xs" | ||
placeholder="Default value..." | ||
bind:value={defaultValue} | ||
/> | ||
</div> | ||
{#if !isDefaultValueValid} | ||
<Alert.Root class="mt-2 border-yellow-500 bg-yellow-50"> | ||
<Alert.Title>Invalid default value</Alert.Title> | ||
<Alert.Description>Your default value is invalid. Default value will not be saved.</Alert.Description> | ||
</Alert.Root> | ||
{/if} | ||
{#if constraint} | ||
<div class="pt-2"> | ||
<Separator /> | ||
</div> | ||
<div class="flex items-center space-x-2"> | ||
<Checkbox id="required" bind:checked={constraint.required} /> | ||
<Label for="required" class="text-xs font-normal">Mark as required field.</Label> | ||
</div> | ||
{/if} | ||
</div> |
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
12 changes: 12 additions & 0 deletions
12
apps/frontend/src/lib/components/blocks/field-value/long-text-field.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,12 @@ | ||
<script lang="ts"> | ||
export let value: string | undefined = undefined | ||
export let placeholder: string | undefined = undefined | ||
</script> | ||
|
||
{#if !value} | ||
<div> | ||
{placeholder || ""} | ||
</div> | ||
{:else} | ||
<div class={$$restProps.class}>{value}</div> | ||
{/if} |
66 changes: 66 additions & 0 deletions
66
apps/frontend/src/lib/components/blocks/grid-view/editable-cell/long-text-cell.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,66 @@ | ||
<script lang="ts"> | ||
import { trpc } from "$lib/trpc/client" | ||
import { cn } from "$lib/utils" | ||
import { createMutation } from "@tanstack/svelte-query" | ||
import type { LongTextField, StringField } from "@undb/table" | ||
import { toast } from "svelte-sonner" | ||
import { gridViewStore } from "../grid-view.store" | ||
export let tableId: string | ||
export let field: LongTextField | ||
export let value: string | ||
export let recordId: string | ||
export let isEditing: boolean | ||
export let readonly: boolean | ||
export let onValueChange: (value: string) => void | ||
const updateCell = createMutation({ | ||
mutationKey: ["record", tableId, field.id.value, recordId], | ||
mutationFn: trpc.record.update.mutate, | ||
onSuccess(data, variables, context) { | ||
el?.blur() | ||
gridViewStore.exitEditing() | ||
onValueChange(value) | ||
}, | ||
onError(error: Error) { | ||
toast.error(error.message) | ||
}, | ||
}) | ||
let el: HTMLTextAreaElement | ||
$: if (isEditing) { | ||
if (el) { | ||
el.focus() | ||
} | ||
} | ||
</script> | ||
|
||
{#if isEditing} | ||
<div class="absolute -bottom-10 left-0 right-0 top-0"> | ||
<textarea | ||
rows={3} | ||
bind:this={el} | ||
bind:value | ||
on:blur={() => { | ||
gridViewStore.exitEditing() | ||
}} | ||
class={cn( | ||
$$restProps.class, | ||
"focus-visible:ring-ring h-full w-full rounded-none border px-2 text-xs outline-none focus:bg-white", | ||
)} | ||
on:change={() => { | ||
$updateCell.mutate({ | ||
tableId, | ||
id: recordId, | ||
values: { [field.id.value]: value }, | ||
}) | ||
}} | ||
/> | ||
</div> | ||
{:else} | ||
<div class={cn("truncate", $$restProps.class)}> | ||
{#if value} | ||
{value} | ||
{/if} | ||
</div> | ||
{/if} |
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 |
---|---|---|
|
@@ -83,6 +83,7 @@ export class Graphql { | |
enum FieldType { | ||
string | ||
longText | ||
number | ||
rating | ||
|
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
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
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
Oops, something went wrong.