Edit page

Implement action

To implement an action, you need to create a component with props of ActionProps. Here is example from Delete

import {ActionProps, ContentActionParams} from 'digimaker-ui';
const Delete = (props:ActionProps) => {
const [shown, setShown] = React.useState(false);
const params = props.params as ContentActionParams;
//...
}

ActionProps

Prop nameTypeDefaultRequiredDescription
fromview"list" | "inline" | "content"true

the view when it’s trigged

paramsListActionParams | ContentActionParamstrue

params when being trigged

from{ id: number; list_contenttype?: string; }false

from object.eg:{id: 22}

counternumberfalse

item counter when invoking the actions, starting from 0

Action from content

When fromview is content(from main) or inline(row_action in list)

ContentActionParams

export interface ContentActionParams{
/** from object */
from?: any;//eg.{id:22}
/** content on */
content:any; //todo: define 'any'
/** After action callback. redirect is useful when deleting itself. Note that redirect will be ignore in inline mode(list row) so it's safe to call true */
afterAction: (redirect?: boolean)=>void;
}

Action from list

When fromview is list - from list's tool(above list)

ListActionParams

export interface ListActionParams{
/** selected content list */
selected: Array<any>; //todo: define any as content
/** config of the list, include eg. sort array */
listConfig: any; //todo: define
/** after action it will refresh list */
afterAction: (newConfig?:ListAfterActionConfig)=>void; //todo: define 'any'
}