client/posts: improve form behavior when saving
- Disable and enable the form - Notify about success in the sidebar - Notify about errors in the sidebar rather than using a native alert
This commit is contained in:
parent
dbf44ed58f
commit
193e34aff8
2 changed files with 21 additions and 4 deletions
|
@ -101,7 +101,7 @@ class PostController {
|
||||||
}
|
}
|
||||||
|
|
||||||
_evtPostEdit(e) {
|
_evtPostEdit(e) {
|
||||||
// TODO: disable form
|
this._view.sidebarControl.disableForm();
|
||||||
const post = e.detail.post;
|
const post = e.detail.post;
|
||||||
if (e.detail.tags !== undefined) {
|
if (e.detail.tags !== undefined) {
|
||||||
post.tags = e.detail.tags;
|
post.tags = e.detail.tags;
|
||||||
|
@ -123,11 +123,12 @@ class PostController {
|
||||||
}
|
}
|
||||||
post.save()
|
post.save()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
this._view.sidebarControl.showSuccess('Post saved.');
|
||||||
|
this._view.sidebarControl.enableForm();
|
||||||
misc.disableExitConfirmation();
|
misc.disableExitConfirmation();
|
||||||
// TODO: enable form
|
|
||||||
}, errorMessage => {
|
}, errorMessage => {
|
||||||
window.alert(errorMessage);
|
this._view.sidebarControl.showError(errorMessage);
|
||||||
// TODO: enable form
|
this._view.sidebarControl.enableForm();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -144,6 +144,22 @@ class PostEditSidebarControl extends events.EventTarget {
|
||||||
return this._formNode.querySelector(
|
return this._formNode.querySelector(
|
||||||
'.post-thumbnail .dropper-container');
|
'.post-thumbnail .dropper-container');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enableForm() {
|
||||||
|
views.enableForm(this._formNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
disableForm() {
|
||||||
|
views.disableForm(this._formNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
showSuccess(message) {
|
||||||
|
views.showSuccess(this._hostNode, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
showError(message) {
|
||||||
|
views.showError(this._hostNode, message);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = PostEditSidebarControl;
|
module.exports = PostEditSidebarControl;
|
||||||
|
|
Loading…
Reference in a new issue