Skip to content

Creating a new view page

BinHong Lee edited this page Mar 14, 2021 · 1 revision

File and Directory Naming

All view pages (vue files) are located in /src/cockpit/views/ and have to begin with (lowercase) v prefix. (Files without v prefix will not be included in the router file.) The directory hierarchy and name of the file will affect the path of the file. For example, a file named vName.vue located in /src/cockpit/views/display/ will show up as a page in https://localhost:1234/display/name.

Parameters

The default param system by vue is somewhat limiting but at the same time provided sufficient flexibility for us to build on top of it. Due to the fact that all params are optional (in our setup), it is important to also include an implementation in the view for when a param is not found (including redirecting users to Routes.NotFound).

vID

In some occasions, you'd have a main key / ID param (mostly when linking to an object like a trip / city). In this case, we would use a 2 level param where top level is reserved for that id while next level is for everything else. Similarly, the key param is not guaranteed to exist when a user hits that vue file so its important to also handle it when that's the case.

Routing / Redirection

In order to prevent typos when redirecting / routing to different pages, a separate Route class (routes.ts) is also generated (along with router.ts) where all routes are hardcoded.

Testing

(WIP)

Clone this wiki locally