Ga naar hoofdinhoud

CnNotesCard

Inline notes widget for detail pages. Fetches notes from the OpenRegister API, shows the most recent entries (up to maxDisplay), and includes an add-note form. Author names are wrapped with CnUserActionMenu for quick communication. Own notes show a delete button on hover.

Wraps: CnDetailCard, CnUserActionMenu

Try it​

Loading CnNotesCard playground…

Usage​

<CnNotesCard
register-id="uuid-register"
schema-id="uuid-schema"
object-id="uuid-object"
@note-added="refreshSidebar"
@note-deleted="refreshSidebar"
@show-all="openSidebarNotesTab" />

Pass pre-translated labels when your app handles i18n:

<CnNotesCard
register-id="reg"
schema-id="schema"
object-id="obj"
:title-label="t('myapp', 'Notes')"
:add-note-label="t('myapp', 'Add note')"
:no-notes-label="t('myapp', 'No notes yet')"
:show-all-label="t('myapp', 'Show all')" />

Props​

PropTypeRequiredDefaultDescription
registerIdString''OpenRegister register UUID (object source)
schemaIdString''OpenRegister schema UUID (object source)
objectIdString''Object UUID (object source)
fileIdString | NumbernullShow the notes of a plain Nextcloud file instead of an object: the file's id. Used when no objectId is given; the notes are the file's comments.
apiBaseString'/apps/openregister/api'Base URL for OpenRegister API calls
sourceObjectnullNotes of something that is not an object: { kind: 'flow-task', id } reads {apiBase}/flow-tasks/{id}/notes. id may be left out or written @objectId for objectId.
endpointString''A notes URL of its own: the list and the add go to it, a delete to {endpoint}/{noteId}. {id} is filled with the source's id or objectId.
failedLabelString'The notes could not be loaded'Shown when a source or endpoint read failed, instead of the empty text.
maxDisplayNumber5Maximum number of notes to show before the "Show all" footer link appears
collapsibleBooleanfalseWhether the card supports collapse/expand
chromelessBooleanfalseRender the notes body without the surrounding CnDetailCard. Set it where the surface already supplies the card and the title, such as a tab panel whose open tab names the panel; leaving the card on there nests a card inside a card and shows the label twice.
composerString'inline'Where the add form lives. inline keeps it open above the notes; button puts it behind an Add note button in the card's header (the DqTaak board) and closes it once the note is saved. A reply opens it either way. A chromeless card keeps it inline. From a manifest: "props": { "composer": "button" } on the notes integration widget.
titleLabelString'Notes'Card title
addNoteLabelString'Add note'Submit button label
addNotePlaceholderString'Write a note...'Textarea placeholder
noNotesLabelString'No notes yet'Empty state text
showAllLabelString'Show all'Footer link label
unavailableLabelString'Notes are not available for this file'Text shown instead of the notes when Nextcloud refuses a file's comments (no access).
showVisibilityBooleanfalseShow a chip on every note reading Internal or Public. A note without a value reads as internal (OpenRegister's own read-time fallback). Not used for a file source.
canSetVisibilityBooleanfalseWhether the caller may set visibility on this object: the answer the server gives for update on it. The host passes it; the card never infers it from the current user. When true the add-note form offers a Public switch (default internal) and each note a Make public / Make internal toggle.
publicSwitchLabelString'Public (visible to the customer)'Label of the add-note switch.
makePublicLabelString'Make public'Label of the toggle on an internal note.
makeInternalLabelString'Make internal'Label of the toggle on a public note.
replyLabelString'Reply'Label of the Reply button, shown only when the backend supports replies
deleteLabelString'Delete note'Accessible label for the delete button

Replies, group mentions and images​

The add-note form is the shared CnNoteComposer and each note's text is rendered by CnNoteBody, the same as in the sidebar Notes tab.

  • Replies. When the notes response carries a parentId key on its notes (null or not), each note offers Reply (its accessible name says whom it answers). The reply is created with the note's id as parentId and shows under its top-level note, one level deep, oldest first. A reply to a reply attaches to the same top-level note, and a reply many places below its parent carries a one-line quote of it. Without the parentId key (an OpenRegister that does not store parents yet) no Reply is shown, because it would be saved as a loose note. Not offered for a file source.
  • Group mentions. @ suggests groups beside users; a group is stored as @"group/<gid>" and shown as a group chip.
  • Images. An image pasted or dropped into the form is uploaded to the record's files and shown in the note. Only files of the same record render as images; any other image URL renders as a link.

A file as the source​

A document that is only a file, with no record behind it, can still hold notes. Pass fileId instead of the object props:

<CnNotesCard :file-id="file.fileid" />

The card then lists, adds and deletes the file's Nextcloud comments through /remote.php/dav/comments/files/{fileId}, the calls the Files sidebar's comments tab makes. They are the same notes: a note added here shows in the Files sidebar and the other way round. Nextcloud checks access on each call, so a colleague who cannot open the file sees no notes and no add field (the card shows unavailableLabel). Mention notifications for file comments come from Nextcloud's comments app; the card dispatches nothing. With an objectId, the card behaves as before, even when fileId is also set.

To show only a count (for a list row), use useFileComments.

A flow task, or another source​

source: { kind: 'flow-task' } points the card at a task of OpenRegister's task engine: it reads, adds and deletes through /api/flow-tasks/{id}/notes. Those notes carry isCurrentUser, so the author can delete their own; the delete button keeps its accessible name. A failed read says so ("The notes could not be loaded") instead of showing no notes, and a refused add or delete shows the server's sentence. On a page the notes integration passes it through its props:

{ "id": "task-notes", "type": "integration", "integrationId": "notes", "title": "Notes",
"props": { "source": { "kind": "flow-task", "id": "@objectId" } } }

Events​

EventPayloadDescription
note-added—Emitted after a note has been successfully created
note-deleted—Emitted after a note has been successfully deleted
show-all—Emitted when the "Show all" footer link is clicked
mention{ objectId, register, schema, noteId, mentionedUserIds, mentionedGroupIds? }After a note that mentions someone was added. mentionedGroupIds is present only when a group (@"group/<gid>") is mentioned. nc-vue notifies nobody; the listener does, and expands a group to its members.
visibility-changed{ id, visibility }After a note's visibility was changed

Reference (auto-generated)​

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

OpenRegister reliance​

medium: this component relies on OpenRegister for part of what it does. 1 direct reference, 9 files reached through imports.

Through: CnNoteComposer.

See the reliance overview for the filterable list.

Props​

NameTypeRequiredDefaultDescription
registerIdstring''OpenRegister register ID
schemaIdstring''OpenRegister schema ID
objectIdstring''Object UUID
fileIdstring&#124;numbernullShow the notes of a plain Nextcloud file instead of an OpenRegister object: the file's id. Used when no objectId is given; the notes are the file's comments (/remote.php/dav/comments/files/{fileId}), the same ones the Files sidebar shows.
apiBasestring'/apps/openregister/api'Base API URL for OpenRegister
sourceunionnullRead the notes of something that is not an OpenRegister object: { kind: 'flow-task', id } reads \$\{apiBase}/flow-tasks/{id}/notes. id may be left out or written @objectId for objectId.
endpointstring''A notes URL that replaces the object's own: the list and the add go to it, a delete to {endpoint}/{noteId}. {id} is filled with the source's id or objectId.
maxDisplaynumber5Maximum number of notes to display
collapsiblebooleanfalseWhether the card is collapsible
chromelessbooleanfalseRender the notes body without the surrounding CnDetailCard. Set when a surface already supplies the card and the title, such as a tab panel whose open tab names the panel. Leaving the card on there nests a card inside a card and shows the label twice.
composerstring'inline'Where the add form lives: inline (default) keeps it open above the notes; button puts it behind an "Add note" button in the card's header (DqTaak "Notities"), and closes it again once the note is saved. A reply opens it either way. Without the card's header (chromeless) the form stays inline.
showVisibilitybooleanfalseShow a chip on every note reading internal or public. A note without a value reads as internal. Off by default, so a host that passes nothing renders the card as before. Not used for a file source (file comments carry no flag).
canSetVisibilitybooleanfalseWhether the caller may set visibility on this object: the answer the server gives for update on it. The host passes it; the card never infers it from the current user. When true the card offers the public switch in the add-note form and a toggle on each note.
titleLabelstring() =&gt; t('nextcloud-vue', 'Notes')Card header title.
addNoteLabelstring() =&gt; t('nextcloud-vue', 'Add note')Label for the submit button that creates a new note.
addNotePlaceholderstring() =&gt; t('nextcloud-vue', 'Write a note…')Placeholder shown inside the new-note textarea before any input.
noNotesLabelstring() =&gt; t('nextcloud-vue', 'No notes yet')Empty-state text shown when the object has zero notes.
showAllLabelstring() =&gt; t('nextcloud-vue', 'Show all')Label for the "Show all" button rendered when the note list is truncated.
unavailableLabelstring() =&gt; t('nextcloud-vue', 'Notes are not available for this file')Text shown instead of the notes when Nextcloud refuses a file's comments (no access).
publicSwitchLabelstring() =&gt; t('nextcloud-vue', 'Public (visible to the customer)')Label of the add-note switch that makes the note public.
makePublicLabelstring() =&gt; t('nextcloud-vue', 'Make public')Label of the per-note action that makes an internal note public.
makeInternalLabelstring() =&gt; t('nextcloud-vue', 'Make internal')Label of the per-note action that makes a public note internal.
replyLabelstring() =&gt; t('nextcloud-vue', 'Reply')Label of the Reply button (shown only when the backend supports replies).
deleteLabelstring() =&gt; t('nextcloud-vue', 'Delete note')Aria label for the per-note delete icon button.
failedLabelstring() =&gt; t('nextcloud-vue', 'The notes could not be loaded')Text shown when a source or endpoint read failed.

Events​

NamePayloadDescription
show-all—
mention—
note-added—
note-deleted—
visibility-changed—Emitted after a note's visibility was changed. Payload: { id, visibility }.

Internal or public​

With showVisibility every note carries a chip, and the label (not the colour) says which side of the counter it is on. With canSetVisibility the add-note form carries the choice before the note is written (default internal) and a note can be flipped afterwards. Creating a note and changing its visibility both go out through one method (writeNote): POST .../notes with { message, visibility } and PATCH .../notes/{id} with { visibility }. A host that passes neither prop renders the card as before and sends { message } only. The server still decides: a refused write shows an error and leaves the note as it was.