mirror of
https://gitee.com/nocobase/nocobase.git
synced 2024-12-05 21:57:45 +08:00
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:
parent
5d95eed09a
commit
9101bbbb1b
@ -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 }}>
|
||||
|
@ -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',
|
||||
|
@ -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: {
|
||||
|
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user