Ga naar hoofdinhoud

CnVersionHistory

Object version-history list plus field-by-field diff viewer for the pluggable integration registry. Fetches an OpenRegister object's audit-trail entries (query-time storage strategy, same endpoint as CnAuditTrailTab) and renders them inside a CnDetailCard, newest-first. Selecting one entry — or checking two and pressing "Compare selected" — opens a structural diff table (field | old value | new value), changed-only by default with a "Show all fields" toggle. Registered as its own version-history integration, additive alongside the existing audit-trail integration.

Wraps: CnDetailCard

Try it

Loading CnVersionHistory playground…

Usage

<CnVersionHistory
:register="registerId"
:schema="schemaId"
:object-id="objectId"
surface="detail-page" />

Design notes: diffs are built from audit-trail deltas, not full snapshots

OpenRegister does not store a full before/after object snapshot per version — AuditTrailMapper::createAuditTrail() persists only a per-field changed delta ({field: {old, new}}) at write time. So:

  • A single history entry's diff is exactly its own changed map.
  • Comparing two checked entries folds every entry's changed map between them (foldAuditTrailEntries, src/utils/auditTrailDiff.js) into a synthetic before/after state, then diffs that with computeObjectDiff (src/utils/computeObjectDiff.js) — the same generic, nested-aware diff utility used for the single-entry case.
  • A field that was never touched anywhere in the selected range is invisible to the diff — there is no baseline snapshot to compare it against. This is a backend data-shape limitation, not a viewer limitation.
  • "Show all fields" reveals unchanged rows: at the top level that only applies to fields OpenRegister reported as touched, but nested inside an already-changed object/array field it also reveals unchanged sibling keys (computeObjectDiff is fully general — a future host with real full snapshots gets true full-field toggling for free).

Pass pre-translated labels when your app handles i18n:

<CnVersionHistory
:register="reg"
:schema="schema"
:object-id="id"
:no-entries-label="t('myapp', 'No version history yet')"
:compare-label="t('myapp', 'Compare selected')"
:show-all-fields-label="t('myapp', 'Show all fields')" />

Display props

PropTypeDefaultNotes
titleString''Override the card title (defaults to the translated label).
pageSize (page-size)Number20Number of history entries fetched per page.
collapsibleBooleanfalseWhether the card collapses.
apiBase (api-base)String'/apps/openregister/api'Base API URL.
noEntriesLabel (no-entries-label)Stringt('nextcloud-vue', 'No version history yet')Pre-translated empty-history label.
fallbackVersionLabel (fallback-version-label)Stringt('nextcloud-vue', 'Unversioned change')Shown when an entry carries no semantic version.
selectForCompareLabel (select-for-compare-label)Stringt('nextcloud-vue', 'Select for compare')Accessible label for the row-select checkbox.
compareLabel (compare-label)Stringt('nextcloud-vue', 'Compare selected')Label for the compare-action button.
loadMoreLabel (load-more-label)Stringt('nextcloud-vue', 'Load more')Label for the pagination load-more button.
backLabel (back-label)Stringt('nextcloud-vue', 'Back to history')Label for the diff view's back-to-list button.
showAllFieldsLabel (show-all-fields-label)Stringt('nextcloud-vue', 'Show all fields')Label for the changed-only/show-all toggle.
fieldLabel (field-label)Stringt('nextcloud-vue', 'Field')Diff table field-column header.
oldValueLabel (old-value-label)Stringt('nextcloud-vue', 'Old value')Diff table old-value-column header.
newValueLabel (new-value-label)Stringt('nextcloud-vue', 'New value')Diff table new-value-column header.
noChangesLabel (no-changes-label)Stringt('nextcloud-vue', 'No field changes to show')Shown when a diff has no visible rows.

Reference

Props

NameTypeRequiredDefaultDescription
registerstringOpenRegister register id (slug or uuid).
schemastringOpenRegister schema id (slug or uuid).
objectIdstringParent object id.
surfacestring'detail-page'Rendering surface — passed for AD-19 surface fallback consumers.
apiBasestring'/apps/openregister/api'Base API URL.
pageSizenumber20Number of history entries to fetch per page.
collapsiblebooleanfalseWhether the card collapses.
titlestring''Override the card title (defaults to the translated label).
noEntriesLabelstring() =&gt; t('nextcloud-vue', 'No version history yet')Pre-translated empty-history label.
fallbackVersionLabelstring() =&gt; t('nextcloud-vue', 'Unversioned change')Pre-translated fallback shown when an entry carries no semantic version.
selectForCompareLabelstring() =&gt; t('nextcloud-vue', 'Select for compare')Pre-translated "select for compare" checkbox label.
compareLabelstring() =&gt; t('nextcloud-vue', 'Compare selected')Pre-translated compare-action label.
loadMoreLabelstring() =&gt; t('nextcloud-vue', 'Load more')Pre-translated load-more label.
backLabelstring() =&gt; t('nextcloud-vue', 'Back to history')Pre-translated back-to-list label.
showAllFieldsLabelstring() =&gt; t('nextcloud-vue', 'Show all fields')Pre-translated "show all fields" toggle label.
fieldLabelstring() =&gt; t('nextcloud-vue', 'Field')Pre-translated diff table field-column header.
oldValueLabelstring() =&gt; t('nextcloud-vue', 'Old value')Pre-translated diff table old-value-column header.
newValueLabelstring() =&gt; t('nextcloud-vue', 'New value')Pre-translated diff table new-value-column header.
noChangesLabelstring() =&gt; t('nextcloud-vue', 'No field changes to show')Pre-translated label shown when a diff has no visible rows.