mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-07-02 03:02:19 +08:00
fix: URL query parameter variables not working in public form field default values (#7084)
This commit is contained in:
parent
19d59c28fc
commit
2361f078eb
@ -19,6 +19,7 @@ import { useParentPopupVariableContext } from '../../schema-settings/VariableInp
|
|||||||
import { useCurrentParentRecordContext } from '../../schema-settings/VariableInput/hooks/useParentRecordVariable';
|
import { useCurrentParentRecordContext } from '../../schema-settings/VariableInput/hooks/useParentRecordVariable';
|
||||||
import { usePopupVariableContext } from '../../schema-settings/VariableInput/hooks/usePopupVariable';
|
import { usePopupVariableContext } from '../../schema-settings/VariableInput/hooks/usePopupVariable';
|
||||||
import { useCurrentRecordContext } from '../../schema-settings/VariableInput/hooks/useRecordVariable';
|
import { useCurrentRecordContext } from '../../schema-settings/VariableInput/hooks/useRecordVariable';
|
||||||
|
import { useURLSearchParamsVariable } from '../../schema-settings/VariableInput/hooks/useURLSearchParamsVariable';
|
||||||
import { VariableOption } from '../types';
|
import { VariableOption } from '../types';
|
||||||
import useContextVariable from './useContextVariable';
|
import useContextVariable from './useContextVariable';
|
||||||
|
|
||||||
@ -52,6 +53,7 @@ const useLocalVariables = (props?: Props) => {
|
|||||||
dataSource: parentPopupDataSource,
|
dataSource: parentPopupDataSource,
|
||||||
defaultValue: defaultValueOfParentPopupRecord,
|
defaultValue: defaultValueOfParentPopupRecord,
|
||||||
} = useParentPopupVariableContext();
|
} = useParentPopupVariableContext();
|
||||||
|
const { urlSearchParamsCtx, shouldDisplay: shouldDisplayURLSearchParams } = useURLSearchParamsVariable();
|
||||||
const { datetimeCtx } = useDatetimeVariableContext();
|
const { datetimeCtx } = useDatetimeVariableContext();
|
||||||
const { currentFormCtx } = useCurrentFormContext({ form: props?.currentForm });
|
const { currentFormCtx } = useCurrentFormContext({ form: props?.currentForm });
|
||||||
const { name: currentCollectionName } = useCollection_deprecated();
|
const { name: currentCollectionName } = useCollection_deprecated();
|
||||||
@ -146,6 +148,10 @@ const useLocalVariables = (props?: Props) => {
|
|||||||
ctx: parentObjectCtx,
|
ctx: parentObjectCtx,
|
||||||
collectionName: collectionNameOfParentObject,
|
collectionName: collectionNameOfParentObject,
|
||||||
},
|
},
|
||||||
|
shouldDisplayURLSearchParams && {
|
||||||
|
name: '$nURLSearchParams',
|
||||||
|
ctx: urlSearchParamsCtx,
|
||||||
|
},
|
||||||
] as VariableOption[]
|
] as VariableOption[]
|
||||||
).filter(Boolean);
|
).filter(Boolean);
|
||||||
}, [
|
}, [
|
||||||
@ -170,6 +176,7 @@ const useLocalVariables = (props?: Props) => {
|
|||||||
parentObjectCtx,
|
parentObjectCtx,
|
||||||
collectionNameOfParentObject,
|
collectionNameOfParentObject,
|
||||||
contextVariable,
|
contextVariable,
|
||||||
|
urlSearchParamsCtx,
|
||||||
]); // 尽量保持返回的值不变,这样可以减少接口的请求次数,因为关系字段会缓存到变量的 ctx 中
|
]); // 尽量保持返回的值不变,这样可以减少接口的请求次数,因为关系字段会缓存到变量的 ctx 中
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user