Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/table component #2786

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Feat/table component #2786

wants to merge 7 commits into from

Conversation

jfmcquade
Copy link
Collaborator

@jfmcquade jfmcquade commented Feb 7, 2025

PR Checklist

  • PR title descriptive (can be used in release notes)

Description

A very basic table component using @angular/material's table library.

Allows for sorting on columns.

TODO:

  • Add pagination (see docs)
  • Custom styling

This is component is currently in use on the conflict_forecast deployment (which builds from the deployment/conflict_forecast branch). See web riots_list_view_page template, web preview here.

Git Issues

Closes #2519

Screenshots/Videos

Demo of comp_table:

table.demo.mov

@jfmcquade jfmcquade requested a review from chrismclarke March 6, 2025 16:20
@jfmcquade jfmcquade marked this pull request as ready for review March 6, 2025 16:21
})
export class TmplTableComponent extends TemplateBaseComponent implements AfterViewInit {
params = computed(() => this.getParams(this.parameterList()));
dataRows = computed(() => this.getDataRowsFromValue(this.value()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit(blocking): the getDataRows from value function is async, so this computed will not behave as expected (no such thing as async computed). Instead it would be better to use an effect to respond to value changes and set the dataRows as a signal. I think it still kinda works in the frontend due to the additional cdr calls, but I'd consider that to be more of a bug than expected behaviour

LottieModule,
MatSortModule,
MatTableModule,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit(non-blocking): I can't remember how well we've implemented optimisation for this module, but might be more viable to include the imports in the table component itself and turn into a standalone component so that the modules are easier to remove from build when the component is not needed

Copy link
Member

@chrismclarke chrismclarke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jfmcquade
Overall I think component code is set out nicely and feature works well.

Longer term I'm still unsure whether we want to be importing the entire angular-material library just for one component, although at least with tree-shaking it only adds about 64kb to bundle size (which is still less than some components like pdf, lottie or odk viewer), and hopefully we can find a sensible way to include in optimisation system to remove from deployments that don't include the component

image

Longer term I think we'd come across similar bundle sizes if implementing AgGrid, so I think the only reasonable alternative would be Tanstack Table, although that would mean implementing quite a bit more UI code so I think maybe keep as-is for now.

Regarding my own use case to render data-items in a table, I think likely I'd be best creating another component (likely data_table component) that handles data subscriptions and finds a way to just pass the final row data to this component (may include minor refactor).

For the demo case you presented I think it might be good to include a few additional authoring options to implement pagination, as I can see the large data list is quite painful to render otherwise. I'll make a follow-up PR to address this and the other blocking issues I've raised

@chrismclarke chrismclarke mentioned this pull request Mar 10, 2025
4 tasks
@chrismclarke
Copy link
Member

@jfmcquade
See my proposed changes in #2838

Once happy may also want to tag Esmee for functional testing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Data table component
2 participants