Skip to content

Commit

Permalink
Merge pull request #290 from nowcommunity/update_docs_for_tableview
Browse files Browse the repository at this point in the history
expand documentation for tableviews
  • Loading branch information
juhanikat authored Sep 27, 2024
2 parents 7d6b7bf + b79bae5 commit 64fe98f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
7 changes: 0 additions & 7 deletions documentation/columns.md

This file was deleted.

15 changes: 15 additions & 0 deletions documentation/creating_new_tableview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
### Setting up a new table view

Following things are needed to create a new page with a table (examples are all from Cross-Search):

- Backend:
- A [service](../backend/src/services/crossSearch.ts) to get the data from the database. There might be a necessities to clean the result, filter the result by project ids (pid) and user's permissions, and create a temp type for typescript.
- A [route](../backend/src/routes/crossSearch.ts) function calling the service.
- The [App](../backend/src/app.ts) should use the route.

- Frontend:
- Create necessary types in [backendtypes](../frontend/src/backendTypes.d.ts)
- Create a [component](../frontend/src/components/CrossSearch/CrossSearchTable.tsx) (note that cross search borrows the detail parts from localities). The tableview is defined via variables columns and visibleColumns. Columns in the most simple form only require an accesrKey and a header. If an accessorFn is used, a separate id is required as well. The accessorkey functions as a key to fetch data as well as an id to reference the column as well. The variable visibleColumns takes in accessorKeys or ids for columns, set to false, to be hidden by default.
- Create a button for the component in [navigation bar](../frontend/src/components/NavBar.tsx)
- Create a relevant page-object for [Pages](../frontend/src/components/pages.tsx)
- Add a route for the component to [App](../frontend/src/App.tsx)
2 changes: 1 addition & 1 deletion documentation/frontend.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

**Data tables**

+ [TableView](../frontend/src/components/TableView/TableView.tsx) is a generic component that takes in column definitions, data, and renders a [material-react-table (click for docs)](https://www.material-react-table.com/). It also handles the tables state management: for example saving column filters into url, and restoring them on first render. Defining [columns](./columns.md) in more detail.
+ [TableView](../frontend/src/components/TableView/TableView.tsx) is a generic component that takes in column definitions, data, and renders a [material-react-table (click for docs)](https://www.material-react-table.com/). It also handles the tables state management: for example saving column filters into url, and restoring them on first render. Creating a new [tableview](./creating_new_tableview.md) in more detail.

+ [DetailView](../frontend/src/components/DetailView/)-folder has components that are used by the detailed view: The view which allows looking at and editing a single data item, for example a locality. The DetailView-component is generic, allowing different data types to use it.

Expand Down

0 comments on commit 64fe98f

Please sign in to comment.