fix: dateformat setting should support sub-table/table block (#3297)

* fix: dateformat should effect immediately in sub-table

* refactor: dateformat setting for sub-table/table block

* refactor: dateformat setting for sub-table/table block

* refactor: schemaSettingsDateFormat
This commit is contained in:
katherinehhh 2024-01-02 17:36:28 +08:00 committed by GitHub
parent e8759588b5
commit fda30fd519
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 8 deletions

View File

@ -11,7 +11,7 @@ import { Collection, useCollection, useCollectionManager } from '../../../collec
import { useRecord } from '../../../record-provider'; import { useRecord } from '../../../record-provider';
import { generalSettingsItems } from '../../../schema-items/GeneralSettings'; import { generalSettingsItems } from '../../../schema-items/GeneralSettings';
import { import {
SchemaSettingsDataFormat, SchemaSettingsDateFormat,
SchemaSettingsDataScope, SchemaSettingsDataScope,
SchemaSettingsDefaultValue, SchemaSettingsDefaultValue,
SchemaSettingsSortingRule, SchemaSettingsSortingRule,
@ -732,7 +732,7 @@ export const formItemSettings = new SchemaSettings({
}, },
{ {
name: 'dateFormat', name: 'dateFormat',
Component: SchemaSettingsDataFormat, Component: SchemaSettingsDateFormat,
useVisible() { useVisible() {
const collectionField = useCollectionField(); const collectionField = useCollectionField();
const isDateField = ['datetime', 'createdAt', 'updatedAt'].includes(collectionField?.interface); const isDateField = ['datetime', 'createdAt', 'updatedAt'].includes(collectionField?.interface);

View File

@ -6,7 +6,7 @@ import { useFormBlockContext } from '../../../block-provider';
import { useCollectionManager } from '../../../collection-manager'; import { useCollectionManager } from '../../../collection-manager';
import { import {
GeneralSchemaDesigner, GeneralSchemaDesigner,
SchemaSettingsDataFormat, SchemaSettingsDateFormat,
SchemaSettingsDataScope, SchemaSettingsDataScope,
SchemaSettingsDefaultValue, SchemaSettingsDefaultValue,
SchemaSettingsDivider, SchemaSettingsDivider,
@ -392,7 +392,7 @@ export const TableColumnDesigner = (props) => {
}} }}
/> />
)} )}
{isDateField && <SchemaSettingsDataFormat fieldSchema={fieldSchema} />} {isDateField && <SchemaSettingsDateFormat fieldSchema={fieldSchema} />}
{isSubTableColumn && {isSubTableColumn &&
!field?.readPretty && !field?.readPretty &&
['obo', 'oho', 'o2o', 'o2m', 'm2m', 'm2o'].includes(collectionField?.interface) && ( ['obo', 'oho', 'o2o', 'o2m', 'm2m', 'm2o'].includes(collectionField?.interface) && (

View File

@ -1428,10 +1428,9 @@ export const SchemaSettingsEnableChildCollections = function EnableChildCollecti
); );
}; };
export const SchemaSettingsDataFormat = function DateFormatConfig(props: { fieldSchema: Schema }) { export const SchemaSettingsDateFormat = function DateFormatConfig(props: { fieldSchema: Schema }) {
const { fieldSchema } = props; const { fieldSchema } = props;
const field = useField(); const field = useField();
const form = useForm();
const { dn } = useDesignable(); const { dn } = useDesignable();
const { t } = useTranslation(); const { t } = useTranslation();
const { getCollectionJoinField } = useCollectionManager(); const { getCollectionJoinField } = useCollectionManager();
@ -1561,8 +1560,12 @@ export const SchemaSettingsDataFormat = function DateFormatConfig(props: { field
}; };
schema['x-component-props'] = fieldSchema['x-component-props']; schema['x-component-props'] = fieldSchema['x-component-props'];
field.componentProps = fieldSchema['x-component-props']; field.componentProps = fieldSchema['x-component-props'];
field.query(`.*.${fieldSchema.name}`).forEach((f) => { //子表格/表格区块
f.componentProps = fieldSchema['x-component-props']; const parts = (field.path.entire as string).split('.');
parts.pop();
const modifiedString = parts.join('.');
field.query(`${modifiedString}.*[0:].${fieldSchema.name}`).forEach((f) => {
f.setComponentProps({ ...data });
}); });
dn.emit('patch', { dn.emit('patch', {
schema, schema,