diff --git a/mathesar_ui/src/api/rpc/records.ts b/mathesar_ui/src/api/rpc/records.ts index e82f8adf3e..8a8123f06a 100644 --- a/mathesar_ui/src/api/rpc/records.ts +++ b/mathesar_ui/src/api/rpc/records.ts @@ -1,5 +1,7 @@ import { rpcMethodTypeContainer } from '@mathesar/packages/json-rpc-client-builder'; +import type { RecordSummaryTemplate } from './tables'; + export type ResultValue = string | number | boolean | null; export type SortDirection = 'asc' | 'desc'; @@ -130,6 +132,16 @@ export const records = { table_oid: number; record_id: ResultValue; return_record_summaries?: boolean; + /** + * Keys are stringified table OIDs. Values are record summary templates + * that will override the templates stored in table metadata. These + * overrides can be used to render a of a record summary using an + * ephemeral template before any template is stored. + * */ + table_record_summary_templates?: Record< + string, + RecordSummaryTemplate | null + > | null; }, RecordsResponse >(), diff --git a/mathesar_ui/src/api/rpc/tables.ts b/mathesar_ui/src/api/rpc/tables.ts index d2d392380d..f9f0f774f0 100644 --- a/mathesar_ui/src/api/rpc/tables.ts +++ b/mathesar_ui/src/api/rpc/tables.ts @@ -32,6 +32,17 @@ export interface RawTablePrivilegesForRole { direct: TablePrivilege[]; } +/** + * A string is static text to be displayed in the summary. + * + * An array of numbers indicates a reference to a column in the table. Each + * number is a column attnum. A sequence of multiple numbers indicates a chain + * of FK references, column-by-column. + * + */ +export type RecordSummaryTemplatePart = string | number[]; +export type RecordSummaryTemplate = RecordSummaryTemplatePart[]; + interface TableMetadata { /** The id of the data file used during import while creating the table */ data_file_id: number | null; @@ -45,8 +56,7 @@ interface TableMetadata { */ import_verified: boolean | null; column_order: number[] | null; - record_summary_customized: boolean | null; - record_summary_template: string | null; + record_summary_template: RecordSummaryTemplate | null; } export interface RawTableWithMetadata extends RawTable { diff --git a/mathesar_ui/src/component-library/fieldset-group/FieldsetGroup.scss b/mathesar_ui/src/component-library/fieldset-group/FieldsetGroup.scss index 1e909b82a5..e895c5de1d 100644 --- a/mathesar_ui/src/component-library/fieldset-group/FieldsetGroup.scss +++ b/mathesar_ui/src/component-library/fieldset-group/FieldsetGroup.scss @@ -1,48 +1,32 @@ -.fieldset-group { - padding: 0; - margin: 0; +.fieldset-group-options { --spacing-y-default: 0.5em; --spacing-x-default: 1em; + padding-left: 0; + list-style-type: none; + margin-top: 0.25em; + margin-bottom: 0; - legend { - padding: 0; - font-weight: var(--font-weight-medium); - margin-bottom: 0.5rem; - } - .options { - padding-left: 0; - list-style-type: none; - margin-top: 0.25em; - margin-bottom: 0; - } - &.has-label .options { + &.has-fieldset-label { margin-top: 1em; } - &:not(.inline) .option:not(:first-child) { - margin-top: var(--spacing-y, var(--spacing-y-default)); - } - &:not(.inline) .option:not(:last-child) { - margin-bottom: var(--spacing-y, var(--spacing-y-default)); - } - &:not(.inline) .option.has-help:not(:last-child) { - margin-bottom: calc(2 * var(--spacing-y, var(--spacing-y-default))); + + &:not(.inline) { + .option:not(:first-child) { + margin-top: var(--spacing-y, var(--spacing-y-default)); + } + .option:not(:last-child) { + margin-bottom: var(--spacing-y, var(--spacing-y-default)); + } + .option.has-help:not(:last-child) { + margin-bottom: calc(2 * var(--spacing-y, var(--spacing-y-default))); + } } - &.inline .options { + &.inline { display: flex; flex-wrap: wrap; .option:not(:last-child) { margin-right: var(--spacing-x, var(--spacing-x-default)); } } - - &:not(.boxed) { - border: 0; - } - &.boxed { - border: 1px solid var(--slate-300); - border-radius: var(--border-radius-m); - padding: 1em; - padding-top: 0; - } } diff --git a/mathesar_ui/src/component-library/fieldset-group/FieldsetGroup.svelte b/mathesar_ui/src/component-library/fieldset-group/FieldsetGroup.svelte index 2d2c1d55f5..2885999942 100644 --- a/mathesar_ui/src/component-library/fieldset-group/FieldsetGroup.svelte +++ b/mathesar_ui/src/component-library/fieldset-group/FieldsetGroup.svelte @@ -9,11 +9,12 @@ import Render from '@mathesar-component-library-dir/render/Render.svelte'; import StringOrComponent from '@mathesar-component-library-dir/string-or-component/StringOrComponent.svelte'; + import Fieldset from '../fieldset/Fieldset.svelte'; import type { ComponentWithProps } from '../types'; type Option = $$Generic; - export let isInline = false; + export let isInline: boolean | undefined = undefined; export let options: readonly Option[] = []; export let label: string | undefined = undefined; export let ariaLabel: string | undefined = undefined; @@ -21,28 +22,20 @@ export let labelKey = 'label'; export let getLabel: LabelGetter