Merge branch 'main' into fix-quote-table

This commit is contained in:
Zeke Zhang 2024-08-09 21:56:45 +08:00
commit aa801048dd
9 changed files with 38 additions and 21 deletions

View File

@ -419,6 +419,8 @@ jobs:
- plugin-workflow - plugin-workflow
- plugin-workflow-approval - plugin-workflow-approval
- plugin-data-source-main - plugin-data-source-main
permissions:
pull-requests: write
if: ${{ !cancelled() && github.event.pull_request.number }} if: ${{ !cancelled() && github.event.pull_request.number }}
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4

View File

@ -69,7 +69,7 @@ const PreviewCom = (props) => {
}; };
}); });
const children = collection.fields const children = collection.fields
.filter((v) => !['hasOne', 'hasMany', 'belongsToMany'].includes(v?.type)) .filter((v) => !['obo', 'oho', 'm2m', 'o2m'].includes(v?.interface))
?.map((v) => { ?.map((v) => {
return { value: v.name, key: v.name, label: t(v.uiSchema?.title || v.name) }; return { value: v.name, key: v.name, label: t(v.uiSchema?.title || v.name) };
}) })

View File

@ -68,11 +68,12 @@ const useSourceFieldsOptions = () => {
return; return;
} }
const children = (collection.fields as FieldOptions[]) const children = (collection.fields as FieldOptions[])
.filter((v) => !['hasOne', 'hasMany', 'belongsToMany'].includes(v?.type)) .filter((v) => {
return !['hasOne', 'hasMany', 'belongsToMany', 'belongsTo'].includes(v?.type);
})
?.map((v) => { ?.map((v) => {
return { value: v.name, label: t(v.uiSchema?.title) }; return { value: v.name, label: t(v.uiSchema?.title) };
}); });
data.push({ data.push({
value: item, value: item,
label: t(collection.title), label: t(collection.title),
@ -110,7 +111,6 @@ export const FieldsConfigure = observer(
[compile], [compile],
); );
const sourceFieldsOptions = useSourceFieldsOptions(); const sourceFieldsOptions = useSourceFieldsOptions();
const refGetInterface = useRef(getInterface); const refGetInterface = useRef(getInterface);
useEffect(() => { useEffect(() => {
const fieldsMp = new Map(); const fieldsMp = new Map();

View File

@ -13,7 +13,7 @@ import { isEqual } from 'lodash';
import { useCallback, useEffect, useMemo } from 'react'; import { useCallback, useEffect, useMemo } from 'react';
import { useTableBlockContext } from '../../../../../block-provider/TableBlockProvider'; import { useTableBlockContext } from '../../../../../block-provider/TableBlockProvider';
import { findFilterTargets } from '../../../../../block-provider/hooks'; import { findFilterTargets } from '../../../../../block-provider/hooks';
import { useFilterBlock } from '../../../../../filter-provider/FilterProvider'; import { DataBlock, useFilterBlock } from '../../../../../filter-provider/FilterProvider';
import { mergeFilter } from '../../../../../filter-provider/utils'; import { mergeFilter } from '../../../../../filter-provider/utils';
import { removeNullCondition } from '../../../../../schema-component'; import { removeNullCondition } from '../../../../../schema-component';
@ -103,12 +103,17 @@ export const useTableBlockProps = () => {
return; return;
} }
const value = [record[ctx.rowKey]]; const currentBlock = dataBlocks.find((block) => block.uid === fieldSchema.parent['x-uid']);
dataBlocks.forEach((block) => { dataBlocks.forEach((block) => {
const target = targets.find((target) => target.uid === block.uid); const target = targets.find((target) => target.uid === block.uid);
if (!target) return; if (!target) return;
const isForeignKey = block.foreignKeyFields?.some((field) => field.name === target.field);
const sourceKey = getSourceKey(currentBlock, target.field);
const recordKey = isForeignKey ? sourceKey : ctx.rowKey;
const value = [record[recordKey]];
const param = block.service.params?.[0] || {}; const param = block.service.params?.[0] || {};
// 保留原有的 filter // 保留原有的 filter
const storedFilter = block.service.params?.[1]?.filters || {}; const storedFilter = block.service.params?.[1]?.filters || {};
@ -146,7 +151,7 @@ export const useTableBlockProps = () => {
}); });
// 更新表格的选中状态 // 更新表格的选中状态
setSelectedRow((prev) => (prev?.includes(record[ctx.rowKey]) ? [] : [...value])); setSelectedRow((prev) => (prev?.includes(record[ctx.rowKey]) ? [] : [record[ctx.rowKey]]));
}, },
[ctx.rowKey, fieldSchema, getDataBlocks], [ctx.rowKey, fieldSchema, getDataBlocks],
), ),
@ -155,3 +160,8 @@ export const useTableBlockProps = () => {
}, []), }, []),
}; };
}; };
function getSourceKey(currentBlock: DataBlock, field: string) {
const associationField = currentBlock?.associatedFields?.find((item) => item.foreignKey === field);
return associationField?.sourceKey || 'id';
}

