Skip to content

useTableItemActions ​

Dispatches per-row actions (edit, delete, restore, duplicate, switch, link, bulk, custom form, show data) and computes which actions are visible for a given row.

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


Props Factory ​

js
import { makeTableItemActionsProps } from '@/hooks/table/useTableItemActions'
PropTypeDefaultDescription
isRowEditingBoolean—Whether the row is currently being inline-edited
hideMobileActionsBooleanfalseHide action buttons on mobile
rowActionsIconString'mdi-cog-outline'Icon for the dropdown trigger button
rowActionsArray|Object[]Action definitions for each row
rowActionsTypeString'inline''inline' renders icons; 'dropdown' renders a menu
iteratorTypeString''Set to 'iterator' when used in card/list view

Usage ​

js
import useTableItemActions, { makeTableItemActionsProps } from '@/hooks/table/useTableItemActions'

const { itemAction, itemHasAction, visibleRowActions, actionShowingType, actionEvents } =
  useTableItemActions(props, { TableForms, loadItems, TableItem, TableNames })

Returns ​

NameTypeDescription
itemAction(item, action, ...args) => voidDispatch an action for a row
itemHasAction(item, action) => BooleanReturns true when the action should be shown for this item
visibleRowActionsComputedRef<Array>Processed action definitions with resolved icons, colors, and component props
actionShowingTypeComputedRef<'inline'|'dropdown'>Whether actions render inline or in a dropdown (auto-collapses on small screens)
actionEventsReactive<Object>Shared event bus { event, payload, reset() } consumed by DataTable to open dialogs

Built-in Action Names ​

NameBehavior
editOpens the form modal with the row's data
delete / forceDeleteTriggers a confirmation dialog then calls datatableApi.delete / forceDelete
restoreTriggers datatableApi.restore
duplicateStrips id from the item and opens the create form
switchSends a PUT to endpoints.update with the toggled key/value
linkOpens item.href or action.url (:id replaced) in the configured target
activateSets the active row in the table
bulkDelete / bulkForceDelete / bulkRestore / bulkPublishBulk operations via dialog confirmation

Custom Actions ​

Any action with a form property triggers handleCustomFormAction, which loads a custom schema/model into the useTableForms custom-form modal.

Any action with a show property triggers handleShowAction, which opens the show-data modal with the relevant item data.

Permission Checks ​

itemHasAction uses can(action.name, permissionName) for built-in actions. It also evaluates action.conditions and action.userConditions against the row item and the user profile respectively.

Responsive Collapse ​

actionShowingType automatically switches to 'dropdown' on smaller viewports when the number of actions exceeds the breakpoint threshold (2+ actions on mobile, 3+ on tablet, etc.).

See Also ​