From e4b13289d719824982810d31d5bca8c2ef6448fb Mon Sep 17 00:00:00 2001 From: Junyi Date: Fri, 10 Jun 2022 23:27:35 +0800 Subject: [PATCH] fix(client): set `dropdownMatchSelectWidth` to false globally (#497) --- .../client/src/antd-config-provider/index.tsx | 6 +++++- packages/core/client/src/locale/zh_CN.ts | 3 +++ .../schema-component/antd/filter/FilterItem.tsx | 10 ++++------ packages/core/client/src/workflow/calculators.tsx | 15 +++++++++++---- packages/core/client/src/workflow/nodes/index.tsx | 7 ++++++- .../client/src/workflow/schemas/collection.ts | 3 +++ .../core/client/src/workflow/triggers/index.tsx | 10 ++++++++-- .../triggers/schedule/DateFieldsSelect.tsx | 7 ++++++- .../workflow/triggers/schedule/ScheduleConfig.tsx | 7 ------- .../src/workflow/triggers/schedule/index.tsx | 1 - .../triggers/schedule/locale/Cron.zh-CN.ts | 2 +- 11 files changed, 47 insertions(+), 24 deletions(-) diff --git a/packages/core/client/src/antd-config-provider/index.tsx b/packages/core/client/src/antd-config-provider/index.tsx index fdc654ef2..6c7990362 100644 --- a/packages/core/client/src/antd-config-provider/index.tsx +++ b/packages/core/client/src/antd-config-provider/index.tsx @@ -27,7 +27,11 @@ export function AntdConfigProvider(props) { return ; } return ( - + {props.children} ); diff --git a/packages/core/client/src/locale/zh_CN.ts b/packages/core/client/src/locale/zh_CN.ts index f24a511de..0f26f04fd 100644 --- a/packages/core/client/src/locale/zh_CN.ts +++ b/packages/core/client/src/locale/zh_CN.ts @@ -499,6 +499,7 @@ export default { 'Boolean': '逻辑值', 'String': '字符串', + 'Calculator': '运算', 'Comparison': '值比较', 'Arithmetic calculation': '算术运算', 'String operation': '字符串', @@ -581,5 +582,7 @@ export default { "Record ID": "数据 ID", "User": "用户", "Field": "字段", + "Select": "选择", + "Select Field": "选择字段", "Field value changes": "变更记录", } diff --git a/packages/core/client/src/schema-component/antd/filter/FilterItem.tsx b/packages/core/client/src/schema-component/antd/filter/FilterItem.tsx index 983866db4..fec6718a7 100644 --- a/packages/core/client/src/schema-component/antd/filter/FilterItem.tsx +++ b/packages/core/client/src/schema-component/antd/filter/FilterItem.tsx @@ -2,12 +2,14 @@ import { CloseCircleOutlined } from '@ant-design/icons'; import { observer } from '@formily/react'; import { Cascader, Select, Space } from 'antd'; import React, { useContext } from 'react'; +import { useTranslation } from 'react-i18next'; import { useCompile } from '../..'; import { RemoveConditionContext } from './context'; import { DynamicComponent } from './DynamicComponent'; import { useValues } from './useValues'; export const FilterItem = observer((props: any) => { + const { t } = useTranslation(); const compile = useCompile(); const remove = useContext(RemoveConditionContext); const { schema, fields, operators, dataIndex, operator, setDataIndex, setOperator, value, setValue } = useValues(); @@ -20,15 +22,13 @@ export const FilterItem = observer((props: any) => { value: 'name', children: 'children', }} - style={{ - width: 150, - }} changeOnSelect={false} value={dataIndex} options={compile(fields)} onChange={(value) => { setDataIndex(value); }} + placeholder={t('Select Field')} /> onChange({ value: v, type, options })}> + @@ -306,6 +309,7 @@ export function Operand({ } export function Calculation({ calculator, operands = [], onChange }) { + const { t } = useTranslation(); const compile = useCompile(); return ( @@ -316,14 +320,17 @@ export function Calculation({ calculator, operands = [], onChange }) { .ant-select{ width: auto; - min-width: 6em; } `}> onChange({ calculator, operands: [v, operands[1]] }))} /> {operands[0] ? ( <> - onChange({ operands, calculator: v })} + placeholder={t('Calculator')} + > {calculators.map(group => ( {group.children.map(item => ( diff --git a/packages/core/client/src/workflow/nodes/index.tsx b/packages/core/client/src/workflow/nodes/index.tsx index 8e84c1bde..ceacbcad1 100644 --- a/packages/core/client/src/workflow/nodes/index.tsx +++ b/packages/core/client/src/workflow/nodes/index.tsx @@ -220,7 +220,12 @@ export function NodeDefaultView(props) { name: 'config', 'x-component': 'fieldset', 'x-component-props': { - disabled: workflow.executed + disabled: workflow.executed, + className: css` + .ant-select{ + width: auto; + } + ` }, properties: instruction.fieldset }, diff --git a/packages/core/client/src/workflow/schemas/collection.ts b/packages/core/client/src/workflow/schemas/collection.ts index 9539f6a62..240949e66 100644 --- a/packages/core/client/src/workflow/schemas/collection.ts +++ b/packages/core/client/src/workflow/schemas/collection.ts @@ -10,6 +10,9 @@ export const collection = { 'x-reactions': ['{{useCollectionDataSource()}}'], 'x-decorator': 'FormItem', 'x-component': 'Select', + 'x-component-props': { + placeholder: '{{t("Select collection")}}' + } }; export const values = { diff --git a/packages/core/client/src/workflow/triggers/index.tsx b/packages/core/client/src/workflow/triggers/index.tsx index 4908af0b0..05878de5a 100644 --- a/packages/core/client/src/workflow/triggers/index.tsx +++ b/packages/core/client/src/workflow/triggers/index.tsx @@ -1,6 +1,6 @@ import React from "react"; import { ISchema, useForm } from "@formily/react"; -import { cx } from "@emotion/css"; +import { css, cx } from "@emotion/css"; import { Registry } from "@nocobase/utils"; import { useTranslation } from "react-i18next"; import { message, Tag } from "antd"; @@ -93,7 +93,13 @@ export const TriggerConfig = () => { type: 'void', name: 'config', 'x-component': 'fieldset', - 'x-component-props': {}, + 'x-component-props': { + className: css` + .ant-select{ + width: auto; + } + ` + }, properties: fieldset }, actions: { diff --git a/packages/core/client/src/workflow/triggers/schedule/DateFieldsSelect.tsx b/packages/core/client/src/workflow/triggers/schedule/DateFieldsSelect.tsx index 3e33e4d98..5541ba6ea 100644 --- a/packages/core/client/src/workflow/triggers/schedule/DateFieldsSelect.tsx +++ b/packages/core/client/src/workflow/triggers/schedule/DateFieldsSelect.tsx @@ -3,15 +3,20 @@ import { observer, useForm } from "@formily/react"; import { Select } from "antd"; import { useCollectionManager, useCompile } from "@nocobase/client"; +import { useTranslation } from "react-i18next"; export const DateFieldsSelect: React.FC = observer((props) => { + const { t } = useTranslation(); const compile = useCompile(); const { getCollectionFields } = useCollectionManager(); const { values } = useForm(); const fields = getCollectionFields(values?.config?.collection); return ( - {fields .filter(field => ( !field.hidden diff --git a/packages/core/client/src/workflow/triggers/schedule/ScheduleConfig.tsx b/packages/core/client/src/workflow/triggers/schedule/ScheduleConfig.tsx index 66ff5952e..e4d4157e0 100644 --- a/packages/core/client/src/workflow/triggers/schedule/ScheduleConfig.tsx +++ b/packages/core/client/src/workflow/triggers/schedule/ScheduleConfig.tsx @@ -6,7 +6,6 @@ import { css } from '@emotion/css'; import { SchemaComponent } from '@nocobase/client'; import { collection } from '../../schemas/collection'; -// import { DateFieldsSelect } from './DateFieldsSelect'; import { OnField } from './OnField'; import { EndsByField } from './EndsByField'; import { RepeatField } from './RepeatField'; @@ -191,11 +190,6 @@ export const ScheduleConfig = () => { 'x-component': 'fieldset', 'x-component-props': { className: css` - .ant-select{ - width: auto; - min-width: 6em; - } - .ant-input-number{ width: 4em; } @@ -210,7 +204,6 @@ export const ScheduleConfig = () => { } }} components={{ - // DateFieldsSelect, OnField, RepeatField, EndsByField diff --git a/packages/core/client/src/workflow/triggers/schedule/index.tsx b/packages/core/client/src/workflow/triggers/schedule/index.tsx index 0284a6eb3..895b926ae 100644 --- a/packages/core/client/src/workflow/triggers/schedule/index.tsx +++ b/packages/core/client/src/workflow/triggers/schedule/index.tsx @@ -24,7 +24,6 @@ export default { useCollectionDataSource }, components: { - // FieldsSelect ScheduleConfig }, getter({ type, options, onChange }) { diff --git a/packages/core/client/src/workflow/triggers/schedule/locale/Cron.zh-CN.ts b/packages/core/client/src/workflow/triggers/schedule/locale/Cron.zh-CN.ts index f997c1981..96c338dbc 100644 --- a/packages/core/client/src/workflow/triggers/schedule/locale/Cron.zh-CN.ts +++ b/packages/core/client/src/workflow/triggers/schedule/locale/Cron.zh-CN.ts @@ -19,7 +19,7 @@ export default { prefixMonths: '的', prefixMonthDays: '的', prefixWeekDays: '的', - prefixWeekDaysForMonthAndYearPeriod: '和', + prefixWeekDaysForMonthAndYearPeriod: '并且', prefixHours: '的', prefixMinutes: ':', prefixMinutesForHourPeriod: '的',