Skip to content

Commit

Permalink
Merge pull request #2148 from undb-io/release/v1.0.0-122
Browse files Browse the repository at this point in the history
Release version v1.0.0-122
  • Loading branch information
nichenqin authored Nov 19, 2024
2 parents 35f21be + 728e6ab commit 0489040
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 36 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## v1.0.0-122


### 🩹 Fixes

- Fix calendar virtual list ([9c1f422](https://github.com/undb-io/undb/commit/9c1f422))

### ❤️ Contributors

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

## v1.0.0-121


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
$: records = Records.fromJSON($t, rs)
let virtualListEl: HTMLDivElement
let virtualItemEls: HTMLDivElement[] = []
$: color = $viewId ? $t.views.getViewById($viewId)?.color.into(undefined) : undefined
Expand All @@ -127,6 +128,14 @@
estimateSize: () => 60,
overscan: 5,
})
$: items = $virtualizer.getVirtualItems()
$: {
if (virtualItemEls.length) {
virtualItemEls.forEach((el) => $virtualizer.measureElement(el))
}
}
</script>

<div class="flex h-full flex-1 flex-col gap-2 overflow-hidden p-2">
Expand All @@ -146,21 +155,26 @@
<div class="flex-1 overflow-auto" bind:this={virtualListEl}>
{#if !records.isEmpty}
<div style="position: relative; height: {$virtualizer.getTotalSize()}px; width: 100%;">
{#each $virtualizer.getVirtualItems() as row (row.key)}
<div
style="position: absolute; top: 0; left: 0; width: 100%; height: {row.size}px; transform: translateY({row.start}px);"
>
<CalendarViewMonthRecord
{r}
{color}
record={records?.records[row.index]}
{defaultField}
{field}
{shareId}
{readonly}
/>
</div>
{/each}
<div
class="space-y-2"
style="position: absolute; top: 0; left: 0; width: 100%; transform: translateY({items[0]
? items[0].start
: 0}px);"
>
{#each items as row, idx (row.key)}
<div bind:this={virtualItemEls[idx]}>
<CalendarViewMonthRecord
{r}
{color}
record={records?.records[row.index]}
{defaultField}
{field}
{shareId}
{readonly}
/>
</div>
{/each}
</div>
</div>

{#if $getRecords.hasNextPage}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import { invalidate } from "$app/navigation"
import { hasPermission } from "$lib/store/space-member.store"
import { CircleCheckBigIcon } from "lucide-svelte"
import * as Form from "$lib/components/ui/form"
export let readonly = false
Expand All @@ -21,14 +22,19 @@
export let view: CalendarView
let calendar = view.calendar.unwrapOrElse(() => ({ field: undefined, timeScale: "month" }))
const form = superForm(
defaults(
{
tableId: $table.id.value,
viewId: view.id.value,
type: "calendar",
name: view.name.value,
calendar: view.calendar.unwrapOrElse(() => ({ field: undefined })),
calendar: {
...calendar,
timeScale: calendar.timeScale ?? "month",
},
},
zodClient(updateCalendarViewDTO),
),
Expand All @@ -38,15 +44,21 @@
validators: zodClient(updateCalendarViewDTO),
resetForm: false,
invalidateAll: false,
onSubmit(event) {
validateForm({ update: true })
},
onUpdate(event) {
if (!event.form.valid) return
if (!event.form.valid) {
console.log(event.form.errors, event.form.data)
return
}
$updateViewMutation.mutate(event.form.data)
},
},
)
const { enhance, form: formData } = form
const { enhance, form: formData, validateForm } = form
const updateViewMutation = createMutation({
mutationFn: trpc.table.view.update.mutate,
Expand All @@ -62,19 +74,27 @@
<form id="select-calendar-field-form" class="space-y-2" use:enhance>
<div class="grid w-full items-center gap-4">
<div class="flex flex-col space-y-1.5">
<FieldPicker
disabled={readonly}
placeholder="Select a select type field to group calendar lanes"
value={$formData.calendar?.field}
onValueChange={(field) => {
if ($formData.calendar) {
$formData.calendar.field = field
} else {
$formData.calendar = { field }
}
}}
filter={(f) => fields.map((f) => f.id.value).includes(f.id)}
/>
<Form.Field {form} name="calendar.field">
<Form.Control let:attrs>
<Form.Label for="calendar.field">Calendar field</Form.Label>
<FieldPicker
disabled={readonly}
placeholder="Select a select type field to group calendar lanes"
class="w-full"
value={$formData.calendar?.field}
onValueChange={(field) => {
if ($formData.calendar) {
$formData.calendar.field = field
} else {
$formData.calendar = { field }
}
}}
filter={(f) => fields.map((f) => f.id.value).includes(f.id)}
/>
</Form.Control>
<Form.Description />
<Form.FieldErrors />
</Form.Field>
</div>
</div>
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import Checkbox from "$lib/components/ui/checkbox/checkbox.svelte"
import { Label } from "$lib/components/ui/label/index.js"
export let defaultValue: boolean | undefined
export let defaultValue: boolean | undefined = false
export let disabled: boolean | undefined
</script>

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-121",
"version": "1.0.0-122",
"private": true,
"scripts": {
"build": "NODE_ENV=production bun --bun turbo build",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export type ICheckboxFieldDTO = z.infer<typeof checkboxFieldDTO>
export class CheckboxField extends AbstractField<CheckboxFieldValue> {
constructor(dto: ICheckboxFieldDTO) {
super(dto)
if (dto.defaultValue === true) {
this.defaultValue = new CheckboxFieldValue(dto.defaultValue ?? false)
if (typeof dto.defaultValue === "boolean") {
this.defaultValue = new CheckboxFieldValue(dto.defaultValue)
}
}

Expand Down Expand Up @@ -88,6 +88,6 @@ export class CheckboxField extends AbstractField<CheckboxFieldValue> {
}

override getMutationSpec(value: CheckboxFieldValue): Option<RecordComositeSpecification> {
return Some(new CheckboxEqual(value.value, this.id))
return Some(new CheckboxEqual(!!value.value, this.id))
}
}

0 comments on commit 0489040

Please sign in to comment.