mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 21:49:25 +08:00
feat: support getFieldSupportedHelpers
This commit is contained in:
parent
400e4240fa
commit
9a0cfa9971
@ -262,7 +262,7 @@ function _Input(props: VariableInputProps) {
|
|||||||
[value],
|
[value],
|
||||||
);
|
);
|
||||||
|
|
||||||
const selectedScopeOption = useMemo(() => findScopeOption(scope, variableSegments), [scope, variableSegments]);
|
const selectedScopeOption = useMemo(() => findScopeOption(options, variableSegments), [options, variableSegments]);
|
||||||
|
|
||||||
const parsed = useMemo(() => parseValue(variableSegments, parseOptions), [parseOptions, variableSegments]);
|
const parsed = useMemo(() => parseValue(variableSegments, parseOptions), [parseOptions, variableSegments]);
|
||||||
const isConstant = typeof parsed === 'string';
|
const isConstant = typeof parsed === 'string';
|
||||||
@ -356,7 +356,7 @@ function _Input(props: VariableInputProps) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
await option.loadChildren(option, activeKey, variable);
|
await option.loadChildren(option, activeKey, variable);
|
||||||
setOptions((prev) => [...prev]);
|
setOptions([...options]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -381,7 +381,7 @@ function _Input(props: VariableInputProps) {
|
|||||||
// setPrevType(next[1]);
|
// setPrevType(next[1]);
|
||||||
const newVariable = ConstantTypes[next[1]]?.default?.() ?? null;
|
const newVariable = ConstantTypes[next[1]]?.default?.() ?? null;
|
||||||
onChange(
|
onChange(
|
||||||
composeTemplate({ fullVariable: newVariable, helpers: optionPath[optionPath.length - 1]?.helpers ?? [] }),
|
composeTemplate({ fullVariable: newVariable, helpers: helperObservables.helpersObs.value ?? [] }),
|
||||||
optionPath,
|
optionPath,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -394,7 +394,10 @@ function _Input(props: VariableInputProps) {
|
|||||||
}
|
}
|
||||||
const variableName = next.join('.');
|
const variableName = next.join('.');
|
||||||
const option = optionPath[optionPath.length - 1];
|
const option = optionPath[optionPath.length - 1];
|
||||||
onChange(composeTemplate({ fullVariable: variableName, helpers: option?.helpers ?? [] }), optionPath);
|
onChange(
|
||||||
|
composeTemplate({ fullVariable: variableName, helpers: helperObservables.helpersObs.value ?? [] }),
|
||||||
|
optionPath,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
[type, variable, onChange],
|
[type, variable, onChange],
|
||||||
);
|
);
|
||||||
|
@ -192,3 +192,12 @@ export function useVariable() {
|
|||||||
isHelperAllowed,
|
isHelperAllowed,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getFieldSupportedHelpers(fieldSchema: any): string[] {
|
||||||
|
if (!fieldSchema) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
if (['datetimeNoTz', 'date'].includes(fieldSchema?.type)) {
|
||||||
|
return ['date.*'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -7,5 +7,6 @@
|
|||||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export * from './Variable';
|
|
||||||
export { TextAreaWithGlobalScope } from './TextAreaWithGlobalScope';
|
export { TextAreaWithGlobalScope } from './TextAreaWithGlobalScope';
|
||||||
|
export * from './Variable';
|
||||||
|
export { getFieldSupportedHelpers } from './VariableProvider';
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 683602770b9fdad9a8fecc71735e8e5b46b76ceb
|
1
packages/plugins/@nocobase/plugin-backups
Submodule
1
packages/plugins/@nocobase/plugin-backups
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit d6a1f327a10cbe56ddec3d5adbb6e4adaf7a48d3
|
@ -10,7 +10,15 @@
|
|||||||
import { uniqBy } from 'lodash';
|
import { uniqBy } from 'lodash';
|
||||||
import React, { createContext, useCallback, useContext } from 'react';
|
import React, { createContext, useCallback, useContext } from 'react';
|
||||||
|
|
||||||
import { Variable, parseCollectionName, useApp, useCompile, useGlobalVariable, usePlugin } from '@nocobase/client';
|
import {
|
||||||
|
Variable,
|
||||||
|
getFieldSupportedHelpers,
|
||||||
|
parseCollectionName,
|
||||||
|
useApp,
|
||||||
|
useCompile,
|
||||||
|
useGlobalVariable,
|
||||||
|
usePlugin,
|
||||||
|
} from '@nocobase/client';
|
||||||
|
|
||||||
import WorkflowPlugin from '.';
|
import WorkflowPlugin from '.';
|
||||||
import { useFlowContext } from './FlowContext';
|
import { useFlowContext } from './FlowContext';
|
||||||
@ -366,6 +374,7 @@ export function getCollectionFieldOptions(options): VariableOption[] {
|
|||||||
[fieldNames.label]: label,
|
[fieldNames.label]: label,
|
||||||
key: field.name,
|
key: field.name,
|
||||||
[fieldNames.value]: field.name,
|
[fieldNames.value]: field.name,
|
||||||
|
helpers: getFieldSupportedHelpers(field),
|
||||||
isLeaf,
|
isLeaf,
|
||||||
loadChildren: isLeaf ? null : boundLoadChildren,
|
loadChildren: isLeaf ? null : boundLoadChildren,
|
||||||
field,
|
field,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user