client/posts: fix merge could be used only once
This commit is contained in:
parent
58fabc6e36
commit
ac98b7d8e6
|
@ -18,14 +18,7 @@ class PostDetailController extends BasePostController {
|
||||||
this._id = ctx.parameters.id;
|
this._id = ctx.parameters.id;
|
||||||
post.addEventListener('change', e => this._evtSaved(e, section));
|
post.addEventListener('change', e => this._evtSaved(e, section));
|
||||||
|
|
||||||
this._view = new PostDetailView({
|
this._installView(post, section);
|
||||||
post: post,
|
|
||||||
section: section,
|
|
||||||
canMerge: api.hasPrivilege('posts:merge'),
|
|
||||||
});
|
|
||||||
|
|
||||||
this._view.addEventListener('select', e => this._evtSelect(e));
|
|
||||||
this._view.addEventListener('merge', e => this._evtMerge(e));
|
|
||||||
}, errorMessage => {
|
}, errorMessage => {
|
||||||
this._view = new EmptyView();
|
this._view = new EmptyView();
|
||||||
this._view.showError(errorMessage);
|
this._view.showError(errorMessage);
|
||||||
|
@ -36,6 +29,17 @@ class PostDetailController extends BasePostController {
|
||||||
this._view.showSuccess(message);
|
this._view.showSuccess(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_installView(post, section) {
|
||||||
|
this._view = new PostDetailView({
|
||||||
|
post: post,
|
||||||
|
section: section,
|
||||||
|
canMerge: api.hasPrivilege('posts:merge'),
|
||||||
|
});
|
||||||
|
|
||||||
|
this._view.addEventListener('select', e => this._evtSelect(e));
|
||||||
|
this._view.addEventListener('merge', e => this._evtMerge(e));
|
||||||
|
}
|
||||||
|
|
||||||
_evtSelect(e) {
|
_evtSelect(e) {
|
||||||
this._view.clearMessages();
|
this._view.clearMessages();
|
||||||
this._view.disableForm();
|
this._view.disableForm();
|
||||||
|
@ -61,11 +65,7 @@ class PostDetailController extends BasePostController {
|
||||||
this._view.disableForm();
|
this._view.disableForm();
|
||||||
e.detail.post.merge(e.detail.targetPost.id, e.detail.useOldContent)
|
e.detail.post.merge(e.detail.targetPost.id, e.detail.useOldContent)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this._view = new PostDetailView({
|
this._installView(e.detail.post, 'merge');
|
||||||
post: e.detail.targetPost,
|
|
||||||
section: 'merge',
|
|
||||||
canMerge: api.hasPrivilege('posts:merge'),
|
|
||||||
});
|
|
||||||
this._view.showSuccess('Post merged.');
|
this._view.showSuccess('Post merged.');
|
||||||
router.replace(
|
router.replace(
|
||||||
'/post/' + e.detail.targetPost.id + '/merge', null, false);
|
'/post/' + e.detail.targetPost.id + '/merge', null, false);
|
||||||
|
|
Loading…
Reference in New Issue