refactor: default role & default field storage (#3844)

* refactor: default role & default field storage

* refactor: verification

* refactor: verification
This commit is contained in:
katherinehhh 2024-03-28 16:47:43 +08:00 committed by GitHub
parent 0191070547
commit 9a66301ec7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 0 deletions

View File

@ -101,6 +101,7 @@ export const Form: React.FC<FormProps> & { Designer?: any } = observer(
async onSuccess(data) {
await form.reset();
form.setValues(data?.data);
form.setInitialValues(data?.data);
},
},
props,

View File

@ -43,6 +43,13 @@ export const roleEditSchema = {
'x-component': 'CollectionField',
'x-decorator': 'FormItem',
'x-content': '{{t("Default role")}}',
'x-reactions': (field) => {
if (field.initialValue) {
field.disabled = true;
} else {
field.disabled = false;
}
},
},
footer: {
type: 'void',

View File

@ -96,6 +96,15 @@ export const EditStorage = () => {
onClick={() => {
setVisible(true);
const storageType = plugin.storageTypes.get(record.type);
if (storageType.properties['default']) {
storageType.properties['default']['x-reactions'] = (field) => {
if (field.initialValue) {
field.disabled = true;
} else {
field.disabled = false;
}
};
}
setSchema({
type: 'object',
properties: {