mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-09 15:39:24 +08:00
chore: avoid misoperation of date variables (#4452)
This commit is contained in:
parent
2d880e576f
commit
f6d56a9cb3
@ -39,6 +39,7 @@ export const SchemaSettingsDataScope: FC<DataScopeProps> = function DataScopeCon
|
|||||||
{...props}
|
{...props}
|
||||||
form={form}
|
form={form}
|
||||||
record={record}
|
record={record}
|
||||||
|
noDisabled={true}
|
||||||
shouldChange={getShouldChange({
|
shouldChange={getShouldChange({
|
||||||
collectionField: props.collectionField,
|
collectionField: props.collectionField,
|
||||||
variables,
|
variables,
|
||||||
|
@ -67,6 +67,10 @@ type Props = {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
returnScope?: (scope: Option[]) => any[];
|
returnScope?: (scope: Option[]) => any[];
|
||||||
|
/**
|
||||||
|
* 不需要禁用选项,一般会在表达式中使用
|
||||||
|
*/
|
||||||
|
noDisabled?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -91,6 +95,7 @@ export const VariableInput = (props: Props) => {
|
|||||||
record,
|
record,
|
||||||
returnScope = _.identity,
|
returnScope = _.identity,
|
||||||
targetFieldSchema,
|
targetFieldSchema,
|
||||||
|
noDisabled,
|
||||||
} = props;
|
} = props;
|
||||||
const { name: blockCollectionName } = useBlockCollection();
|
const { name: blockCollectionName } = useBlockCollection();
|
||||||
const scope = useVariableScope();
|
const scope = useVariableScope();
|
||||||
@ -103,6 +108,7 @@ export const VariableInput = (props: Props) => {
|
|||||||
operator,
|
operator,
|
||||||
uiSchema,
|
uiSchema,
|
||||||
targetFieldSchema,
|
targetFieldSchema,
|
||||||
|
noDisabled,
|
||||||
});
|
});
|
||||||
const contextVariable = useContextAssociationFields({ schema, maxDepth: 2, contextCollectionName, collectionField });
|
const contextVariable = useContextAssociationFields({ schema, maxDepth: 2, contextCollectionName, collectionField });
|
||||||
const { compatOldVariables } = useCompatOldVariables({
|
const { compatOldVariables } = useCompatOldVariables({
|
||||||
|
@ -193,7 +193,7 @@ export const useDatetimeVariable = ({ operator, schema, noDisabled }: Props = {}
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const datetimeSettings = useMemo(() => {
|
const datetimeSettings = useMemo(() => {
|
||||||
const operatorValue = operator?.value || '';
|
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 = [
|
const dateOptions = [
|
||||||
{
|
{
|
||||||
key: 'now',
|
key: 'now',
|
||||||
|
@ -11,7 +11,6 @@ import { Form } from '@formily/core';
|
|||||||
import { ISchema, Schema } from '@formily/react';
|
import { ISchema, Schema } from '@formily/react';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { CollectionFieldOptions_deprecated } from '../../../collection-manager';
|
import { CollectionFieldOptions_deprecated } from '../../../collection-manager';
|
||||||
import { useBlockCollection } from './useBlockCollection';
|
|
||||||
import { useDatetimeVariable } from './useDateVariable';
|
import { useDatetimeVariable } from './useDateVariable';
|
||||||
import { useCurrentFormVariable } from './useFormVariable';
|
import { useCurrentFormVariable } from './useFormVariable';
|
||||||
import { useCurrentObjectVariable } from './useIterationVariable';
|
import { useCurrentObjectVariable } from './useIterationVariable';
|
||||||
@ -56,7 +55,6 @@ export const useVariableOptions = ({
|
|||||||
targetFieldSchema,
|
targetFieldSchema,
|
||||||
record,
|
record,
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
const { name: blockCollectionName = record?.__collectionName } = useBlockCollection();
|
|
||||||
const blockParentCollectionName = record?.__parent?.__collectionName;
|
const blockParentCollectionName = record?.__parent?.__collectionName;
|
||||||
const { currentUserSettings } = useCurrentUserVariable({
|
const { currentUserSettings } = useCurrentUserVariable({
|
||||||
maxDepth: 3,
|
maxDepth: 3,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user