Refactoring of fe4ebd58: Set Close/Back buttons to always browse back

This commit is contained in:
Bubka 2023-08-30 14:33:43 +02:00
parent 70313995b9
commit d7942b4233
6 changed files with 17 additions and 53 deletions

View File

@ -4,7 +4,7 @@
<div class="tabs is-centered is-fullwidth">
<ul>
<li v-for="tab in tabs" :key="tab.view" :class="{ 'is-active': tab.view === activeTab }">
<router-link :id="tab.id" :to="{ name: tab.view }">{{ tab.name }}</router-link>
<router-link :id="tab.id" :to="{ name: tab.view, params: {returnTo: $route.params.returnTo} }">{{ tab.name }}</router-link>
</li>
</ul>
</div>

View File

@ -85,6 +85,22 @@ router.beforeEach((to, from, next) => {
if (to.name !== 'login' && to.meta.requiresAuth && ! Vue.$storage.get('authenticated', false)) {
next({ name: 'login' })
}
else if (to.name.startsWith('settings.')) {
if (to.params.returnTo == undefined) {
if (from.params.returnTo) {
next({name: to.name, params: { returnTo: from.params.returnTo }})
}
else if (from.name) {
next({name: to.name, params: { returnTo: from.path }})
}
else {
next({name: to.name, params: { returnTo: '/accounts' }})
}
}
else {
next()
}
}
else if (to.matched.some(record => record.meta.disabledWithAuthProxy)) {
if (window.appConfig.proxyAuth) {
next({ name: 'accounts' })

View File

@ -151,19 +151,6 @@
},
},
beforeRouteEnter(to, from, next) {
next(vm => {
if (from.params.returnTo) {
to.params.returnTo = from.params.returnTo
}
else {
to.params.returnTo = from.name
? from.path
: '/accounts'
}
})
},
beforeRouteLeave(to, from, next) {
if (to.name == 'accounts') {
this.$notify({ clean: true })

View File

@ -156,19 +156,6 @@
},
},
beforeRouteEnter(to, from, next) {
next(vm => {
if (from.params.returnTo) {
to.params.returnTo = from.params.returnTo
}
else {
to.params.returnTo = from.name
? from.path
: '/accounts'
}
})
},
beforeRouteLeave(to, from, next) {
if (to.name == 'accounts') {
this.$notify({ clean: true })

View File

@ -260,19 +260,6 @@
},
beforeRouteEnter(to, from, next) {
next(vm => {
if (from.params.returnTo) {
to.params.returnTo = from.params.returnTo
}
else {
to.params.returnTo = from.name
? from.path
: '/accounts'
}
})
},
beforeRouteLeave(to, from, next) {
if (to.name == 'accounts') {
this.$notify({ clean: true })

View File

@ -224,19 +224,6 @@
},
beforeRouteEnter(to, from, next) {
next(vm => {
if (from.params.returnTo) {
to.params.returnTo = from.params.returnTo
}
else {
to.params.returnTo = from.name
? from.path
: '/accounts'
}
})
},
beforeRouteLeave(to, from, next) {
if (to.name == 'accounts') {
this.$notify({ clean: true })