Merge pull request #377 from nextcloud/fix/redirects

Fix redirects
This commit is contained in:
Jan C. Borchardt 2020-05-11 19:24:00 +02:00 committed by GitHub
commit 14213f91bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 5 deletions

View file

@ -32,7 +32,7 @@
</AppNavigation>
<!-- No forms & loading emptycontents -->
<AppContent v-if="loading || noForms || (!hash && $route.name !== 'create')">
<AppContent v-if="loading || noForms || (!routeHash && $route.name !== 'create')">
<EmptyContent v-if="loading" icon="icon-loading">
{{ t('forms', 'Loading forms …') }}
</EmptyContent>
@ -102,16 +102,16 @@ export default {
return this.forms && this.forms.length === 0
},
hash() {
routeHash() {
return this.$route.params.hash
},
selectedForm: {
get() {
return this.forms.find(form => form.hash === this.hash)
return this.forms.find(form => form.hash === this.routeHash)
},
set(form) {
const index = this.forms.findIndex(search => search.hash === this.hash)
const index = this.forms.findIndex(search => search.hash === this.routeHash)
if (index > -1) {
this.$set(this.forms, index, form)
}
@ -163,7 +163,14 @@ export default {
*/
async onDeleteForm(id) {
const formIndex = this.forms.findIndex(form => form.id === id)
const deletedHash = this.forms[formIndex].hash
this.forms.splice(formIndex, 1)
// Redirect if current form has been deleted
if (deletedHash === this.routeHash) {
this.$router.push({ name: 'root' })
}
},
},
}

View file

@ -58,7 +58,7 @@ export default new Router({
path: '/:hash/results',
component: Results,
name: 'results',
props: { default: true },
props: true,
},
],
})

View file

@ -139,6 +139,13 @@ export default {
},
},
watch: {
// Reload results, when form changes
hash() {
this.loadFormResults()
},
},
beforeMount() {
this.loadFormResults()
SetWindowTitle(this.formTitle)