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 { ISchema, Schema } from '@formily/react';
|
||||||
|
import { message } from 'antd';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { useAPIClient } from '../../../api-client';
|
||||||
import { i18n } from '../../../i18n';
|
import { i18n } from '../../../i18n';
|
||||||
import { CollectionOptions } from '../../types';
|
import { CollectionOptions } from '../../types';
|
||||||
import { CollectionTemplate } from '../components/CollectionTemplate';
|
import { CollectionTemplate } from '../components/CollectionTemplate';
|
||||||
@ -12,6 +15,7 @@ export const collection: CollectionOptions = {
|
|||||||
name: 'collections',
|
name: 'collections',
|
||||||
filterTargetKey: 'name',
|
filterTargetKey: 'name',
|
||||||
targetKey: 'name',
|
targetKey: 'name',
|
||||||
|
sortable: true,
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
type: 'integer',
|
type: 'integer',
|
||||||
@ -80,15 +84,16 @@ export const collectionSchema: ISchema = {
|
|||||||
'x-decorator': 'ResourceActionProvider',
|
'x-decorator': 'ResourceActionProvider',
|
||||||
'x-decorator-props': {
|
'x-decorator-props': {
|
||||||
collection: collection,
|
collection: collection,
|
||||||
|
dragSort: true,
|
||||||
request: {
|
request: {
|
||||||
resource: 'collections',
|
resource: 'collections',
|
||||||
action: 'list',
|
action: 'list',
|
||||||
params: {
|
params: {
|
||||||
pageSize: 50,
|
pageSize: 50,
|
||||||
|
sort: 'sort',
|
||||||
filter: {
|
filter: {
|
||||||
'hidden.$isFalsy': true,
|
'hidden.$isFalsy': true,
|
||||||
},
|
},
|
||||||
sort: ['sort'],
|
|
||||||
appends: [],
|
appends: [],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -150,6 +155,20 @@ export const collectionSchema: ISchema = {
|
|||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
},
|
},
|
||||||
useDataSource: '{{ cm.useDataSourceFromRAC }}',
|
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: {
|
properties: {
|
||||||
column1: {
|
column1: {
|
||||||
|
Loading…
Reference in New Issue
Block a user