fix: refresh expenses table when date range or filters change - #4633
fix: refresh expenses table when date range or filters change#4633richardmilles wants to merge 4 commits into
Conversation
Restore the daterangepicker apply and filter change handlers so /expenses/search receives the selected start_date and end_date instead of today's date for both. Fixes opensourcepos#4596
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe expenses view now refreshes the expense table when the filter dropdown closes and when a date range is applied. The existing date-range picker initialization remains unchanged. ChangesExpense table refresh
Estimated code review effort: 1 (Trivial) | ~5 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@CodeRabbit was this pattern missing in expenses view specifcally? |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo '=== PR diff ==='
git diff HEAD^ HEAD -- app/Views/expenses/manage.php
echo
echo '=== Expenses view outline ==='
ast-grep outline app/Views/expenses/manage.php --items all || true
echo
echo '=== Date-range and select-close handler patterns in views ==='
rg -n -C 4 --glob '*.php' \
'(daterangepicker|apply\.daterangepicker|close\.bs\.select|start_date|end_date)' \
app/ViewsLength of output: 26191
This pattern is not present in every date-range view. For example, You are interacting with an AI system. |
|
@CodeRabbit is this bug also present in other views? |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo '=== Date-range picker candidates ==='
rg -n -C 5 --glob '*.php' \
'(daterangepicker|apply\.daterangepicker|start_date|end_date|refreshOptions|bootstrapTable)' \
app/Views
echo
echo '=== View structure for files that initialize daterangepicker ==='
while IFS= read -r file; do
echo
echo "--- $file ---"
ast-grep outline "$file" --items all || true
done < <(rg -l --glob '*.php' 'daterangepicker\s*\(' app/Views)Length of output: 35525 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo '=== Cashups view script and shared partial inclusions ==='
sed -n '15,50p' app/Views/cashups/manage.php
rg -n -C 3 "table_filter_persistence|apply\.daterangepicker|hidden\.bs\.select|table_support\.refresh" \
app/Views/cashups/manage.php
echo
echo '=== Items view script and shared partial inclusions ==='
sed -n '15,85p' app/Views/items/manage.php
rg -n -C 3 "table_filter_persistence|apply\.daterangepicker|hidden\.bs\.select|table_support\.refresh" \
app/Views/items/manage.php
echo
echo '=== All manage views that initialize the shared date-range picker ==='
rg -n -C 3 --glob 'manage.php' \
"view\('partial/daterangepicker'\)|apply\.daterangepicker|hidden\.bs\.select|table_support\.refresh" \
app/Views
echo
echo '=== Uses of the table-filter persistence partial ==='
rg -n -C 3 "view\('partial/table_filter_persistence'\)" app/ViewsLength of output: 11031
Both views update the shared
The report input views do not have this defect. They use the selected dates when the user clicks Generate Report, instead of reloading a main table. You are interacting with an AI system. |
|
@CodeRabbit I will reject this change ideally we also use filter persistence once a range is selected, we change the URL |
|
Tip For best results, initiate chat on the files or code changes.
🐇︵︵ ✏️ Learnings added
You are interacting with an AI system. |
|
@CodeRabbit can you male these changes? |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo '=== Candidate files ==='
fd -t f -p 'manage.php' app/Views/expenses app/Views/sales app/Views || true
fd -t f 'table_filter_persistence.php' app/Views || true
fd -t f 'daterangepicker.php' app/Views || true
echo
echo '=== Expenses view outline ==='
ast-grep outline app/Views/expenses/manage.php --items all
echo
echo '=== Expenses date-range and table handlers ==='
rg -n -C 8 \
'(queryParams|daterangepicker|apply\.daterangepicker|hidden\.bs\.select|table_support\.refresh|table_filter_persistence|start_date|end_date)' \
app/Views/expenses/manage.php
echo
echo '=== Shared persistence partial ==='
persistence_file="$(fd -t f 'table_filter_persistence.php' app/Views | head -n 1)"
if [ -n "$persistence_file" ]; then
cat -n "$persistence_file"
fi
echo
echo '=== Shared date-range partial ==='
daterange_file="$(fd -t f 'daterangepicker.php' app/Views | head -n 1)"
if [ -n "$daterange_file" ]; then
cat -n "$daterange_file"
fi
echo
echo '=== Comparable manage-view event handlers ==='
rg -n -C 8 --glob 'manage.php' \
'(apply\.daterangepicker|hidden\.bs\.select|table_filter_persistence|table_support\.refresh)' \
app/ViewsLength of output: 32673 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo '=== All persistence-partial consumers ==='
rg -n -C 12 "view\('partial/table_filter_persistence'" app
echo
echo '=== Consumer date and filter handlers ==='
while IFS= read -r file; do
echo
echo "--- $file ---"
rg -n -C 8 \
'(hidden\.bs\.select|apply\.daterangepicker|table_support\.refresh|daterangepicker|filters)' \
"$file" || true
done < <(rg -l "view\('partial/table_filter_persistence'" app)
echo
echo '=== Candidate view and JavaScript tests ==='
fd -t f . tests app | rg '(Expenses|expenses|table_filter_persistence|daterangepicker|manage).*([Tt]est|test|spec)\.(php|js)$' || true
echo
echo '=== References to custom jQuery events for table persistence ==='
rg -n -C 4 \
'(trigger\s*\(|\.on\s*\().*(filter|persist|url|table_support)' \
app tests || trueLength of output: 8625 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo '=== Persistence-partial consumers ==='
rg -n -C 10 "view\('partial/table_filter_persistence'" app
echo
echo '=== Items handlers ==='
rg -n -C 10 \
'(hidden\.bs\.select|apply\.daterangepicker|table_support\.refresh|daterangepicker|filters|stock_location)' \
app/Views/items/manage.php || true
echo
echo '=== Cashups handlers ==='
rg -n -C 10 \
'(hidden\.bs\.select|apply\.daterangepicker|table_support\.refresh|daterangepicker|filters)' \
app/Views/cashups/manage.php || true
echo
echo '=== Expenses handlers ==='
rg -n -C 10 \
'(hidden\.bs\.select|apply\.daterangepicker|table_support\.refresh|daterangepicker|filters)' \
app/Views/expenses/manage.php || true
echo
echo '=== Sales handlers ==='
rg -n -C 10 \
'(hidden\.bs\.select|apply\.daterangepicker|table_support\.refresh|daterangepicker|filters)' \
app/Views/sales/manage.php || true
echo
echo '=== Candidate tests ==='
fd -t f . tests app 2>/dev/null \
| rg -i '(expenses|table_filter_persistence|daterangepicker|manage).*(test|spec).*?\.(php|js)$' \
|| true
echo
echo '=== Existing custom event conventions ==='
rg -n -C 4 \
'\.(trigger|triggerHandler|on)\s*\(\s*["'\''][^"'\'']+(filter|persist|url)[^"'\'']*["'\'']' \
app tests 2>/dev/null \
|| trueLength of output: 22752
I will move the existing
You are interacting with an AI system. |
|
❌ Failed to create commit: AGENT_CHAT: Failed to create commit |
1 similar comment
|
❌ Failed to create commit: AGENT_CHAT: Failed to create commit |
|
@CodeRabbit what permission needs to be granted to allow you to push commits |
|
Tip For best results, initiate chat on the files or code changes.
[coderabbit_configuration] You are interacting with an AI system. |
|
|
||
| <script type="text/javascript"> | ||
| $(document).ready(function() { | ||
| // When any filter is clicked and the dropdown window is closed |
There was a problem hiding this comment.
Let's remove all the comments from here. They aren't needed. Also from lines 22, 31, et al.
Restores the missing daterangepicker apply and filter change handlers on the Expenses page so selecting a date range reloads the table with the correct start_date and end_date.
Without these handlers the UI range updated but /expenses/search kept today's date for both parameters, so historical expenses never appeared.
Fixes #4596
Summary by CodeRabbit