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:
katherinehhh 2024-02-26 21:26:02 +08:00 committed by GitHub
parent 0e728ca5a5
commit 28222fce99
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 25 additions and 12 deletions

View File

@ -1,5 +1,5 @@
import React from 'react';
import { uid } from '@formily/shared';
import { InitializerWithSwitch } from './InitializerWithSwitch';
import { useSchemaInitializerItem } from '../../application';
@ -13,7 +13,7 @@ export const TableActionColumnInitializer = () => {
'x-initializer': 'TableActionColumnInitializers',
'x-action-column': 'actions',
properties: {
actions: {
[uid()]: {
type: 'void',
'x-decorator': 'DndContext',
'x-component': 'Space',

View File

@ -1193,7 +1193,7 @@ export const createFormBlockSchema = (options) => {
'x-initializer': formItemInitializers,
properties: {},
},
actions: {
[uid()]: {
type: 'void',
'x-initializer': actionInitializers,
'x-component': 'ActionBar',
@ -1254,7 +1254,7 @@ export const createFilterFormBlockSchema = (options) => {
'x-initializer': formItemInitializers,
properties: {},
},
actions: {
[uid()]: {
type: 'void',
'x-initializer': actionInitializers,
'x-component': 'ActionBar',
@ -1308,7 +1308,7 @@ export const createReadPrettyFormBlockSchema = (options) => {
useProps: '{{ useFormBlockProps }}',
},
properties: {
actions: {
[uid()]: {
type: 'void',
'x-initializer': actionInitializers,
'x-component': 'ActionBar',
@ -1402,7 +1402,7 @@ export const createTableBlockSchema = (options) => {
'x-designer': 'TableV2.ActionColumnDesigner',
'x-initializer': tableActionColumnInitializers ?? 'TableActionColumnInitializers',
properties: {
actions: {
[uid()]: {
type: 'void',
'x-decorator': 'DndContext',
'x-component': 'Space',
@ -1470,7 +1470,7 @@ export const createTableSelectorSchema = (options) => {
'x-designer': 'TableSelectorDesigner',
'x-component': 'CardItem',
properties: {
actions: {
[uid()]: {
type: 'void',
'x-initializer': 'TableActionInitializers',
'x-component': 'ActionBar',

View File

@ -46,8 +46,12 @@ function InternalFormBlockInitializer({ schema, ...others }) {
delete result['x-acl-action-props'];
delete result['x-acl-action'];
const [formKey] = Object.keys(result.properties);
result.properties[formKey].properties.actions['x-decorator'] = 'ActionBarProvider';
result.properties[formKey].properties.actions['x-component-props'].style = {
//获取actionBar的schemakey
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',
flexWrap: 'wrap',
};

View File

@ -87,10 +87,13 @@ export default {
formBlocks.forEach((formBlock) => {
const [formKey] = Object.keys(formBlock.properties);
const formSchema = formBlock.properties[formKey];
//获取actionBar的schemakey
const actionKey =
Object.entries(formSchema.properties).find(([key, f]) => f['x-component'] === 'ActionBar')?.[0] || 'actions';
forms[formKey] = {
type: 'create',
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) => ({
status: item['x-decorator-props'].value,
values: item['x-action-settings']?.assignedValues?.values,

View File

@ -378,10 +378,13 @@ export default {
formBlock['x-decorator-props'].collection.fields = fields.map(
(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] = {
type: 'custom',
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) => ({
status: item['x-decorator-props'].value,
values: item['x-action-settings']?.assignedValues?.values,

View File

@ -125,11 +125,14 @@ export default {
formBlocks.forEach((formBlock) => {
const [formKey] = Object.keys(formBlock.properties);
const formSchema = formBlock.properties[formKey];
//获取actionBar的schemakey
const actionKey =
Object.entries(formSchema.properties).find(([key, f]) => f['x-component'] === 'ActionBar')?.[0] || 'actions';
forms[formKey] = {
...formBlock['x-decorator-props'],
type: 'update',
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) => ({
status: item['x-decorator-props'].value,
values: item['x-action-settings']?.assignedValues?.values,