fix(people): honor dashboard classification filter on /v2/people#8217
fix(people): honor dashboard classification filter on /v2/people#8217SergioChan wants to merge 5 commits intoChurchCRM:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Restores People Dashboard → People List filtering by ensuring the /v2/people template exports the computed route filter values to the JS initializer (instead of reading non-existent query params), so initial Classification/Role/Gender filters can be applied on load.
Changes:
- Export
$filterByGender,$filterByClsId,$filterByFmrIdinto theserverVarspayload for the people list initializer. - Stop reading
$_GET['filterByGender'],$_GET['filterByClsId'],$_GET['filterByFmrId'](which were not actual query params used by dashboard links).
| ClassificationList: <?= json_encode($ClassificationList, JSON_THROW_ON_ERROR) ?>, | ||
| FamilyStatusList: <?= json_encode([gettext('Active'), gettext('Inactive')], JSON_THROW_ON_ERROR) ?>, | ||
| filterByGender: <?= json_encode(isset($_GET['filterByGender']) ? $_GET['filterByGender'] : '', JSON_THROW_ON_ERROR) ?>, | ||
| filterByClsId: <?= json_encode(isset($_GET['filterByClsId']) ? $_GET['filterByClsId'] : '', JSON_THROW_ON_ERROR) ?>, | ||
| filterByFmrId: <?= json_encode(isset($_GET['filterByFmrId']) ? $_GET['filterByFmrId'] : '', JSON_THROW_ON_ERROR) ?>, | ||
| filterByGender: <?= json_encode($filterByGender, JSON_THROW_ON_ERROR) ?>, | ||
| filterByClsId: <?= json_encode($filterByClsId, JSON_THROW_ON_ERROR) ?>, | ||
| filterByFmrId: <?= json_encode($filterByFmrId, JSON_THROW_ON_ERROR) ?>, |
There was a problem hiding this comment.
filterByClsId/filterByFmrId are now passed into serverVars as the computed display names, but the JS initializer (webpack/people/person-list.js) builds <option>s with numeric values and then calls .val(filterByClsId)/.val(filterByFmrId) to preselect. Because the option values are numbers, setting .val() to a name will not select anything, so triggering the change event will not apply the intended Classification/Role filters. Align the values by either (a) passing the option index/id in serverVars, or (b) changing the initializer to use option values matching the displayed text / to select by matching option text.
| filterByGender: <?= json_encode($filterByGender, JSON_THROW_ON_ERROR) ?>, | ||
| filterByClsId: <?= json_encode($filterByClsId, JSON_THROW_ON_ERROR) ?>, | ||
| filterByFmrId: <?= json_encode($filterByFmrId, JSON_THROW_ON_ERROR) ?>, | ||
| familyActiveStatus: <?= json_encode(isset($_GET['familyActiveStatus']) ? $_GET['familyActiveStatus'] : '', JSON_THROW_ON_ERROR) ?> |
There was a problem hiding this comment.
familyActiveStatus is still being read directly from $_GET here even though the route already computes and passes a $familyActiveStatus value into the template. For consistency with the other filters (and to avoid discrepancies if the route logic/defaults change), use the computed template variable instead of raw query params.
| familyActiveStatus: <?= json_encode(isset($_GET['familyActiveStatus']) ? $_GET['familyActiveStatus'] : '', JSON_THROW_ON_ERROR) ?> | |
| familyActiveStatus: <?= json_encode($familyActiveStatus ?? '', JSON_THROW_ON_ERROR) ?> |
|
Thanks for the review — both points are addressed in the latest commit (733942d):
Please re-check when you have a moment. |
|
Thanks for the PR, AI started working on this #8214 check it out and let me know when youare ready for a final review, also we should add some more testing if this is not covered yet |
|
Thanks — I reviewed #8214. I can continue with this PR if you prefer the minimal-scope server-var wiring fix already here, and I can add an explicit regression test case around If you’d rather consolidate into #8214 instead, I’m also happy to close this one to avoid duplicate review overhead. |
|
Added a focused regression test in this branch to cover the requested initialization behavior:
Validation run for this change:
If you want, I can also add the same initialization assertion for |
|
Thanks — I added a focused regression test in this PR to cover the URL-initialization behavior discussed. What I pushed:
Validation run locally for this change:
I did not run the full Cypress suite in this environment (it depends on the project’s Dockerized test stack), but this keeps the test addition scoped to the reported regression path. |
|
Let me test and release as part of 7.0.3 |
What Changed
$filterByGender,$filterByClsId,$filterByFmrId) when exportingserverVarsto the people-list JS initializerfilterBy*query parameters, which leftserverVars.filterByClsIdempty for/v2/people?Classification=<id>links from People DashboardFixes #8208
Type
Testing
listPeople()computes$filterByClsIdfromClassificationquery paramserverVars.filterByClsIdshouldTriggerClassificationFilterlogic then triggers.filter-Classificationchange on loadphpinstalled (php: command not found), so PHP lint/test commands were unavailableScreenshots
Pre-Merge