chore: avoid misoperation of date variables (#4452)

This commit is contained in:
Zeke Zhang 2024-05-22 21:21:06 +08:00 committed by GitHub
parent 2d880e576f
commit f6d56a9cb3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 8 additions and 3 deletions

View File

@ -39,6 +39,7 @@ export const SchemaSettingsDataScope: FC<DataScopeProps> = function DataScopeCon
{...props}
form={form}
record={record}
noDisabled={true}
shouldChange={getShouldChange({
collectionField: props.collectionField,
variables,

View File

@ -67,6 +67,10 @@ type Props = {
* @returns
*/
returnScope?: (scope: Option[]) => any[];
/**
* 使
*/
noDisabled?: boolean;
};
/**
@ -91,6 +95,7 @@ export const VariableInput = (props: Props) => {
record,
returnScope = _.identity,
targetFieldSchema,
noDisabled,
} = props;
const { name: blockCollectionName } = useBlockCollection();
const scope = useVariableScope();
@ -103,6 +108,7 @@ export const VariableInput = (props: Props) => {
operator,
uiSchema,
targetFieldSchema,
noDisabled,
});
const contextVariable = useContextAssociationFields({ schema, maxDepth: 2, contextCollectionName, collectionField });
const { compatOldVariables } = useCompatOldVariables({

View File

@ -193,7 +193,7 @@ export const useDatetimeVariable = ({ operator, schema, noDisabled }: Props = {}
const { t } = useTranslation();
const datetimeSettings = useMemo(() => {
const operatorValue = operator?.value || '';
const disabled = noDisabled ? false : !['DatePicker', 'DatePicker.RangePicker'].includes(schema?.['x-component']);
const disabled = noDisabled ? false : !['DatePicker.RangePicker'].includes(schema?.['x-component']);
const dateOptions = [
{
key: 'now',

View File

@ -11,7 +11,6 @@ import { Form } from '@formily/core';
import { ISchema, Schema } from '@formily/react';
import { useMemo } from 'react';
import { CollectionFieldOptions_deprecated } from '../../../collection-manager';
import { useBlockCollection } from './useBlockCollection';
import { useDatetimeVariable } from './useDateVariable';
import { useCurrentFormVariable } from './useFormVariable';
import { useCurrentObjectVariable } from './useIterationVariable';
@ -56,7 +55,6 @@ export const useVariableOptions = ({
targetFieldSchema,
record,
}: Props) => {
const { name: blockCollectionName = record?.__collectionName } = useBlockCollection();
const blockParentCollectionName = record?.__parent?.__collectionName;
const { currentUserSettings } = useCurrentUserVariable({
maxDepth: 3,