fix: actions schema key should be uid (#3570)
* fix: actions in table column should be uid * fix: actins name in form block * fix: actions schema key should be uid * fix: actions schema key should be uid
This commit is contained in:
parent
0e728ca5a5
commit
28222fce99
@ -1,5 +1,5 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { uid } from '@formily/shared';
|
||||||
import { InitializerWithSwitch } from './InitializerWithSwitch';
|
import { InitializerWithSwitch } from './InitializerWithSwitch';
|
||||||
import { useSchemaInitializerItem } from '../../application';
|
import { useSchemaInitializerItem } from '../../application';
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ export const TableActionColumnInitializer = () => {
|
|||||||
'x-initializer': 'TableActionColumnInitializers',
|
'x-initializer': 'TableActionColumnInitializers',
|
||||||
'x-action-column': 'actions',
|
'x-action-column': 'actions',
|
||||||
properties: {
|
properties: {
|
||||||
actions: {
|
[uid()]: {
|
||||||
type: 'void',
|
type: 'void',
|
||||||
'x-decorator': 'DndContext',
|
'x-decorator': 'DndContext',
|
||||||
'x-component': 'Space',
|
'x-component': 'Space',
|
||||||
|
@ -1193,7 +1193,7 @@ export const createFormBlockSchema = (options) => {
|
|||||||
'x-initializer': formItemInitializers,
|
'x-initializer': formItemInitializers,
|
||||||
properties: {},
|
properties: {},
|
||||||
},
|
},
|
||||||
actions: {
|
[uid()]: {
|
||||||
type: 'void',
|
type: 'void',
|
||||||
'x-initializer': actionInitializers,
|
'x-initializer': actionInitializers,
|
||||||
'x-component': 'ActionBar',
|
'x-component': 'ActionBar',
|
||||||
@ -1254,7 +1254,7 @@ export const createFilterFormBlockSchema = (options) => {
|
|||||||
'x-initializer': formItemInitializers,
|
'x-initializer': formItemInitializers,
|
||||||
properties: {},
|
properties: {},
|
||||||
},
|
},
|
||||||
actions: {
|
[uid()]: {
|
||||||
type: 'void',
|
type: 'void',
|
||||||
'x-initializer': actionInitializers,
|
'x-initializer': actionInitializers,
|
||||||
'x-component': 'ActionBar',
|
'x-component': 'ActionBar',
|
||||||
@ -1308,7 +1308,7 @@ export const createReadPrettyFormBlockSchema = (options) => {
|
|||||||
useProps: '{{ useFormBlockProps }}',
|
useProps: '{{ useFormBlockProps }}',
|
||||||
},
|
},
|
||||||
properties: {
|
properties: {
|
||||||
actions: {
|
[uid()]: {
|
||||||
type: 'void',
|
type: 'void',
|
||||||
'x-initializer': actionInitializers,
|
'x-initializer': actionInitializers,
|
||||||
'x-component': 'ActionBar',
|
'x-component': 'ActionBar',
|
||||||
@ -1402,7 +1402,7 @@ export const createTableBlockSchema = (options) => {
|
|||||||
'x-designer': 'TableV2.ActionColumnDesigner',
|
'x-designer': 'TableV2.ActionColumnDesigner',
|
||||||
'x-initializer': tableActionColumnInitializers ?? 'TableActionColumnInitializers',
|
'x-initializer': tableActionColumnInitializers ?? 'TableActionColumnInitializers',
|
||||||
properties: {
|
properties: {
|
||||||
actions: {
|
[uid()]: {
|
||||||
type: 'void',
|
type: 'void',
|
||||||
'x-decorator': 'DndContext',
|
'x-decorator': 'DndContext',
|
||||||
'x-component': 'Space',
|
'x-component': 'Space',
|
||||||
@ -1470,7 +1470,7 @@ export const createTableSelectorSchema = (options) => {
|
|||||||
'x-designer': 'TableSelectorDesigner',
|
'x-designer': 'TableSelectorDesigner',
|
||||||
'x-component': 'CardItem',
|
'x-component': 'CardItem',
|
||||||
properties: {
|
properties: {
|
||||||
actions: {
|
[uid()]: {
|
||||||
type: 'void',
|
type: 'void',
|
||||||
'x-initializer': 'TableActionInitializers',
|
'x-initializer': 'TableActionInitializers',
|
||||||
'x-component': 'ActionBar',
|
'x-component': 'ActionBar',
|
||||||
|
@ -46,8 +46,12 @@ function InternalFormBlockInitializer({ schema, ...others }) {
|
|||||||
delete result['x-acl-action-props'];
|
delete result['x-acl-action-props'];
|
||||||
delete result['x-acl-action'];
|
delete result['x-acl-action'];
|
||||||
const [formKey] = Object.keys(result.properties);
|
const [formKey] = Object.keys(result.properties);
|
||||||
result.properties[formKey].properties.actions['x-decorator'] = 'ActionBarProvider';
|
//获取actionBar的schemakey
|
||||||
result.properties[formKey].properties.actions['x-component-props'].style = {
|
const actionKey =
|
||||||
|
Object.entries(result.properties[formKey].properties).find(([key, f]) => f['x-component'] === 'ActionBar')?.[0] ||
|
||||||
|
'actions';
|
||||||
|
result.properties[formKey].properties[actionKey]['x-decorator'] = 'ActionBarProvider';
|
||||||
|
result.properties[formKey].properties[actionKey]['x-component-props'].style = {
|
||||||
marginTop: '1.5em',
|
marginTop: '1.5em',
|
||||||
flexWrap: 'wrap',
|
flexWrap: 'wrap',
|
||||||
};
|
};
|
||||||
|
@ -87,10 +87,13 @@ export default {
|
|||||||
formBlocks.forEach((formBlock) => {
|
formBlocks.forEach((formBlock) => {
|
||||||
const [formKey] = Object.keys(formBlock.properties);
|
const [formKey] = Object.keys(formBlock.properties);
|
||||||
const formSchema = formBlock.properties[formKey];
|
const formSchema = formBlock.properties[formKey];
|
||||||
|
//获取actionBar的schemakey
|
||||||
|
const actionKey =
|
||||||
|
Object.entries(formSchema.properties).find(([key, f]) => f['x-component'] === 'ActionBar')?.[0] || 'actions';
|
||||||
forms[formKey] = {
|
forms[formKey] = {
|
||||||
type: 'create',
|
type: 'create',
|
||||||
title: formBlock['x-component-props']?.title || formKey,
|
title: formBlock['x-component-props']?.title || formKey,
|
||||||
actions: findSchema(formSchema.properties.actions, (item) => item['x-component'] === 'Action').map(
|
actions: findSchema(formSchema.properties[actionKey], (item) => item['x-component'] === 'Action').map(
|
||||||
(item) => ({
|
(item) => ({
|
||||||
status: item['x-decorator-props'].value,
|
status: item['x-decorator-props'].value,
|
||||||
values: item['x-action-settings']?.assignedValues?.values,
|
values: item['x-action-settings']?.assignedValues?.values,
|
||||||
|
@ -378,10 +378,13 @@ export default {
|
|||||||
formBlock['x-decorator-props'].collection.fields = fields.map(
|
formBlock['x-decorator-props'].collection.fields = fields.map(
|
||||||
(field) => field['x-component-props']?.field ?? field['x-interface-options'],
|
(field) => field['x-component-props']?.field ?? field['x-interface-options'],
|
||||||
);
|
);
|
||||||
|
//获取actionBar的schemakey
|
||||||
|
const actionKey =
|
||||||
|
Object.entries(formSchema.properties).find(([key, f]) => f['x-component'] === 'ActionBar')?.[0] || 'actions';
|
||||||
forms[formKey] = {
|
forms[formKey] = {
|
||||||
type: 'custom',
|
type: 'custom',
|
||||||
title: formBlock['x-component-props']?.title || formKey,
|
title: formBlock['x-component-props']?.title || formKey,
|
||||||
actions: findSchema(formSchema.properties.actions, (item) => item['x-component'] === 'Action').map(
|
actions: findSchema(formSchema.properties[actionKey], (item) => item['x-component'] === 'Action').map(
|
||||||
(item) => ({
|
(item) => ({
|
||||||
status: item['x-decorator-props'].value,
|
status: item['x-decorator-props'].value,
|
||||||
values: item['x-action-settings']?.assignedValues?.values,
|
values: item['x-action-settings']?.assignedValues?.values,
|
||||||
|
@ -125,11 +125,14 @@ export default {
|
|||||||
formBlocks.forEach((formBlock) => {
|
formBlocks.forEach((formBlock) => {
|
||||||
const [formKey] = Object.keys(formBlock.properties);
|
const [formKey] = Object.keys(formBlock.properties);
|
||||||
const formSchema = formBlock.properties[formKey];
|
const formSchema = formBlock.properties[formKey];
|
||||||
|
//获取actionBar的schemakey
|
||||||
|
const actionKey =
|
||||||
|
Object.entries(formSchema.properties).find(([key, f]) => f['x-component'] === 'ActionBar')?.[0] || 'actions';
|
||||||
forms[formKey] = {
|
forms[formKey] = {
|
||||||
...formBlock['x-decorator-props'],
|
...formBlock['x-decorator-props'],
|
||||||
type: 'update',
|
type: 'update',
|
||||||
title: formBlock['x-component-props']?.title || formKey,
|
title: formBlock['x-component-props']?.title || formKey,
|
||||||
actions: findSchema(formSchema.properties.actions, (item) => item['x-component'] === 'Action').map(
|
actions: findSchema(formSchema.properties[actionKey], (item) => item['x-component'] === 'Action').map(
|
||||||
(item) => ({
|
(item) => ({
|
||||||
status: item['x-decorator-props'].value,
|
status: item['x-decorator-props'].value,
|
||||||
values: item['x-action-settings']?.assignedValues?.values,
|
values: item['x-action-settings']?.assignedValues?.values,
|
||||||
|
Loading…
Reference in New Issue
Block a user