Skip to content

useTableItem ​

Holds the currently edited row and provides soft-delete detection helpers.

File: vue/src/js/hooks/table/useTableItem.js


Usage ​

js
import useTableItem from '@/hooks/table/useTableItem'

const {
  editedItem,
  isSoftDeletableItem,
  itemIsDeleted,
  setEditedItem,
  resetEditedItem,
  isSoftDeletable,
  isDeleted,
} = useTableItem(props, context)

Returns ​

State ​

NameTypeDescription
editedItemRef<Object>The row currently open in the form. Initialized from props.modelValue or a blank model derived from formSchema.
isSoftDeletableItemComputedRef<Boolean>true when editedItem.deleted_at is set (soft-deleted)
itemIsDeletedComputedRef<Boolean>Alias for isSoftDeletableItem

Methods ​

NameSignatureDescription
setEditedItem(item: Object) => voidReplace editedItem with a shallow copy of item
resetEditedItem() => voidReset editedItem to a blank model (runs in nextTick)
isSoftDeletable(item: Object) => BooleanReturns true when item.deleted_at is truthy
isDeleted(item: Object) => BooleanAlias for isSoftDeletable

Notes ​

  • resetEditedItem uses nextTick to avoid clearing the form before the close animation finishes.
  • Soft-delete detection drives which delete action is shown (delete vs forceDelete) and which dialog text is used.

See Also ​