Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,17 @@
$this->insertHeaderOnIos();
$this->initialState->provideInitialState('maxStringLengths', Constants::MAX_STRING_LENGTHS);
$this->initialState->provideInitialState('appConfig', $this->configService->getAppConfig());

if (isset($hash)) {
$this->initialState->provideInitialState('formId', $this->formMapper->findByHash($hash)->id);
try {
$form = $this->formMapper->findByHash($hash);
$this->initialState->provideInitialState('formId', $form->id);
} catch (DoesNotExistException $e) {

Check warning on line 78 in lib/Controller/PageController.php

View check run for this annotation

Codecov / codecov/patch

lib/Controller/PageController.php#L76-L78

Added lines #L76 - L78 were not covered by tests
// Provide null to indicate no form was found
$this->initialState->provideInitialState('formId', 'invalid');

Check warning on line 80 in lib/Controller/PageController.php

View check run for this annotation

Codecov / codecov/patch

lib/Controller/PageController.php#L80

Added line #L80 was not covered by tests
}
}

return new TemplateResponse($this->appName, self::TEMPLATE_MAIN, [
'id-app-content' => '#app-content-vue',
'id-app-navigation' => '#app-navigation-vue',
Expand Down
14 changes: 9 additions & 5 deletions src/Forms.vue
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,11 @@ export default {

// If the user is allowed to access this route
routeAllowed() {
// Check formId from initial state on app initialization
if (this.loading && loadState(appName, 'formId') === 'invalid') {
return false
}

// Not allowed, if no hash
if (!this.routeHash) {
return false
Expand Down Expand Up @@ -420,17 +425,16 @@ export default {
showError(t('forms', 'Form not found'))

if ([403, 404].includes(error.response?.status)) {
this.$router.push({ name: 'root' })
if (this.$route.name !== 'root') {
this.$router.push({ name: 'root' })
}
}
}
}

this.loading = false
},

/**
*
*/
async onNewForm() {
try {
// Request a new empty form
Expand Down Expand Up @@ -487,7 +491,7 @@ export default {
this.forms.splice(formIndex, 1)

// Redirect if current form has been deleted
if (deletedHash === this.routeHash) {
if (deletedHash === this.routeHash && this.$route.name !== 'root') {
this.$router.push({ name: 'root' })
}
},
Expand Down
Loading