mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 03:46:08 +00:00
feat(plugin-field-sequence): allow to customize date format (#4685)
* feat(plugin-field-sequence): allow to customize date format * chore(plugin-sequence): remove debug log
This commit is contained in:
parent
9bef416d51
commit
3838793c50
@ -34,7 +34,8 @@ function RuleTypeSelect(props) {
|
||||
|
||||
useFormEffects(() => {
|
||||
onFieldValueChange(`patterns.${index}.type`, (field) => {
|
||||
setValuesIn(`patterns.${index}.options`, {});
|
||||
const type = RuleTypes[field.value];
|
||||
setValuesIn(`patterns.${index}.options`, type.defaults ? { ...type.defaults } : {});
|
||||
});
|
||||
});
|
||||
|
||||
@ -194,6 +195,10 @@ const RuleTypes = {
|
||||
default: null,
|
||||
},
|
||||
},
|
||||
defaults: {
|
||||
digits: 4,
|
||||
start: 1,
|
||||
},
|
||||
},
|
||||
date: {
|
||||
title: `{{t("Date", { ns: "${NAMESPACE}" })}}`,
|
||||
@ -202,6 +207,19 @@ const RuleTypes = {
|
||||
return <code>{options.value}</code>;
|
||||
},
|
||||
},
|
||||
fieldset: {
|
||||
format: {
|
||||
type: 'string',
|
||||
title: `{{t("Date format", { ns: "${NAMESPACE}" })}}`,
|
||||
description: `{{t('Supports all formats of the Day.js library, such as "YYYYMMDD", "YYYY-MM-DD", etc.', { ns: "${NAMESPACE}" })}}`,
|
||||
'x-decorator': 'FormItem',
|
||||
'x-component': 'Input',
|
||||
default: 'YYYYMMDD',
|
||||
},
|
||||
},
|
||||
defaults: {
|
||||
format: 'YYYYMMDD',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@ -384,7 +402,7 @@ export class SequenceFieldInterface extends CollectionFieldInterface {
|
||||
type: 'void',
|
||||
'x-component': 'ArrayTable.Addition',
|
||||
'x-component-props': {
|
||||
defaultValue: { type: 'integer', options: { digits: 1, start: 0 } },
|
||||
defaultValue: { type: 'integer', options: { ...RuleTypes.integer.defaults } },
|
||||
},
|
||||
title: `{{t("Add rule", { ns: "${NAMESPACE}" })}}`,
|
||||
},
|
||||
|
@ -9,6 +9,9 @@
|
||||
"Autoincrement": "自增数字",
|
||||
"Fixed text": "固定文本",
|
||||
"Text content": "文本内容",
|
||||
"Date": "日期",
|
||||
"Date format": "日期格式",
|
||||
"Supports all formats of the Day.js library, such as \"YYYYMMDD\", \"YYYY-MM-DD\", etc.": "支持 Day.js 库的所有格式,如“YYYYMMDD”、“YYYY-MM-DD”等。",
|
||||
"Rule content": "规则内容",
|
||||
"{{value}} Digits": "{{value}} 位数字",
|
||||
"Digits": "位数",
|
||||
|
Loading…
Reference in New Issue
Block a user