-
-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2146 from undb-io/release/v1.0.0-121
Release version v1.0.0-121
- Loading branch information
Showing
83 changed files
with
2,215 additions
and
416 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
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
115 changes: 115 additions & 0 deletions
115
apps/frontend/src/lib/components/blocks/calendar-view/calendar-timescale-picker.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,115 @@ | ||
<script lang="ts"> | ||
import Check from "svelte-radix/Check.svelte" | ||
import CaretSort from "svelte-radix/CaretSort.svelte" | ||
import { tick } from "svelte" | ||
import * as Command from "$lib/components/ui/command/index.js" | ||
import * as Popover from "$lib/components/ui/popover/index.js" | ||
import * as Tooltip from "$lib/components/ui/tooltip" | ||
import { Button } from "$lib/components/ui/button/index.js" | ||
import { cn } from "$lib/utils.js" | ||
import { LL } from "@undb/i18n/client" | ||
import { calendarTimeScales, type CalendarTimeScale, type CalendarView } from "@undb/table" | ||
import { createMutation } from "@tanstack/svelte-query" | ||
import { trpc } from "$lib/trpc/client" | ||
import { toast } from "svelte-sonner" | ||
import { getTable } from "$lib/store/table.store" | ||
import { invalidate } from "$app/navigation" | ||
import { type ICalendarViewDTO } from "@undb/table" | ||
export let view: CalendarView | ||
const table = getTable() | ||
let open = false | ||
let search = "" | ||
$: filtered = calendarTimeScales.filter((scale) => { | ||
const label = $LL.table.timeScales[scale]() ?? scale | ||
return label.toLowerCase().includes(search.toLowerCase()) | ||
}) | ||
$: selected = view.timeScale | ||
$: selectedValue = selected ?? "Select time scale..." | ||
function closeAndFocusTrigger(triggerId: string) { | ||
open = false | ||
tick().then(() => { | ||
document.getElementById(triggerId)?.focus() | ||
}) | ||
} | ||
const updateViewMutation = createMutation({ | ||
mutationFn: trpc.table.view.update.mutate, | ||
mutationKey: ["updateView"], | ||
async onSuccess(data, variables, context) { | ||
await invalidate(`undb:table:${$table.id.value}`) | ||
}, | ||
}) | ||
function onSelect(scale: string) { | ||
view.timeScale = scale as CalendarTimeScale | ||
const json = view.toJSON() as ICalendarViewDTO | ||
$updateViewMutation.mutate({ | ||
tableId: $table.id.value, | ||
viewId: view.id.value, | ||
...json, | ||
calendar: { | ||
...json.calendar, | ||
timeScale: view.timeScale, | ||
}, | ||
}) | ||
} | ||
</script> | ||
|
||
<Popover.Root bind:open let:ids portal="body"> | ||
<Popover.Trigger asChild let:builder={popoverBuilder}> | ||
<Tooltip.Root portal="body"> | ||
<Tooltip.Trigger asChild let:builder> | ||
<Button | ||
size="sm" | ||
builders={[popoverBuilder, builder]} | ||
variant="outline" | ||
role="combobox" | ||
aria-expanded={open} | ||
{...$$restProps} | ||
class={cn("w-full justify-between", $$restProps.class)} | ||
> | ||
<span class="flex items-center overflow-hidden text-ellipsis" title={selectedValue}> | ||
{#if selected} | ||
<slot> | ||
{$LL.table.timeScales[selected]() ?? selected} | ||
</slot> | ||
{/if} | ||
</span> | ||
<CaretSort class="ml-2 h-4 w-4 shrink-0 opacity-50" /> | ||
</Button> | ||
</Tooltip.Trigger> | ||
<Tooltip.Content> | ||
<p>Select time scale</p> | ||
</Tooltip.Content> | ||
</Tooltip.Root> | ||
</Popover.Trigger> | ||
<Popover.Content class="p-0"> | ||
<Command.Root shouldFilter={false}> | ||
<Command.Input bind:value={search} placeholder="Search time scale..." class="h-9" /> | ||
<Command.Empty>No time scale found.</Command.Empty> | ||
<Command.Group class="max-h-[300px] overflow-y-auto"> | ||
{#each filtered as scale} | ||
<Command.Item | ||
value={scale} | ||
onSelect={(value) => { | ||
onSelect(value) | ||
closeAndFocusTrigger(ids.trigger) | ||
}} | ||
> | ||
<Check class={cn("mr-2 h-4 w-4", selected !== scale && "text-transparent")} /> | ||
<span class="text-xs"> | ||
{$LL.table.timeScales[scale]() ?? scale} | ||
</span> | ||
</Command.Item> | ||
{/each} | ||
</Command.Group> | ||
</Command.Root> | ||
</Popover.Content> | ||
</Popover.Root> |
Oops, something went wrong.