mirror of
https://gitee.com/nocobase/nocobase.git
synced 2024-12-03 12:47:44 +08:00
* 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 { GeneralSchemaDesigner, SchemaSettings } from '../../../schema-settings';
|
||||||
import { useSchemaTemplate } from '../../../schema-templates';
|
import { useSchemaTemplate } from '../../../schema-templates';
|
||||||
|
|
||||||
const useOptions = () => {
|
const useOptions = (type = 'string') => {
|
||||||
const compile = useCompile();
|
const compile = useCompile();
|
||||||
const { fields } = useCollection();
|
const { fields } = useCollection();
|
||||||
const options = fields?.map((field) => {
|
const options = fields
|
||||||
|
?.filter((field) => field.type === type)
|
||||||
|
?.map((field) => {
|
||||||
return {
|
return {
|
||||||
value: field.name,
|
value: field.name,
|
||||||
label: compile(field?.uiSchema?.title),
|
label: compile(field?.uiSchema?.title),
|
||||||
@ -31,7 +33,6 @@ export const CalendarDesigner = () => {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const template = useSchemaTemplate();
|
const template = useSchemaTemplate();
|
||||||
const defaultFilter = fieldSchema?.['x-decorator-props']?.params?.filter || {};
|
const defaultFilter = fieldSchema?.['x-decorator-props']?.params?.filter || {};
|
||||||
const options = useOptions();
|
|
||||||
const fieldNames = fieldSchema?.['x-decorator-props']?.['fieldNames'] || {};
|
const fieldNames = fieldSchema?.['x-decorator-props']?.['fieldNames'] || {};
|
||||||
const defaultResource = fieldSchema?.['x-decorator-props']?.resource;
|
const defaultResource = fieldSchema?.['x-decorator-props']?.resource;
|
||||||
return (
|
return (
|
||||||
@ -40,12 +41,14 @@ export const CalendarDesigner = () => {
|
|||||||
<SchemaSettings.SelectItem
|
<SchemaSettings.SelectItem
|
||||||
title={t('Title field')}
|
title={t('Title field')}
|
||||||
value={fieldNames.title}
|
value={fieldNames.title}
|
||||||
options={options}
|
options={useOptions('string')}
|
||||||
onChange={(title) => {
|
onChange={(title) => {
|
||||||
const fieldNames = field.decoratorProps.fieldNames || {};
|
const fieldNames = field.decoratorProps.fieldNames || {};
|
||||||
fieldNames['title'] = title;
|
fieldNames['title'] = title;
|
||||||
field.decoratorProps.params = fieldNames;
|
field.decoratorProps.params = fieldNames;
|
||||||
fieldSchema['x-decorator-props']['params'] = fieldNames;
|
fieldSchema['x-decorator-props']['params'] = fieldNames;
|
||||||
|
// Select切换option后value未按照预期切换,固增加以下代码
|
||||||
|
fieldSchema['x-decorator-props']['fieldNames'] = fieldNames;
|
||||||
service.refresh();
|
service.refresh();
|
||||||
dn.emit('patch', {
|
dn.emit('patch', {
|
||||||
schema: {
|
schema: {
|
||||||
@ -59,12 +62,12 @@ export const CalendarDesigner = () => {
|
|||||||
<SchemaSettings.SelectItem
|
<SchemaSettings.SelectItem
|
||||||
title={t('Start date field')}
|
title={t('Start date field')}
|
||||||
value={fieldNames.start}
|
value={fieldNames.start}
|
||||||
options={options}
|
options={useOptions('date')}
|
||||||
onChange={(start) => {
|
onChange={(start) => {
|
||||||
const fieldNames = field.decoratorProps.fieldNames || {};
|
const fieldNames = field.decoratorProps.fieldNames || {};
|
||||||
fieldNames['start'] = start;
|
fieldNames['start'] = start;
|
||||||
field.decoratorProps.params = fieldNames;
|
field.decoratorProps.fieldNames = fieldNames;
|
||||||
fieldSchema['x-decorator-props']['params'] = fieldNames;
|
fieldSchema['x-decorator-props']['fieldNames'] = fieldNames;
|
||||||
service.refresh();
|
service.refresh();
|
||||||
dn.emit('patch', {
|
dn.emit('patch', {
|
||||||
schema: {
|
schema: {
|
||||||
@ -78,12 +81,12 @@ export const CalendarDesigner = () => {
|
|||||||
<SchemaSettings.SelectItem
|
<SchemaSettings.SelectItem
|
||||||
title={t('End date field')}
|
title={t('End date field')}
|
||||||
value={fieldNames.end}
|
value={fieldNames.end}
|
||||||
options={options}
|
options={useOptions('date')}
|
||||||
onChange={(end) => {
|
onChange={(end) => {
|
||||||
const fieldNames = field.decoratorProps.fieldNames || {};
|
const fieldNames = field.decoratorProps.fieldNames || {};
|
||||||
fieldNames['end'] = end;
|
fieldNames['end'] = end;
|
||||||
field.decoratorProps.params = fieldNames;
|
field.decoratorProps.fieldNames = fieldNames;
|
||||||
fieldSchema['x-decorator-props']['params'] = fieldNames;
|
fieldSchema['x-decorator-props']['fieldNames'] = fieldNames;
|
||||||
service.refresh();
|
service.refresh();
|
||||||
dn.emit('patch', {
|
dn.emit('patch', {
|
||||||
schema: {
|
schema: {
|
||||||
|
Loading…
Reference in New Issue
Block a user