chore: skip sync overriding field default value (#1762)

* chore: skip sync overriding field default value

* chore: test

* chore: override field does not allow setting default values

---------

Co-authored-by: katherinehhh <katherine_15995@163.com>
This commit is contained in:
ChengLei Shao 2023-04-25 19:31:16 +08:00 committed by GitHub
parent 5d95eed09a
commit 9101bbbb1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 57 additions and 1 deletions

View File

@ -45,6 +45,7 @@ const getSchema = (schema: IField, record: any, compile, getContainer): ISchema
},
},
};
properties['defaultValue']['x-disabled'] = record.overriding;
}
return {
@ -143,7 +144,6 @@ export const EditFieldAction = (props) => {
const { t } = useTranslation();
const compile = useCompile();
const [data, setData] = useState<any>({});
return (
<RecordProvider record={record}>
<ActionContext.Provider value={{ visible, setVisible }}>

View File

@ -25,6 +25,7 @@ const getSchema = (schema: IField, record: any, compile, getContainer): ISchema
properties['defaultValue'] = cloneDeep(schema.default.uiSchema);
properties['defaultValue']['title'] = compile('{{ t("Default value") }}');
properties['defaultValue']['x-decorator'] = 'FormItem';
properties['defaultValue']['x-disabled'] = true;
}
return {
type: 'object',

View File

@ -24,6 +24,56 @@ pgOnly()('Inherited Collection', () => {
await app.destroy();
});
it('should update overridden multiple select field', async () => {
await collectionRepository.create({
values: {
name: 'parent',
fields: [
{ type: 'string', name: 'name' },
{
type: 'array',
name: 'selectors',
uiSchema: {
enum: [{ value: '123', label: '123' }],
},
},
],
},
context: {},
});
await collectionRepository.create({
values: {
name: 'child',
inherits: ['parent'],
fields: [
{
type: 'array',
name: 'selectors',
uiSchema: {
enum: [{ value: '123', label: '123' }],
},
overriding: true,
},
],
},
context: {},
});
await fieldsRepository.update({
filter: {
name: 'selectors',
collectionName: 'child',
},
values: {
uiSchema: {
enum: [{ value: '223', label: '223' }],
},
defaultValue: [],
},
});
});
it("should not delete child's field when parent field delete that inherits from multiple table", async () => {
await collectionRepository.create({
values: {

View File

@ -163,6 +163,11 @@ export class FieldModel extends MagicAttributeModel {
const field = collection.getField(this.get('name'));
// overriding field should not sync default value
if (field.get('overriding')) {
return;
}
const queryInterface = collection.db.sequelize.getQueryInterface();
await queryInterface.changeColumn(