mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-10-28 19:18:58 -04:00
fix: refresh cashups and items tables on filter and date range change (#4731)
* fix(cashups,items): sync date globals from picker on Apply Address CodeRabbit review on #4731: when a page loads with restored GET dates the globals are overwritten after the picker initializes, so applying an unchanged range (which skips the picker change callback) refreshed the table with the stale globals instead of the visible range. Add a shared apply.daterangepicker handler in the daterangepicker partial that copies the picker range into start_date/end_date; it binds before page-level handlers so refreshes and URL updates use the visible range. * style(views): remove redundant comments in daterangepicker
This commit is contained in:
1 parent
7ea3f21365
commit
17c32d3122
3 files changed
+31
No files matched your search
@@ -14,9 +14,17 @@
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('#filters').on('hidden.bs.select', function(e) {
|
||||
table_support.refresh();
|
||||
});
|
||||
|
||||
// Load the preset datarange picker
|
||||
<?= view('partial/daterangepicker') ?>
|
||||
|
||||
$("#daterangepicker").on('apply.daterangepicker', function(ev, picker) {
|
||||
table_support.refresh();
|
||||
});
|
||||
|
||||
<?= view('partial/bootstrap_tables_locale') ?>
|
||||
|
||||
// Override dates from server if provided
|
||||
|
||||
@@ -25,8 +25,23 @@ use App\Models\Employee;
|
||||
);
|
||||
});
|
||||
|
||||
$('#filters').on('hidden.bs.select', function(e) {
|
||||
table_support.refresh();
|
||||
});
|
||||
|
||||
if ($('#stock_location').length) {
|
||||
$('#stock_location').on('change', function() {
|
||||
table_support.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
// Load the preset daterange picker
|
||||
<?= view('partial/daterangepicker') ?>
|
||||
|
||||
$("#daterangepicker").on('apply.daterangepicker', function(ev, picker) {
|
||||
table_support.refresh();
|
||||
});
|
||||
|
||||
// Set the beginning of time as starting date
|
||||
$('#daterangepicker').data('daterangepicker').setStartDate("<?= date($config['dateformat'], mktime(0, 0, 0, 01, 01, 2010)) ?>");
|
||||
// Update the hidden inputs with the selected dates before submitting the search data
|
||||
|
||||
@@ -110,6 +110,10 @@
|
||||
start_date = start.format('YYYY-MM-DD');
|
||||
end_date = end.format('YYYY-MM-DD');
|
||||
});
|
||||
$('#daterangepicker').on('apply.daterangepicker', function(ev, picker) {
|
||||
start_date = picker.startDate.format('YYYY-MM-DD');
|
||||
end_date = picker.endDate.format('YYYY-MM-DD');
|
||||
});
|
||||
<?php } else { ?>
|
||||
$('#daterangepicker').css("width", "305");
|
||||
let start_date = "<?= date('Y-m-d H:i:s', mktime(0, 0, 0, date("m"), date("d"), date("Y"))) ?>";
|
||||
@@ -217,4 +221,8 @@
|
||||
start_date = start.format('YYYY-MM-DD HH:mm:ss');
|
||||
end_date = end.format('YYYY-MM-DD HH:mm:ss');
|
||||
});
|
||||
$('#daterangepicker').on('apply.daterangepicker', function(ev, picker) {
|
||||
start_date = picker.startDate.format('YYYY-MM-DD HH:mm:ss');
|
||||
end_date = picker.endDate.format('YYYY-MM-DD HH:mm:ss');
|
||||
});
|
||||
<?php } ?>
|
||||
Reference in new issue
Block a user