Save form after saving custom field

[MAILPOET-2592]
This commit is contained in:
Pavel Dohnal
2020-01-07 13:44:00 +01:00
committed by Rostislav Wolný
parent 8feb574623
commit bcb2f1f4d8
4 changed files with 13 additions and 13 deletions

View File

@@ -47,15 +47,18 @@ export default {
endpoint: 'customFields',
action: 'save',
data: requestData,
}).done((response) => {
dispatch('mailpoet-form-editor').saveCustomFieldDone(customField.id, response.data);
if (typeof actionData.onFinish === 'function') actionData.onFinish();
}).fail((response) => {
let errorMessage = null;
if (response.errors.length > 0) {
errorMessage = response.errors.map((error) => (error.message));
}
dispatch('mailpoet-form-editor').saveCustomFieldFailed(errorMessage);
});
})
.then((response) => {
dispatch('mailpoet-form-editor').saveCustomFieldDone(customField.id, response.data);
if (typeof actionData.onFinish === 'function') actionData.onFinish();
})
.then(dispatch('mailpoet-form-editor').saveForm)
.fail((response) => {
let errorMessage = null;
if (response.errors.length > 0) {
errorMessage = response.errors.map((error) => (error.message));
}
dispatch('mailpoet-form-editor').saveCustomFieldFailed(errorMessage);
});
},
};

View File

@@ -19,7 +19,6 @@ export default (state, action) => {
return {
...state,
isCustomFieldSaving: false,
isFormSaving: false,
notices,
customFields,
};

View File

@@ -8,7 +8,6 @@ export default (state, action) => {
});
return {
...state,
isFormSaving: false,
isCustomFieldSaving: false,
notices,
};

View File

@@ -2,7 +2,6 @@ export default (state) => {
const notices = state.notices.filter((notice) => notice.id !== 'custom-field');
return {
...state,
isFormSaving: true,
isCustomFieldSaving: true,
notices,
};