Skip to content

Commit

Permalink
NEW Add notification on save action
Browse files Browse the repository at this point in the history
  • Loading branch information
raissanorth committed Sep 25, 2018
1 parent c6a995f commit e12f67c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 9 deletions.
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

42 changes: 34 additions & 8 deletions client/src/components/ElementActions/SaveAction.js
Expand Up @@ -16,7 +16,9 @@ const SaveAction = (MenuComponent) => (props) => {
const handleClick = (event) => {
event.stopPropagation();

const { id, securityId } = props;
const { id, title, securityId } = props;

const { jQuery: $ } = window;

const formData = getSerializedFormData(`Form_ElementForm_${id}`);

Expand All @@ -30,14 +32,38 @@ const SaveAction = (MenuComponent) => (props) => {
};

const endpoint = backend.createEndpointFetcher(endpointSpec);
endpoint(formData).then(() => {
// Update the Apollo query cache with the new form data
const { apolloClient } = window.ss;
endpoint(formData)
.then(() => {
// Update the Apollo query cache with the new form data
const { apolloClient } = window.ss;

// @todo optimistically update the data for the current element instead of
// rerunning the whole query
apolloClient.queryManager.reFetchObservableQueries();

// @todo optimistically update the data for the current element instead of
// rerunning the whole query
apolloClient.queryManager.reFetchObservableQueries();
});
$.noticeAdd({
text: i18n.inject(
i18n._t(
'SaveAction.SUCCESS_NOTIFICATION',
'Saved \'{title}\' successfully'),
{ title }
),
stay: false,
type: 'success'
});
})
.catch(() => {
$.noticeAdd({
text: i18n.inject(
i18n._t(
'SaveAction.ERROR_NOTIFICATION',
'Error saving \'{title}\''),
{ title }
),
stay: false,
type: 'error'
});
});
};

const newProps = {
Expand Down

0 comments on commit e12f67c

Please sign in to comment.