mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-07-02 03:02:19 +08:00
fix: form validation rules data lost when collapsing panel (#6949)
* fix: form validation rules data lost when collapsing panel * fix: test * fix: date picker not refreshed after toggling from 'is between' back to 'is' * fix: bug
This commit is contained in:
parent
d0dbc2428c
commit
d25e69a66e
@ -679,7 +679,7 @@ export function getOperators() {
|
||||
}
|
||||
|
||||
function parseFullDate(dateStr) {
|
||||
return new Date(dateStr);
|
||||
return new Date(`${dateStr}T00:00:00`);
|
||||
}
|
||||
|
||||
function parseMonth(dateStr) {
|
||||
|
@ -64,37 +64,67 @@ export const datetime = [
|
||||
label: "{{ t('is') }}",
|
||||
value: '$dateOn',
|
||||
selected: true,
|
||||
schema: { 'x-component': 'DateFilterDynamicComponent' },
|
||||
schema: {
|
||||
'x-component': 'DateFilterDynamicComponent',
|
||||
'x-component-props': {
|
||||
isRange: false,
|
||||
},
|
||||
},
|
||||
onlyFilterAction: true, //schema 仅在Filter.Action生效,筛选表单中不生效
|
||||
},
|
||||
{
|
||||
label: "{{ t('is not') }}",
|
||||
value: '$dateNotOn',
|
||||
schema: { 'x-component': 'DateFilterDynamicComponent' },
|
||||
schema: {
|
||||
'x-component': 'DateFilterDynamicComponent',
|
||||
'x-component-props': {
|
||||
isRange: false,
|
||||
},
|
||||
},
|
||||
onlyFilterAction: true,
|
||||
},
|
||||
{
|
||||
label: "{{ t('is before') }}",
|
||||
value: '$dateBefore',
|
||||
schema: { 'x-component': 'DateFilterDynamicComponent' },
|
||||
schema: {
|
||||
'x-component': 'DateFilterDynamicComponent',
|
||||
'x-component-props': {
|
||||
isRange: false,
|
||||
},
|
||||
},
|
||||
onlyFilterAction: true,
|
||||
},
|
||||
{
|
||||
label: "{{ t('is after') }}",
|
||||
value: '$dateAfter',
|
||||
schema: { 'x-component': 'DateFilterDynamicComponent' },
|
||||
schema: {
|
||||
'x-component': 'DateFilterDynamicComponent',
|
||||
'x-component-props': {
|
||||
isRange: false,
|
||||
},
|
||||
},
|
||||
onlyFilterAction: true,
|
||||
},
|
||||
{
|
||||
label: "{{ t('is on or after') }}",
|
||||
value: '$dateNotBefore',
|
||||
schema: { 'x-component': 'DateFilterDynamicComponent' },
|
||||
schema: {
|
||||
'x-component': 'DateFilterDynamicComponent',
|
||||
'x-component-props': {
|
||||
isRange: false,
|
||||
},
|
||||
},
|
||||
onlyFilterAction: true,
|
||||
},
|
||||
{
|
||||
label: "{{ t('is on or before') }}",
|
||||
value: '$dateNotAfter',
|
||||
schema: { 'x-component': 'DateFilterDynamicComponent' },
|
||||
schema: {
|
||||
'x-component': 'DateFilterDynamicComponent',
|
||||
'x-component-props': {
|
||||
isRange: false,
|
||||
},
|
||||
},
|
||||
onlyFilterAction: true,
|
||||
},
|
||||
{
|
||||
|
@ -6,7 +6,7 @@
|
||||
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||
*/
|
||||
import { ArrayCollapse, FormLayout } from '@formily/antd-v5';
|
||||
import { FormLayout } from '@formily/antd-v5';
|
||||
import { Field } from '@formily/core';
|
||||
import { ISchema, useField, useFieldSchema } from '@formily/react';
|
||||
import _ from 'lodash';
|
||||
@ -29,7 +29,7 @@ import { useIsAllowToSetDefaultValue } from '../../../../schema-settings/hooks/u
|
||||
import { getTempFieldState } from '../../../../schema-settings/LinkageRules/bindLinkageRulesToFiled';
|
||||
import { ActionType } from '../../../../schema-settings/LinkageRules/type';
|
||||
import { SchemaSettingsDefaultValue } from '../../../../schema-settings/SchemaSettingsDefaultValue';
|
||||
|
||||
import { ArrayCollapse } from '../../../../schema-settings/LinkageRules/components/LinkageHeader';
|
||||
export const fieldSettingsFormItem = new SchemaSettings({
|
||||
name: 'fieldSettings:FormItem',
|
||||
items: [
|
||||
@ -344,12 +344,17 @@ export const fieldSettingsFormItem = new SchemaSettings({
|
||||
type: 'object',
|
||||
'x-component': 'ArrayCollapse.CollapsePanel',
|
||||
'x-component-props': {
|
||||
header: '{{ t("Validation rule") }}',
|
||||
header: t('Validation rule'),
|
||||
},
|
||||
properties: {
|
||||
index: {
|
||||
type: 'void',
|
||||
'x-component': 'ArrayCollapse.Index',
|
||||
'x-component-props': {
|
||||
style: {
|
||||
lineHeight: '28px',
|
||||
},
|
||||
},
|
||||
},
|
||||
layout: {
|
||||
type: 'void',
|
||||
|
@ -28,7 +28,7 @@ describe('Filter', () => {
|
||||
|
||||
// 弹窗中显示的内容
|
||||
expect(within(tooltip).getByText(/name/i)).toBeInTheDocument();
|
||||
expect(within(tooltip).getByText(/ne/i)).toBeInTheDocument();
|
||||
expect(within(tooltip).getByTitle(/ne/i)).toBeInTheDocument();
|
||||
expect(within(tooltip).getByText(/tags \/ title/i)).toBeInTheDocument();
|
||||
expect(within(tooltip).getByText(/eq/i)).toBeInTheDocument();
|
||||
expect(within(tooltip).getByText(/^Add condition$/i)).toBeInTheDocument();
|
||||
|
@ -131,7 +131,6 @@ export const ArrayCollapse: ComposedArrayCollapse = observer(
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
|
||||
const renderItems = () => {
|
||||
return (
|
||||
<Collapse
|
||||
@ -168,6 +167,8 @@ export const ArrayCollapse: ComposedArrayCollapse = observer(
|
||||
<Badge size="small" className="errors-badge" count={errors.length}>
|
||||
{header}
|
||||
</Badge>
|
||||
) : props.header ? (
|
||||
props.header
|
||||
) : (
|
||||
<LinkageRulesTitle item={item.initialValue || item} index={index} />
|
||||
)}
|
||||
|
Loading…
x
Reference in New Issue
Block a user