bcgov / bcgov/entity

Edit UI: move code from App.vue into router, etc

Open
#15,657 0 comments 0 reactions 0 assignees View on GitHub
ENTITY - DO NOT USE techdebt
Dominant language
JavaScript
Stars
23
Forks
62
Avg merge
24m
Merged PRs (30d)
1

Description

## TODO
- [ ] filing type should either set in VueRouter and passed as a prop to all Views
- [ ] businessID should be passed into all Views as a prop from VueRouter
- [ ] fetchData() should be moved to a common mixin and triggered from all Views

## What is the problem?
In Edit-ui, App.vue has the following method that watches for route changes and sets a filing type, business-id and triggers the loading of data.

```javascript
/** Called when $route property changes. */
@Watch('$route', { immediate: false })
private async onRouteChanged (): Promise {
// init only if we are not on signin or signout route
if (!this.isRouteName(RouteNames.SIGN_IN) && !this.isRouteName(RouteNames.SIGN_OUT)) {
// store current filing type
const filingType = this.$route.matched[0]?.meta.filingType
filingType && this.setFilingType(filingType)

// get and store Business ID
const businessId = sessionStorage.getItem('BUSINESS_ID')
this.setBusinessId(businessId)

// initialize app
await this.fetchData(true)
}
}

```

## What is the impact?
Placing route logic in App.vue makes our code less flexible. Above, a conditional has been added to exclude the logic from being called by the sign-in or sign-out pages. If we change the edit-ui routes, this method would need to be checked and updated.

Also, when this application reaches a maintenance stage, it makes troubleshooting and resolving problem significantly more difficult when applications don't group logic in the same place.

## Proposed solution
By placing the route logic in either the VueRouter configuration or in the appropriate View, we keep routing logic in one place and where it's expected.

- filing type should either set in VueRouter and past as a prop to the View
- businessID should be past into the View as a prop from VueRouter (see #15653)
- `fetchData()` should be triggered from the View

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.