mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-07-02 03:02:19 +08:00
refactor(client): add default type fallback api for (#6644)
This commit is contained in:
parent
49a9c6365b
commit
32ae82bb31
@ -26,12 +26,13 @@ import { Json } from '../input';
|
|||||||
const JT_VALUE_RE = /^\s*{{\s*([^{}]+)\s*}}\s*$/;
|
const JT_VALUE_RE = /^\s*{{\s*([^{}]+)\s*}}\s*$/;
|
||||||
|
|
||||||
type ParseOptions = {
|
type ParseOptions = {
|
||||||
|
defaultTypeOnNull?: string;
|
||||||
stringToDate?: boolean;
|
stringToDate?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
function parseValue(value: any, options: ParseOptions = {}): string | string[] {
|
function parseValue(value: any, options: ParseOptions = {}): string | string[] {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return 'null';
|
return options.defaultTypeOnNull ?? 'null';
|
||||||
}
|
}
|
||||||
const type = typeof value;
|
const type = typeof value;
|
||||||
if (type === 'string') {
|
if (type === 'string') {
|
||||||
|
@ -57,6 +57,9 @@ export default class extends Instruction {
|
|||||||
placeholder: `{{t("Duration", { ns: "${NAMESPACE}" })}}`,
|
placeholder: `{{t("Duration", { ns: "${NAMESPACE}" })}}`,
|
||||||
useTypedConstant: [['number', { min: 1 }]],
|
useTypedConstant: [['number', { min: 1 }]],
|
||||||
nullable: false,
|
nullable: false,
|
||||||
|
parseOptions: {
|
||||||
|
defaultTypeOnNull: 'number',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
default: 1,
|
default: 1,
|
||||||
required: true,
|
required: true,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user