mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-07 14:39:25 +08:00
Merge branch 'next' into develop
This commit is contained in:
commit
f343b988fa
@ -202,7 +202,7 @@ export const tableBlockSettings = new SchemaSettings({
|
||||
}, null);
|
||||
return {
|
||||
title: t('Table size'),
|
||||
value: schema?.['x-component-props']?.size || 'middle',
|
||||
value: schema?.['x-component-props']?.size || 'small',
|
||||
options: [
|
||||
{ label: t('Large'), value: 'large' },
|
||||
{ label: t('Middle'), value: 'middle' },
|
||||
|
@ -65,7 +65,7 @@ const subTableContainer = css`
|
||||
`;
|
||||
|
||||
const tableClassName = css`
|
||||
.ant-formily-item.ant-formily-item-feedback-layout-loose {
|
||||
.ant-formily-item-feedback-layout-popover {
|
||||
margin-bottom: 0px !important;
|
||||
}
|
||||
.ant-formily-editable {
|
||||
@ -202,7 +202,6 @@ export const SubTable: any = observer(
|
||||
<SubFormProvider value={{ value: null, collection, fieldSchema: fieldSchema.parent, skip: true }}>
|
||||
<Table
|
||||
className={tableClassName}
|
||||
bordered
|
||||
size={'small'}
|
||||
field={field}
|
||||
showIndex
|
||||
|
@ -795,7 +795,7 @@ export const Table: any = withDynamicSchemaProps(
|
||||
} = { ...others1, ...others2 } as any;
|
||||
const field = useArrayField(others);
|
||||
const schema = useFieldSchema();
|
||||
const { size = 'middle' } = schema?.['x-component-props'] || {};
|
||||
const { size = 'small' } = schema?.['x-component-props'] || {};
|
||||
const collection = useCollection();
|
||||
const isTableSelector = schema?.parent?.['x-decorator'] === 'TableSelectorProvider';
|
||||
const ctx = isTableSelector ? useTableSelectorContext() : useTableBlockContext();
|
||||
|
@ -66,6 +66,48 @@ describe('update associations', () => {
|
||||
expect(profile1['userId']).toBe(user.id);
|
||||
});
|
||||
|
||||
it('should update has many association with foreign key', async () => {
|
||||
const User = db.collection({
|
||||
name: 'users',
|
||||
fields: [
|
||||
{ type: 'string', name: 'name' },
|
||||
{ type: 'hasMany', name: 'profiles', foreignKey: 'userId', target: 'profiles' },
|
||||
],
|
||||
});
|
||||
|
||||
const Profile = db.collection({
|
||||
name: 'profiles',
|
||||
fields: [
|
||||
{ type: 'string', name: 'name' },
|
||||
{ type: 'bigInt', name: 'userId' },
|
||||
{ type: 'belongsTo', name: 'user', foreignKey: 'userId' },
|
||||
],
|
||||
});
|
||||
|
||||
await db.sync();
|
||||
|
||||
// create user
|
||||
const user = await User.repository.create({ values: { name: 'user1' } });
|
||||
const profile = await Profile.repository.create({ values: { name: 'profile1' } });
|
||||
|
||||
const profileData = profile.toJSON();
|
||||
await User.repository.update({
|
||||
filterByTk: user.id,
|
||||
values: {
|
||||
profiles: [
|
||||
{
|
||||
...profileData,
|
||||
userId: null,
|
||||
},
|
||||
],
|
||||
},
|
||||
updateAssociationValues: ['profiles'],
|
||||
});
|
||||
|
||||
const profile1 = await Profile.repository.findOne({ filterByTk: profile.id });
|
||||
expect(profile1['userId']).toBe(user.id);
|
||||
});
|
||||
|
||||
test('update belongs to with foreign key and object', async () => {
|
||||
const throughAB = db.collection({
|
||||
name: 'throughAB',
|
||||
|
@ -352,7 +352,11 @@ export async function updateSingleAssociation(
|
||||
|
||||
if (updateAssociationValues.includes(key)) {
|
||||
const updateValues = { ...value };
|
||||
|
||||
if (association.associationType === 'HasOne') {
|
||||
delete updateValues[association.foreignKey];
|
||||
}
|
||||
|
||||
await instance.update(updateValues, { ...options, transaction });
|
||||
}
|
||||
|
||||
@ -542,6 +546,10 @@ export async function updateMultipleAssociation(
|
||||
continue;
|
||||
}
|
||||
if (updateAssociationValues.includes(key)) {
|
||||
if (association.associationType === 'HasMany') {
|
||||
delete item[association.foreignKey];
|
||||
}
|
||||
|
||||
await instance.update(item, { ...options, transaction });
|
||||
}
|
||||
await updateAssociations(instance, item, {
|
||||
|
Loading…
x
Reference in New Issue
Block a user