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: filter live services from drop-down menu in admin dashboard #4344

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

jamdelion
Copy link
Contributor

@jamdelion jamdelion commented Feb 18, 2025

In this PR

  • Add the ability to filter columns whose values are an array by using a multi select drop-down modelled on MUI's autocomplete.
  • If an array item is selected, display it in bold in the filtered rows.
  • Be able to delete array items from the filter.
  • Generally tidy up the array list by alphabetising, stripping white space etc
  • Refactor to utils file

Please thoroughly test the filtering of all the columns and check it behaves as expected (note the Article 4s column is an outstanding issue to come back to).

Mild concerns

There are a few types I need to come back to - substituted a lot of anys while I was hacking/prototyping.

I think I've got a bit too down in the weeds with this to properly see if it remains readable/easy to use the generic component. Hopefully fresh eyes/time will help, and implementing it in the next few features!

Copy link

github-actions bot commented Feb 18, 2025

Pizza

Deployed 4d1b202 to https://4344.planx.pizza.

Useful links:

}
return getDoubleFilterFn(filterItem);
},
InputComponent: filteringOne ? SingleInputFilter : DoubleInputFilter,
Copy link
Member

Choose a reason for hiding this comment

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

Ideally, it seems like this would/should be select-one or select-many (rather than select-two). Out of curiousity, have you tried passing in our existing SelectMultiple component here?

@@ -38,7 +38,7 @@ export const mockTeams: AdminPanelData[] = [
liveFlows: [
"Notify completion of planning application",
"Find out if you need planning permission",
"Apply for prior approval",
"apply for prior approval ",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

To test the whitespace and casing processes

getRowHeight={() => "auto"}
getRowClassName={(params) =>
params.indexRelativeToCurrentPage % 2 === 0 ? "even" : "odd"
}
slots={{
toolbar: GridToolbar,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adds the additional toolbar at the top of the table

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Decided to make a separate component from the SelectMultiple since a lot of the props were superfluous, and the styling a bit different!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some of these moved across from DataTable.tsx

@jamdelion jamdelion marked this pull request as ready for review February 20, 2025 16:32
@jamdelion jamdelion requested a review from a team February 20, 2025 16:32
Copy link
Member

@jessicamcinchak jessicamcinchak left a comment

Choose a reason for hiding this comment

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

Took a quick pass through the code - only a few very minor comments, otherwise looking great !

Happy to do final review & approval today once pizza is up 👍

Agree that if this is "working" now, then best way to test current re-useability-ness and spot any further prop tweaking is to just implement it again soon for another case 🙂

}
: {
...baseColDef,
width: column.width || baseColDef.width,
Copy link
Member

Choose a reason for hiding this comment

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

nit: it looks like width could be part of shared baseColDef? Otherwise this feels clear considering level of complexity ➕


const containsItem = (item: string, value: Pick<GridFilterItem, "value">) => {
if (typeof value === "string") {
return item.toLowerCase().includes((value as string).toLowerCase());
Copy link
Member

Choose a reason for hiding this comment

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

nit: do we actually need (value as string) casting still if we're within this conditional if (typeof value === "string") block?

No worries if so, understand MUI types can be fiddly sometimes - but this looks like might be leftover from another iteration?

options: columnValueOptions,
},
},
];
Copy link
Member

Choose a reason for hiding this comment

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

Super clear, easy to revisit 💯

))}
</Box>
),
};
Copy link
Member

Choose a reason for hiding this comment

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

nit: took me a minute to unpack what componentRegistry meant here - is something like cellValueRegistry or valueOptionsRegistry more specific maybe?

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.

2 participants