* fix: calendar change field throw error * fix: calendar change field throw error * fix: calendar change field throw error * Update Calendar.Designer.tsx Co-authored-by: up_young <roc_up_young@163.com> Co-authored-by: yangpeng <oncwnuFixr6B9ykxIme1UJHE_1U8@git.weixin.qq.com> Co-authored-by: chenos <chenlinxh@gmail.com>
This commit is contained in:
parent
cd41eb08ae
commit
54f993f327
@ -8,10 +8,12 @@ import { useCollectionFilterOptions } from '../../../collection-manager/action-h
|
||||
import { GeneralSchemaDesigner, SchemaSettings } from '../../../schema-settings';
|
||||
import { useSchemaTemplate } from '../../../schema-templates';
|
||||
|
||||
const useOptions = () => {
|
||||
const useOptions = (type = 'string') => {
|
||||
const compile = useCompile();
|
||||
const { fields } = useCollection();
|
||||
const options = fields?.map((field) => {
|
||||
const options = fields
|
||||
?.filter((field) => field.type === type)
|
||||
?.map((field) => {
|
||||
return {
|
||||
value: field.name,
|
||||
label: compile(field?.uiSchema?.title),
|
||||
@ -31,7 +33,6 @@ export const CalendarDesigner = () => {
|
||||
const { t } = useTranslation();
|
||||
const template = useSchemaTemplate();
|
||||
const defaultFilter = fieldSchema?.['x-decorator-props']?.params?.filter || {};
|
||||
const options = useOptions();
|
||||
const fieldNames = fieldSchema?.['x-decorator-props']?.['fieldNames'] || {};
|
||||
const defaultResource = fieldSchema?.['x-decorator-props']?.resource;
|
||||
return (
|
||||
@ -40,12 +41,14 @@ export const CalendarDesigner = () => {
|
||||
<SchemaSettings.SelectItem
|
||||
title={t('Title field')}
|
||||
value={fieldNames.title}
|
||||
options={options}
|
||||
options={useOptions('string')}
|
||||
onChange={(title) => {
|
||||
const fieldNames = field.decoratorProps.fieldNames || {};
|
||||
fieldNames['title'] = title;
|
||||
field.decoratorProps.params = fieldNames;
|
||||
fieldSchema['x-decorator-props']['params'] = fieldNames;
|
||||
// Select切换option后value未按照预期切换,固增加以下代码
|
||||
fieldSchema['x-decorator-props']['fieldNames'] = fieldNames;
|
||||
service.refresh();
|
||||
dn.emit('patch', {
|
||||
schema: {
|
||||
@ -59,12 +62,12 @@ export const CalendarDesigner = () => {
|
||||
<SchemaSettings.SelectItem
|
||||
title={t('Start date field')}
|
||||
value={fieldNames.start}
|
||||
options={options}
|
||||
options={useOptions('date')}
|
||||
onChange={(start) => {
|
||||
const fieldNames = field.decoratorProps.fieldNames || {};
|
||||
fieldNames['start'] = start;
|
||||
field.decoratorProps.params = fieldNames;
|
||||
fieldSchema['x-decorator-props']['params'] = fieldNames;
|
||||
field.decoratorProps.fieldNames = fieldNames;
|
||||
fieldSchema['x-decorator-props']['fieldNames'] = fieldNames;
|
||||
service.refresh();
|
||||
dn.emit('patch', {
|
||||
schema: {
|
||||
@ -78,12 +81,12 @@ export const CalendarDesigner = () => {
|
||||
<SchemaSettings.SelectItem
|
||||
title={t('End date field')}
|
||||
value={fieldNames.end}
|
||||
options={options}
|
||||
options={useOptions('date')}
|
||||
onChange={(end) => {
|
||||
const fieldNames = field.decoratorProps.fieldNames || {};
|
||||
fieldNames['end'] = end;
|
||||
field.decoratorProps.params = fieldNames;
|
||||
fieldSchema['x-decorator-props']['params'] = fieldNames;
|
||||
field.decoratorProps.fieldNames = fieldNames;
|
||||
fieldSchema['x-decorator-props']['fieldNames'] = fieldNames;
|
||||
service.refresh();
|
||||
dn.emit('patch', {
|
||||
schema: {
|
||||
|
Loading…
Reference in New Issue
Block a user