Ga naar hoofdinhoud

CnObjectCard

Schema-driven card for displaying an object's key information. Uses schema configuration to determine which fields to show as title, description, image, and metadata.

Wraps: NcCheckboxRadioSwitch, CnCellRenderer

Try it​

Loading CnObjectCard playground…

CnObjectCard showing client data in card layout

Props​

PropTypeDefaultDescription
objectObject(required)Object data
schemaObject(required)Schema with properties and configuration
selectedBooleanfalseSelection state
pillLooksObject{}The referenced records' colour and icon names, by field and id ({ [field]: { [id]: { color, icon } } }, read by CnIndexPage). A record layout pill with resolve: { colorField?, iconField? } takes its record's tone and icon from here.
selectableBooleanfalseShow selection checkbox
cardFieldColumnsObjectnullThe page's columns by key: a fact or a layout part whose field names a column reads through that column's label, formatter and widget, as the table does
clickToViewBooleanfalseBody click on a selectable card emits click (navigation) instead of toggling selection — the checkbox stays the only selection surface (the card counterpart of a table's rowClickToView)
maxMetadataNumber4Max metadata fields shown
accentObjectnullStatus accent { variant, icon?, label? }: a 4px start border in the variant color (success, warning, error, info, primary) and, with icon (a CnIcon name), a colored icon before the title. label is the icon's tooltip and accessible name. An unknown variant draws nothing.

Schema Configuration Keys​

The schema's configuration object controls card layout:

KeyDescription
objectNameFieldField used as card title
objectDescriptionFieldField used as description text
objectImageFieldField containing the image, resolved through resolveImageUrl (an app:<app>/<file> reference or an /apps/… route becomes a real URL; an absolute URL is used as-is)
objectSummaryFieldField used as summary

Events​

EventPayloadDescription
aux-click(object, event)Card middle-clicked (auxclick), under the same conditions as a navigating click. The second argument is the native event, for opening the card in a new tab.
click(object, event)Card clicked. The second argument is the native event, for opening the card in a new tab on a ctrl/cmd/shift click; a middle click emits aux-click instead. When selectable is false this is the primary navigation event. When selectable is true a deliberate click emits select (a text-selection drag is not treated as a click); for backwards compatibility click is also emitted (with a console.warn deprecation notice) if a @click listener is present — migrate selectable consumers to @select.
selectobjectSelection toggled — emitted by the checkbox, and (when selectable) by a deliberate click anywhere on the card body.

Slots​

SlotScopeDescription
#badges\{ object \}Badge section
#actions\{ object \}Actions section
#metadata\{ object, fields \}Metadata section override

Usage​

<CnObjectCard
:object="contact"
:schema="contactSchema"
:selectable="true"
@click="onCardClick"
@select="onSelect" />

Reference (auto-generated)​

The tables below are generated from the SFC source via vue-docgen-cli. They reflect what's actually in CnObjectCard.vue and update automatically whenever the component changes.

OpenRegister reliance​

heavy: this component cannot work without OpenRegister. 0 direct references, 16 files reached through imports.

Through: CnActionDialog, CnAssignDialog, CnBulkJobProgress, CnCellRenderer, CnFkResolveCell, CnIndexPage.

See the reliance overview for the filterable list.

Props​

NameTypeRequiredDefaultDescription
objectobject✓—The object data
schemaobject✓—Schema definition with properties and configuration
selectedbooleanfalseWhether this card is selected
selectablebooleanfalseWhether to show selection checkbox
clickToViewbooleanfalseWhen true, a body click on a SELECTABLE card emits click (navigation) instead of toggling selection — selection then happens via the checkbox only. The card counterpart of CnIndexPage's rowClickToView (a table row click already navigates in that mode).
status(string&#124;{label: string, variant?: string})nullBoard look: the status pill at the end of the head row, as a label ("Open") or { label, variant } with a CnStatusBadge variant (success, warning, error, info, primary, default). Without it the head row ends in the row menu, when there is one.
leading{initials?: string, icon?: string}nullBoard look: the leading element of the head row. { initials } draws the initials in a 36px circle; { icon } a schema icon in a 36px rounded square on a tint.
footerAction{label: string, meta?: string, ariaLabel?: string}nullBoard look: the card's one footer action. { label, meta?, ariaLabel? }; meta is the 13px muted text at the start of the footer. Clicking emits footer-action.
accent{variant: string, icon?: string, label?: string}nullA status accent: a colored border at the start of the card and, with icon, a colored icon before the title. variant is one of success, warning, error, info or primary; icon is a name registered with CnIcon; label names the status for screen readers and as the icon's tooltip.
layout{headPill?: object, number?: string, title?: string, meta?: Array<string>, description?: (string&#124;{field: string, maxLength?: number}), chips?: Array<object>, note?: {field: string, formatter?: string, formatterOptions?: object, tone?: string}, footerPill?: object, footerDate?: {field: string, label?: string, overdueVariant?: string}}nullBoard look: the record layout (manifest key config.cardLayout). Every part names a field of the object (a dot path) and is left out while that field is empty: { headPill, number, title, meta, footerPill, footerDate }. A pill is { field, colorMap?, labels?, variant? }: colorMap maps a value to a CnStatusBadge variant (ignoring case), labels a value to the text shown. meta is a list of fields, joined with " · ". footerDate is { field, label?, overdueVariant? }, drawn as "Termijn 5 okt", in overdueVariant's tone (error) once the date has passed. description is a field (or { field, maxLength? }, cut at 140 characters by default) drawn under the meta line. chips is a list of { field, formatter?, formatterOptions?, colorMap?, labels?, variant? }, each a pill whose text reads through the formatter; with each a list field gives one pill per entry (each names the entry's field or is a template). A meta part may be { template }, a line filled from the object ('{stages|count} stages'). note is { field, formatter?, formatterOptions?, tone? }, a line under the meta line in the purple or teal pill ink. Without it the card keeps its head, facts and action.
pillLooksobject\{\}The referenced records' colour and icon names, by field and id ({ [field]: { [id]: { color, icon } } }, CnIndexPage reads them). A record layout pill with resolve: { colorField?, iconField? } takes its record's tone and icon from here.
cardFieldsArray<string>nullThe property keys the facts list shows, in order (manifest key config.cardFields). Without it the card shows the first maxMetadata visible properties, as before.
cardFieldColumnsobjectnullThe page's columns by key: a fact whose key names a column renders through that column's label, formatter and widget, as the table does.
maxMetadatanumber4Maximum number of metadata fields to show

Events​

NamePayloadDescription
select—Emitted when the card toggles selection (clicking the body of a selectable card, or its checkbox).
footer-action—
clickundefinedEmitted when a non-selectable (or clickToView) card is clicked. Payload: (object, event) — the card's object and the native click event, for opening it in a new tab on a ctrl/cmd/shift click. A middle click emits aux-click instead. Selectable cards emit select; they also emit click (deprecated) when a click listener is present, so migrate selectable consumers to @select.
aux-clickundefinedEmitted when a non-selectable (or clickToView) card is middle-clicked, for opening it in a new tab (see openRowTarget). Payload: (object, event) — the card's object and the native auxclick event.

Slots​

NameBindingsDescription
actionsobject
badgesobject
metadataobject, fields

Board look​

Under the board look the card is white with a 12px radius, no shadow and no hover lift. The head row holds an optional leading element ({ initials } in a 36px circle, or { icon } on a tint), the title with the description as its sub line, and at the end the status pill (a label, or { label, variant }) or, without a status, the row menu from the actions slot. cardFields (property keys, in order) fills a two-column facts list; without it the card shows its first maxMetadata properties. footerAction ({ label, meta?, ariaLabel? }) adds a footer with one action and emits footer-action. The metadata slot still replaces the facts list. The accent border and icon show in the board look too, also on hover and on a selected card.

Record layout (layout, manifest config.cardLayout)​

With a layout the board card draws a record: a head pill and the number, the title, a meta line, an optional description and chips, and a footer with a pill and a date. Every part names a field (a dot path) and is left out while that field is empty.

PartShapeDraws
headPill, footerPill{ field, colorMap?, labels?, variant? }A pill.
number, titlefieldThe number at the end of the head; the title.
metalist of fields or { field, formatter? }One line, joined with " · ".
descriptionfield, or { field, maxLength? }A line under the meta line, cut at maxLength characters (140 by default) with an ellipsis.
chipslist of fields or { field, formatter?, formatterOptions?, colorMap?, labels?, variant? }A pill per entry, its text read through the formatter (a status uuid as its name).
footerDate{ field, label?, overdueVariant? }"Deadline 5 Oct", in the overdueVariant tone (error) once the date has passed.