import React, { useState } from 'react'; import { Space, Button, Popconfirm, Popover } from 'antd'; import { FilterOutlined, PlusOutlined, SelectOutlined, DeleteOutlined } from '@ant-design/icons'; import Drawer from '@/components/pages/AdminLoader/Drawer'; import View from '@/components/pages/AdminLoader/View'; import get from 'lodash/get'; import set from 'lodash/set'; export function Create(props) { const { size, onFinish, schema = {}, associatedKey, ...restProps } = props; const { title, viewName, transform } = schema; return ( <> ) } export function Update(props) { const { onFinish, data, schema = {}, associatedKey, ...restProps } = props; const { title, viewName } = schema; return ( <> ) } export function Add(props) { const { size, onFinish, schema = {}, associatedKey, ...restProps } = props; console.log({associatedKey}, 'add'); const { filter, title, viewName, transform, componentProps = {} } = schema; return ( <> ); }, }); }} icon={} {...componentProps} >{ title } ) } export function Destroy(props) { const { size, schema = {}, onFinish } = props; const { title } = schema; return ( { onFinish && await onFinish(); }}> ) } export function Filter(props) { const { schema = {}, onFinish } = props; const { title, fields = [] } = schema; const [visible, setVisible] = useState(false); const [data, setData] = useState({}); const [filterCount, setFilterCount] = useState(0); console.log('Filter', { visible, data }); return ( <> {visible && (
setVisible(false)} >
)} { setVisible(visible); }} className={'filters-popover'} style={{ }} overlayStyle={{ minWidth: 500 }} content={( <> { if (values) { const items = values.filter.and || values.filter.or; setFilterCount(Object.keys(items).length); setData(values); onFinish && await onFinish(values); } setVisible(false); }} schema={{ "type": "filterForm", "fields": [{ "dataIndex": ["filter"], "name": "filter", "interface": "json", "type": "json", "component": { "type": "filter", 'x-component-props': { fields, } }, }], }}/> )} > ) } export function Actions(props) { const { onTrigger = {}, actions = [], style, ...restProps } = props; return actions.length > 0 && (
{actions.map(action => (
))}
); } export default Actions; const ACTIONS = new Map(); export function registerAction(type: string, Action: any) { ACTIONS.set(type, Action); } export function getAction(type: string) { return ACTIONS.get(type); } export function Action(props) { const { schema = {} } = props; // cnsole.log(schema); const { type } = schema; const Component = getAction(type); return Component && ; } registerAction('add', Add); registerAction('update', Update); registerAction('create', Create); registerAction('destroy', Destroy); registerAction('filter', Filter);