Ga naar hoofdinhoud

CnContactPicker

Modal dialog for picking a person to link to an OpenRegister object: a Nextcloud user or an existing CardDAV contact (people on objects; see ADR-019).

Search is hit-as-you-type against two sources. Contacts come from the OR-side search endpoint (GET {apiBase}/contacts/search?q=<term>), which proxies CardDAV via OCP\Contacts\IManager. Users come from the sharee autocomplete (/ocs/v2.php/apps/files_sharing/api/v1/sharees), which answers the accounts the caller may address, so the picker needs no admin right and shows nobody the caller cannot already see. Users are listed first and marked with a badge; an empty term searches contacts only, since the autocomplete answers nothing without one.

Each row shows the avatar, display name and primary email. A role dropdown, a validity window and a note describe the link before confirming. Feed roleOptions from the schema's vocabulary (the object's contacts listing returns it as roles) so the handler picks a declared role rather than typing one.

Lives in its own .vue file under src/components/CnContactPicker/ per ADR-004 (modal isolation).

Usage​

<CnContactPicker
v-if="showPicker"
:api-base="apiBase"
@link="onPickerLink"
@close="showPicker = false" />

The parent (typically CnContactsTab) handles the actual POST to /api/objects/{r}/{s}/{id}/contacts and the list refresh.

Props​

PropTypeDefaultDescription
apiBaseString/apps/openregister/apiBase path for the OR REST API.
titleStringLink contactDialog title.
roleOptionsArrayApplicant/Handler/Advisor/OtherRole dropdown choices. Pass the schema's linkRoles vocabulary here.
includeUsersBooleantrueWhether Nextcloud users are offered beside contacts.
userSearchUrlString/ocs/v2.php/apps/files_sharing/api/v1/shareesThe autocomplete the user search reads.

Events​

EventPayloadDescription
link{kind, userId | contactUid + addressbookId + contactUri, displayName, email, role, validFrom, validUntil, note}Emitted when the user confirms a selection. kind is user or contact; a user link carries userId, a contact link the three CardDAV fields. Dates are YYYY-MM-DD or null.
close—Emitted on cancel or close.

Label props​

All optional, pre-translated overrides:

PropTypeDescription
searchLabelStringA11y label for the search field.
searchPlaceholderStringPlaceholder for the search field.
emptyLabelStringTitle for the empty/no-results state.
emptyDescriptionStringDescription for the empty/no-results state.
unknownLabelStringFallback label for a contact with no display name.
roleLabelStringLabel for the contact role field.
userBadgeLabelStringBadge marking a row as a Nextcloud user.
validFromLabelStringLabel for the first day of the role.
validUntilLabelStringLabel for the last day of the role.
noteLabelStringLabel for the note on the link.
cancelLabelStringCancel button label.
confirmLabelStringConfirm/link button label.