mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 08:26:21 +00:00
fix: button loading does not disappear when the operation submit failed (#1698)
* fix: button loading does not disappear when the view operation submission failed * fix: add field button loading * refactor: code improve
This commit is contained in:
parent
12f95810d0
commit
eeb07112c7
@ -201,30 +201,35 @@ const useCreateCollection = (schema?: any) => {
|
||||
async run() {
|
||||
field.data = field.data || {};
|
||||
field.data.loading = true;
|
||||
await form.submit();
|
||||
const values = cloneDeep(form.values);
|
||||
if (schema?.events?.beforeSubmit) {
|
||||
schema.events.beforeSubmit(values);
|
||||
try {
|
||||
await form.submit();
|
||||
const values = cloneDeep(form.values);
|
||||
if (schema?.events?.beforeSubmit) {
|
||||
schema.events.beforeSubmit(values);
|
||||
}
|
||||
const fields = values?.template !== 'view' ? useDefaultCollectionFields(values) : values.fields;
|
||||
if (values.autoCreateReverseField) {
|
||||
} else {
|
||||
delete values.reverseField;
|
||||
}
|
||||
delete values.id;
|
||||
delete values.autoCreateReverseField;
|
||||
|
||||
await resource.create({
|
||||
values: {
|
||||
logging: true,
|
||||
...values,
|
||||
fields,
|
||||
},
|
||||
});
|
||||
ctx.setVisible(false);
|
||||
await form.reset();
|
||||
field.data.loading = false;
|
||||
refresh();
|
||||
await refreshCM();
|
||||
} catch (error) {
|
||||
field.data.loading = false;
|
||||
}
|
||||
const fields = values?.template !== 'view' ? useDefaultCollectionFields(values) : values.fields;
|
||||
if (values.autoCreateReverseField) {
|
||||
} else {
|
||||
delete values.reverseField;
|
||||
}
|
||||
delete values.id;
|
||||
delete values.autoCreateReverseField;
|
||||
await resource.create({
|
||||
values: {
|
||||
logging: true,
|
||||
...values,
|
||||
fields,
|
||||
},
|
||||
});
|
||||
ctx.setVisible(false);
|
||||
await form.reset();
|
||||
field.data.loading = false;
|
||||
refresh();
|
||||
await refreshCM();
|
||||
},
|
||||
};
|
||||
};
|
||||
|
@ -148,12 +148,16 @@ const useCreateCollectionField = () => {
|
||||
delete values.reverseField;
|
||||
}
|
||||
delete values.autoCreateReverseField;
|
||||
await resource.create({ values });
|
||||
ctx.setVisible(false);
|
||||
await form.reset();
|
||||
field.data.loading = false;
|
||||
refresh();
|
||||
await refreshCM();
|
||||
try {
|
||||
await resource.create({ values });
|
||||
ctx.setVisible(false);
|
||||
await form.reset();
|
||||
field.data.loading = false;
|
||||
refresh();
|
||||
await refreshCM();
|
||||
} catch (error) {
|
||||
field.data.loading = false;
|
||||
}
|
||||
},
|
||||
};
|
||||
};
|
||||
|
@ -136,15 +136,19 @@ const useSyncFromDatabase = () => {
|
||||
await form.submit();
|
||||
field.data = field.data || {};
|
||||
field.data.loading = true;
|
||||
await api.resource(`collections`).setFields({
|
||||
filterByTk,
|
||||
values: form.values,
|
||||
});
|
||||
ctx.setVisible(false);
|
||||
await form.reset();
|
||||
field.data.loading = false;
|
||||
refresh();
|
||||
await refreshCM();
|
||||
try {
|
||||
await api.resource(`collections`).setFields({
|
||||
filterByTk,
|
||||
values: form.values,
|
||||
});
|
||||
ctx.setVisible(false);
|
||||
await form.reset();
|
||||
field.data.loading = false;
|
||||
refresh();
|
||||
await refreshCM();
|
||||
} catch (error) {
|
||||
field.data.loading = false;
|
||||
}
|
||||
},
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user