client/tags: fix URL redirections

User controller didn't need intervention but I refactored it to match
tag controller anyway.
This commit is contained in:
rr- 2016-08-28 23:55:45 +02:00
parent 997eb3de63
commit acd989cabb
2 changed files with 9 additions and 6 deletions

View file

@ -22,7 +22,7 @@ class TagController {
topNavigation.setTitle('Tag #' + tag.names[0]);
this._name = ctx.parameters.name;
tag.addEventListener('change', e => this._evtSaved(e));
tag.addEventListener('change', e => this._evtSaved(e, section));
const categories = {};
for (let category of tags.getAllCategories()) {
@ -57,10 +57,11 @@ class TagController {
misc.enableExitConfirmation();
}
_evtSaved(e) {
_evtSaved(e, section) {
misc.disableExitConfirmation();
if (this._name !== e.detail.tag.names[0]) {
router.replace('/tag/' + e.detail.tag.names[0], null, false);
router.replace(
'/tag/' + e.detail.tag.names[0] + '/' + section, null, false);
}
}
@ -97,6 +98,8 @@ class TagController {
e.detail.tag.merge(e.detail.targetTagName).then(() => {
this._view.showSuccess('Tag merged.');
this._view.enableForm();
router.replace(
'/tag/' + e.detail.targetTagName + '/merge', null, false);
}, errorMessage => {
this._view.showError(errorMessage);
this._view.enableForm();

View file

@ -26,7 +26,7 @@ class UserController {
const infix = isLoggedIn ? 'self' : 'any';
this._name = userName;
user.addEventListener('change', e => this._evtSaved(e));
user.addEventListener('change', e => this._evtSaved(e, section));
const myRankIndex = api.user ?
api.allRanks.indexOf(api.user.rank) :
@ -73,11 +73,11 @@ class UserController {
misc.enableExitConfirmation();
}
_evtSaved(e) {
_evtSaved(e, section) {
misc.disableExitConfirmation();
if (this._name !== e.detail.user.name) {
router.replace(
'/user/' + e.detail.user.name + '/edit', null, false);
'/user/' + e.detail.user.name + '/' + section, null, false);
}
}