mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 01:36:52 +00:00
feat: kanban support enable drag and drop (#5468)
This commit is contained in:
parent
b36586f324
commit
37bae6ab34
@ -22,6 +22,7 @@ import {
|
||||
useFormBlockContext,
|
||||
schemaSettingsLabelLayout,
|
||||
} from '@nocobase/client';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useKanbanBlockContext } from './KanbanBlockProvider';
|
||||
export const kanbanSettings = new SchemaSettings({
|
||||
name: 'blockSettings:kanban',
|
||||
@ -78,6 +79,32 @@ export const kanbanSettings = new SchemaSettings({
|
||||
},
|
||||
},
|
||||
schemaSettingsLabelLayout,
|
||||
{
|
||||
name: 'allowDragAndDrop',
|
||||
type: 'switch',
|
||||
useComponentProps: () => {
|
||||
const field = useField();
|
||||
const fieldSchema = useFieldSchema();
|
||||
const { t } = useTranslation();
|
||||
const { dn } = useDesignable();
|
||||
return {
|
||||
title: t('Enable drag and drop sorting'),
|
||||
checked: field.componentProps?.dragSort !== false,
|
||||
onChange: async (dragSort) => {
|
||||
field.componentProps = field.componentProps || {};
|
||||
field.componentProps.dragSort = dragSort;
|
||||
fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
|
||||
fieldSchema['x-component-props'].dragSort = dragSort;
|
||||
dn.emit('patch', {
|
||||
schema: {
|
||||
['x-uid']: fieldSchema['x-uid'],
|
||||
'x-component-props': fieldSchema['x-component-props'],
|
||||
},
|
||||
});
|
||||
},
|
||||
};
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'divider',
|
||||
type: 'divider',
|
||||
|
@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
import { ArrayField } from '@formily/core';
|
||||
import { useField } from '@formily/react';
|
||||
import { useField, useFieldSchema } from '@formily/react';
|
||||
import { Spin } from 'antd';
|
||||
import React, { createContext, useCallback, useContext, useEffect, useState } from 'react';
|
||||
import {
|
||||
@ -82,8 +82,13 @@ export const useKanbanBlockContext = () => {
|
||||
};
|
||||
|
||||
const useDisableCardDrag = () => {
|
||||
const fieldSchema = useFieldSchema();
|
||||
const { dragSort } = fieldSchema?.parent?.['x-component-props'] || {};
|
||||
const ctx = useKanbanBlockContext();
|
||||
const { allowAll, allowConfigure, parseAction } = useACLRoleContext();
|
||||
if (dragSort === false) {
|
||||
return true;
|
||||
}
|
||||
if (allowAll || allowConfigure) {
|
||||
return false;
|
||||
}
|
||||
|
@ -4,5 +4,6 @@
|
||||
"Create sort field": "创建排序字段",
|
||||
"Convert the following integer fields to sorting fields": "将以下整数字段转为排序字段",
|
||||
"Sorting field":"排序字段",
|
||||
"Grouped sorting based on":"基于分组字段"
|
||||
"Grouped sorting based on":"基于分组字段",
|
||||
"Enable drag and drop sorting":"启用拖拽排序"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user