fix(linkage-rule): condition variable field is allow select To many association fields (#1798)
* fix: linkage rule condiction variables allow select to manyassociation field * fix: linkage rule condiction variables filter * fix: linkage rule condiction variables filter
This commit is contained in:
parent
6d342d0643
commit
89938191a3
@ -62,7 +62,9 @@ export const linkageMergeAction = ({ operator, value }, field, condition, values
|
||||
try {
|
||||
const result = evaluate(value.result || value.value, { ...scope, now: () => new Date().toString() });
|
||||
valueResult.push(result);
|
||||
} catch (error) {}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
} else if (value?.mode === 'constant') {
|
||||
valueResult.push(value?.value || value);
|
||||
} else {
|
||||
|
@ -61,7 +61,7 @@ const getValue = (str: string, values) => {
|
||||
const regex = /{{(.*?)}}/;
|
||||
const matches = str?.match?.(regex);
|
||||
if (matches) {
|
||||
return getVariableValue(str, values);
|
||||
return getVariableValue(str, flat(values));
|
||||
} else {
|
||||
return str;
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ type Props = {
|
||||
|
||||
export function FilterDynamicComponent(props: Props) {
|
||||
const { value, onChange, renderSchemaComponent, collectionName } = props;
|
||||
const scope = useVariableOptions(collectionName);
|
||||
const scope = useVariableOptions(collectionName, ['o2m', 'm2m']);
|
||||
return (
|
||||
<Variable.Input value={value} onChange={onChange} scope={scope}>
|
||||
{renderSchemaComponent()}
|
||||
|
@ -2,6 +2,7 @@ import { useCompile } from '../../schema-component';
|
||||
import { useCollectionManager, useCollection } from '../../collection-manager';
|
||||
|
||||
const supportsType = [
|
||||
'id',
|
||||
'checkbox',
|
||||
'number',
|
||||
'percent',
|
||||
@ -24,7 +25,7 @@ const supportsType = [
|
||||
'o2m',
|
||||
'm2m',
|
||||
];
|
||||
const useVariableTypes = (currentCollection) => {
|
||||
const useVariableTypes = (currentCollection, excludes = []) => {
|
||||
const { getCollectionFields, getInterface, getCollection } = useCollectionManager();
|
||||
const collection = getCollection(currentCollection);
|
||||
const fields = getCollectionFields(currentCollection);
|
||||
@ -34,7 +35,7 @@ const useVariableTypes = (currentCollection) => {
|
||||
value: currentCollection,
|
||||
options() {
|
||||
const field2option = (field, depth) => {
|
||||
if (!field.interface || !supportsType.includes(field.interface)) {
|
||||
if (!field.interface || !supportsType.filter((v) => !excludes.includes(v)).includes(field.interface)) {
|
||||
return;
|
||||
}
|
||||
const fieldInterface = getInterface(field.interface);
|
||||
@ -92,9 +93,9 @@ const useVariableTypes = (currentCollection) => {
|
||||
];
|
||||
};
|
||||
|
||||
export function useVariableOptions(collectionName) {
|
||||
export function useVariableOptions(collectionName, excludes?) {
|
||||
const compile = useCompile();
|
||||
const options = useVariableTypes(collectionName).map((item) => {
|
||||
const options = useVariableTypes(collectionName, excludes).map((item) => {
|
||||
const options = typeof item.options === 'function' ? item.options() : item.options;
|
||||
return {
|
||||
label: compile(item.title),
|
||||
|
Loading…
Reference in New Issue
Block a user