mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 08:08:32 +00:00
feat: add onTrigger to Actions component
This commit is contained in:
parent
2fd4e2fa61
commit
6b84446697
@ -1,16 +1,20 @@
|
||||
import React, { useRef } from 'react';
|
||||
import { Button } from 'antd';
|
||||
import { Button, Popconfirm } from 'antd';
|
||||
import ViewFactory from '@/components/views';
|
||||
|
||||
export function Destroy(props) {
|
||||
console.log(props);
|
||||
const { title, viewId } = props.schema;
|
||||
const { onTrigger } = props;
|
||||
const { title, viewId, isBulk = true } = props.schema;
|
||||
const drawerRef = useRef<any>();
|
||||
return (
|
||||
<>
|
||||
<Button type={'primary'} onClick={() => {
|
||||
|
||||
}}>{title}</Button>
|
||||
<Popconfirm title="确认删除吗?" onConfirm={() => {
|
||||
console.log('destroy', onTrigger);
|
||||
onTrigger && onTrigger();
|
||||
}}>
|
||||
<Button type={'primary'}>{title}</Button>
|
||||
</Popconfirm>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
@ -25,15 +25,23 @@ export function Action(props) {
|
||||
const { schema = {} } = props;
|
||||
// cnsole.log(schema);
|
||||
const { type } = schema;
|
||||
const Action = getAction(type);
|
||||
return Action && <Action {...props}/>;
|
||||
const Component = getAction(type);
|
||||
return Component && <Component {...props}/>;
|
||||
}
|
||||
|
||||
export function Actions(props) {
|
||||
const { style, schema, actions = [] } = props;
|
||||
const { onTrigger = {}, style, schema, actions = [], ...restProps } = props;
|
||||
console.log(onTrigger);
|
||||
return actions.length > 0 && (
|
||||
<Space style={style}>
|
||||
{actions.map(action => <Action {...props} view={schema} schema={action}/>)}
|
||||
{actions.map(action => (
|
||||
<Action
|
||||
{...restProps}
|
||||
view={schema}
|
||||
schema={action}
|
||||
onTrigger={onTrigger[action.name]}
|
||||
/>
|
||||
))}
|
||||
</Space>
|
||||
);
|
||||
}
|
||||
|
@ -71,6 +71,18 @@ export function SimpleTable(props: SimpleTableProps) {
|
||||
onFinish={() => {
|
||||
refresh();
|
||||
}}
|
||||
onTrigger={{
|
||||
async destroy() {
|
||||
await api.resource(name).destroy({
|
||||
associatedKey,
|
||||
filter: {
|
||||
[`${rowKey}.in`]: selectedRowKeys,
|
||||
},
|
||||
});
|
||||
await refresh();
|
||||
console.log('destroy.onTrigger', selectedRowKeys);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<ViewFactory
|
||||
{...props}
|
||||
|
@ -87,6 +87,18 @@ export function Table(props: TableProps) {
|
||||
onFinish={() => {
|
||||
refresh();
|
||||
}}
|
||||
onTrigger={{
|
||||
async destroy() {
|
||||
await api.resource(name).destroy({
|
||||
associatedKey,
|
||||
filter: {
|
||||
[`${rowKey}.in`]: selectedRowKeys,
|
||||
},
|
||||
});
|
||||
await refresh();
|
||||
console.log('destroy.onTrigger', selectedRowKeys);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<AntdTable
|
||||
rowKey={rowKey}
|
||||
|
Loading…
Reference in New Issue
Block a user