|
3 | 3 | import * as Tooltip from "$lib/components/ui/tooltip" |
4 | 4 | import { ImagesIcon } from "lucide-svelte" |
5 | 5 |
|
6 | | - import { FieldIdVo, type RecordDO, type AttachmentField, AttachmentFieldValue, type Field } from "@undb/table" |
| 6 | + import { |
| 7 | + FieldIdVo, |
| 8 | + type RecordDO, |
| 9 | + type AttachmentField, |
| 10 | + AttachmentFieldValue, |
| 11 | + type Field, |
| 12 | + ViewColor, |
| 13 | + } from "@undb/table" |
7 | 14 | import { queryParam } from "sveltekit-search-params" |
8 | 15 | import { getTable } from "$lib/store/table.store" |
9 | 16 | import FieldValue from "../field-value/field-value.svelte" |
| 17 | + import { getBgColor } from "../grid-view/grid-view.util" |
| 18 | + import { cn } from "$lib/utils" |
10 | 19 |
|
11 | 20 | const table = getTable() |
12 | 21 | export let record: RecordDO |
|
21 | 30 | let field = $table.schema.getFieldById(new FieldIdVo(fieldId)).into(undefined) as AttachmentField | undefined |
22 | 31 | $: fieldValues = record.getValue(new FieldIdVo(fieldId)).into(undefined) as AttachmentFieldValue | undefined |
23 | 32 | $: images = fieldValues?.getImages() ?? [] |
| 33 | +
|
| 34 | + export let color: ViewColor | undefined |
| 35 | + $: colorSpec = color?.getSpec($table.schema).into(undefined) |
| 36 | + $: isMatch = colorSpec ? record.match(colorSpec) : false |
| 37 | + $: condition = isMatch ? color?.getMatchedFieldConditions($table, record)[0] : undefined |
24 | 38 | </script> |
25 | 39 |
|
26 | 40 | <div class="group col-span-1 flex flex-col rounded-md border shadow-sm transition-all hover:shadow-lg"> |
|
41 | 55 | <ImagesIcon class="text-muted-foreground/50 h-10 w-10" /> |
42 | 56 | </div> |
43 | 57 | {/if} |
44 | | - <button on:click={() => ($r = record.id.value)} class="flex flex-1 flex-col space-y-2 px-2 py-3"> |
| 58 | + <button |
| 59 | + on:click={() => ($r = record.id.value)} |
| 60 | + class={cn("relative flex flex-1 flex-col space-y-2 px-2 py-3", isMatch && "pl-3")} |
| 61 | + > |
| 62 | + {#if isMatch} |
| 63 | + <div class={cn("absolute left-0 top-0 h-full w-1", condition && getBgColor(condition.option.color))}></div> |
| 64 | + {/if} |
45 | 65 | {#each fields.filter((f) => f.id.value !== fieldId) as field} |
46 | 66 | <div class="flex w-full"> |
47 | 67 | <FieldValue |
|
0 commit comments