mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 04:15:19 +00:00
feat(collection-manager): drag-and-drop sorting
This commit is contained in:
parent
393ada2bc5
commit
d2fa623158
@ -1,4 +1,7 @@
|
||||
import { ISchema, Schema } from '@formily/react';
|
||||
import { message } from 'antd';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useAPIClient } from '../../../api-client';
|
||||
import { i18n } from '../../../i18n';
|
||||
import { CollectionOptions } from '../../types';
|
||||
import { CollectionTemplate } from '../components/CollectionTemplate';
|
||||
@ -12,6 +15,7 @@ export const collection: CollectionOptions = {
|
||||
name: 'collections',
|
||||
filterTargetKey: 'name',
|
||||
targetKey: 'name',
|
||||
sortable: true,
|
||||
fields: [
|
||||
{
|
||||
type: 'integer',
|
||||
@ -80,15 +84,16 @@ export const collectionSchema: ISchema = {
|
||||
'x-decorator': 'ResourceActionProvider',
|
||||
'x-decorator-props': {
|
||||
collection: collection,
|
||||
dragSort: true,
|
||||
request: {
|
||||
resource: 'collections',
|
||||
action: 'list',
|
||||
params: {
|
||||
pageSize: 50,
|
||||
sort: 'sort',
|
||||
filter: {
|
||||
'hidden.$isFalsy': true,
|
||||
},
|
||||
sort: ['sort'],
|
||||
appends: [],
|
||||
},
|
||||
},
|
||||
@ -150,6 +155,20 @@ export const collectionSchema: ISchema = {
|
||||
type: 'checkbox',
|
||||
},
|
||||
useDataSource: '{{ cm.useDataSourceFromRAC }}',
|
||||
useAction() {
|
||||
const api = useAPIClient();
|
||||
const { t } = useTranslation();
|
||||
return {
|
||||
async move(from, to) {
|
||||
console.log(from, to);
|
||||
await api.resource('collections').move({
|
||||
sourceId: from.key,
|
||||
targetId: to.key,
|
||||
});
|
||||
message.success(t('Saved successfully'), 0.2);
|
||||
},
|
||||
};
|
||||
},
|
||||
},
|
||||
properties: {
|
||||
column1: {
|
||||
|
Loading…
Reference in New Issue
Block a user