View File

@ -362,9 +362,10 @@ export const selectComponentFieldSettings = new SchemaSettings({
{ {
...allowMultiple, ...allowMultiple,
useVisible() { useVisible() {
const isFieldReadPretty = useIsFieldReadPretty();
const isAssociationField = useIsAssociationField(); const isAssociationField = useIsAssociationField();
const IsShowMultipleSwitch = useIsShowMultipleSwitch(); const IsShowMultipleSwitch = useIsShowMultipleSwitch();
return isAssociationField && IsShowMultipleSwitch(); return !isFieldReadPretty && isAssociationField && IsShowMultipleSwitch();
}, },
}, },
{ {

View File

@ -127,7 +127,7 @@ const InternalAssociationSelect = observer(
}; };
return ( return (
<div key={fieldSchema.name}> <div key={fieldSchema.name}>
<Space.Compact style={{ display: 'flex', lineHeight: '32px' }}> <Space.Compact style={{ display: 'flex' }}>
<RemoteSelect <RemoteSelect
style={{ width: '100%' }} style={{ width: '100%' }}
{...rest} {...rest}

View File

@ -121,7 +121,7 @@ const getChildren = (
): Option[] => { ): Option[] => {
const result = options const result = options
.map((option): Option => { .map((option): Option => {
if (!option.target) { if (!option.target || option.target === 'chinaRegions') {
return { return {
key: option.name, key: option.name,
value: option.name, value: option.name,

View File

@ -7,14 +7,14 @@
* For more information, please refer to: https://www.nocobase.com/agreement. * For more information, please refer to: https://www.nocobase.com/agreement.
*/ */
import { Model } from './model'; import { isPlainObject } from '@nocobase/utils';
import { Model as SequelizeModel } from 'sequelize';
import { Collection } from './collection'; import { Collection } from './collection';
import Database from './database'; import Database from './database';
import { InheritedSyncRunner } from './inherited-sync-runner';
import { InheritedCollection } from './inherited-collection';
import { Model as SequelizeModel } from 'sequelize';
import { ZeroColumnTableError } from './errors/zero-column-table-error'; import { ZeroColumnTableError } from './errors/zero-column-table-error';
import { isPlainObject } from '@nocobase/utils'; import { InheritedCollection } from './inherited-collection';
import { InheritedSyncRunner } from './inherited-sync-runner';
import { Model } from './model';
export class SyncRunner { export class SyncRunner {
private readonly collection: Collection; private readonly collection: Collection;
@ -74,14 +74,17 @@ export class SyncRunner {
throw e; throw e;
} }
let beforeColumns;
try { try {
const beforeColumns = await this.queryInterface.describeTable(this.tableName, options); beforeColumns = await this.queryInterface.describeTable(this.tableName, options);
} catch (error) {
// continue
}
if (beforeColumns) {
await this.handlePrimaryKeyBeforeSync(beforeColumns, options); await this.handlePrimaryKeyBeforeSync(beforeColumns, options);
await this.handleUniqueFieldBeforeSync(beforeColumns, options); await this.handleUniqueFieldBeforeSync(beforeColumns, options);
} catch (e) {
if (!e.message.includes('No description found')) {
throw e;
}
} }
const syncResult = await this.performSync(options); const syncResult = await this.performSync(options);

View File

@ -69,7 +69,8 @@ test('menu permission ', async ({ page, mockPage, mockRole, updateRole }) => {
expect(page.url()).toContain(uid2); expect(page.url()).toContain(uid2);
}); });
test('i18n should not fallbackNS', async ({ page }) => { // TODO: this is not stable
test.skip('i18n should not fallbackNS', async ({ page }) => {
await page.goto('/admin/settings/system-settings'); await page.goto('/admin/settings/system-settings');
// 创建 Users 页面 // 创建 Users 页面