Open Azeirah opened 2 years ago
Hello there! Thanks for opening your first issue on this repo!
Just a heads-up: Here at Backpack we use Github Issues only for tracking bugs. Talk about new features is also acceptable. This helps a lot in keeping our focus on improving Backpack. If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below). If you're not sure where it fits, it's ok, a community member will probably reply to help you with that.
Backpack communication channels:
backpack-for-laravel
tag;Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome awesome community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch.
Thank you!
-- Justin Case The Backpack Robot
Hello @Azeirah thanks for the suggestion and such a detailed explanation. This seems like a very good approach to the problem, I already implemented myself something like this to filter charts but not using CrudFilters. (way way more basic) Do you have a screenshot of the final result that you can share?
Cheers
I don't currently have access to the code I wrote for this, but I probably have it in a branch on my PC, but I don't have access to it for a week or so.
Anyway, concerning how it'd look it's literally just the same thing as using filters on table pages, but the filters are present above the cards for graphs.
If you're interested, I can make some time implementing this as some contract work, as I already did most work needed?
Feature Request
What's the feature you think Backpack should have?
I think we should be able to add filters to chart widgets
Have you already implemented a prototype solution, for your own project?
I have, this is oddly enough not super complicated to add. What I changed:
Changes on the backend
After you create a new ChartController, add the
Filter
andSettings
traits, and define thegetCurrentOperation
function to return'list'
(to prevent errors)$this->addFilter
in your ChartController.Changes on the frontend
I had to make some changes to the chart widget blade file as well
id=bp-filters-navbar
style="display: none"
to silence the errors. In the real code you would of course just place checks in place to see if the dataTable is present at all. You can always get the initial ajax_url fromnew URI(window.location.href)
in case dataTable is not present on the page.updateChartOnFilterChange
which is called at the same places asupdateDatatablesOnFilterChange
, it receives{{$filter->key}}
as its first parameter instead of{{$filter->name}}
.simple
widget for some reason does not callupdateDatatablesOnFilterChange
, I added the appropriate calls manually.$(this).closest('.card-body').find('canvas').attr('id');
data-ajax-url
, this is set in this function as well, but needs to be retrieved in every widget code body in the right locationsvar refresh_chart = Object.keys(window).filter((key)=>key.contains(chart_id))[0];
With these changes put together, you get the same filtering functionality and ui as on list view datatables.
Do you see this as a core feature or an add-on?
Core feature for pro.