Ga naar hoofdinhoud

CnLockedBanner

The card that says the current object is locked, and by whom. Mounted automatically by CnDetailPage under the page title whenever useObjectLock().locked === true — for any active lock, not only a remote one.

Two tones, because the two situations are not the same problem:

SituationToneAction
Locked by someone elseError card (role="alert") naming the holdernone — the lock is theirs to release
Locked by youNeutral card (role="status")Unlock button, emitting unlock

The banner used to render only for a remote lock, which meant the one person who could do something about a stale lock — its holder — was the only person the UI never told about it.

For the same fact in a list, card grid or table, use CnLockIndicator.

Props​

PropTypeDefaultDescription
lockedBystring''Display name (or username) of the user holding the lock. Comes from useObjectLock().lockedBy.
lockedByMebooleanfalseWhether the lock belongs to the current user. Comes from useObjectLock().lockedByMe. Defaults to false, the safe reading: a host that does not pass it gets the error tone and no Unlock button.
expiresAtDate | nullnullLock expiration. When set, renders an "Expires in N min" sub-line.
showUnlockbooleantrueWhether to offer Unlock on the viewer's own lock. Set false on a read-only surface.
unlockingbooleanfalseWhether a release is in flight, so the button can disable itself and spin.
messagestring''Override the rendered headline message. Empty renders the default line for the applicable tone.

Events​

EventPayloadDescription
unlock—The viewer asked to release their own lock. The component never calls release() itself: it holds no reference to the composable, and releasing on its own would leave the host unable to refetch or re-enable its editors afterwards.

Usage​

<CnLockedBanner
v-if="lock.locked"
:locked-by="lock.lockedBy"
:locked-by-me="lock.lockedByMe"
:expires-at="lock.expiresAt"
:unlocking="releasing"
@unlock="onRelease" />
async onRelease() {
this.releasing = true
try {
await this.lock.release()
} finally {
this.releasing = false
}
}

The lock object comes from useObjectLock. Mount the banner above any editor surface (form dialog, inline edit grid) so users know to wait.