diff --git a/app/Views/shared/content_requests.php b/app/Views/shared/content_requests.php index d198e2a..aeb80e7 100644 --- a/app/Views/shared/content_requests.php +++ b/app/Views/shared/content_requests.php @@ -12,35 +12,35 @@
- - - - - - -
diff --git a/app/Views/shared/content_validation.php b/app/Views/shared/content_validation.php index 334e180..6072d0e 100644 --- a/app/Views/shared/content_validation.php +++ b/app/Views/shared/content_validation.php @@ -42,7 +42,7 @@
diff --git a/app/Views/shared/script_requests.php b/app/Views/shared/script_requests.php index 942e586..926a236 100644 --- a/app/Views/shared/script_requests.php +++ b/app/Views/shared/script_requests.php @@ -61,14 +61,39 @@ document.addEventListener('alpine:init', () => { this.sortCol = col; this.sortAsc = true; } + this.computeSorted(); + this.computePaginated(); }, nextPage() { - if (this.currentPage < this.totalPages) this.currentPage++; + if (this.currentPage < this.totalPages) { + this.currentPage++; + this.computePaginated(); + } }, prevPage() { - if (this.currentPage > 1) this.currentPage--; + if (this.currentPage > 1) { + this.currentPage--; + this.computePaginated(); + } + }, + + setFilterKey(key) { + this.filterKey = key; + this.computeFiltered(); + this.computeSorted(); + this.computeTotalPages(); + this.computePaginated(); + }, + + setFilterTable(value) { + this.filterTable = value; + this.currentPage = 1; + this.computeFiltered(); + this.computeSorted(); + this.computeTotalPages(); + this.computePaginated(); }, // Compute methods - called only when dependencies change @@ -120,32 +145,6 @@ document.addEventListener('alpine:init', () => { const defaultPrinter = 'get("userrole")]["sampleDialog"]["defaultPrinter"] ?? "lab" ?>'; this.selectedPrinter = defaultPrinter || 'lab'; - // Watchers for reactive updates - this.$watch('list', () => { - this.computeFiltered(); - this.computeValidatedCount(); - }); - - this.$watch('filterKey', () => this.computeFiltered()); - this.$watch('filterTable', () => { - this.currentPage = 1; - this.computeFiltered(); - }); - - this.$watch('filtered', () => { - this.computeSorted(); - this.computeTotalPages(); - }); - - this.$watch('sortCol', () => this.computeSorted()); - this.$watch('sortAsc', () => this.computeSorted()); - this.$watch('sorted', () => this.computePaginated()); - this.$watch('currentPage', () => this.computePaginated()); - - this.$watch('auditData', () => { - this.computeAuditEvents(); - }); - // Initial load only - no auto-refresh this.fetchList(); }, @@ -175,6 +174,9 @@ document.addEventListener('alpine:init', () => { let codeB = statusOrder[b.STATS] ?? 0; return codeA - codeB; }); + // Compute derived data after list is loaded + this.computeFiltered(); + this.computeValidatedCount(); }).finally(() => { this.isLoading = false; }); diff --git a/app/Views/shared/script_validation.php b/app/Views/shared/script_validation.php index 92c00be..1163075 100644 --- a/app/Views/shared/script_validation.php +++ b/app/Views/shared/script_validation.php @@ -29,14 +29,31 @@ document.addEventListener('alpine:init', () => { this.sortCol = col; this.sortAsc = true; } + this.computeUnvalidatedSorted(); + this.computeUnvalidatedPaginated(); }, nextPage() { - if (this.currentPage < this.unvalidatedTotalPages) this.currentPage++; + if (this.currentPage < this.unvalidatedTotalPages) { + this.currentPage++; + this.computeUnvalidatedPaginated(); + } }, prevPage() { - if (this.currentPage > 1) this.currentPage--; + if (this.currentPage > 1) { + this.currentPage--; + this.computeUnvalidatedPaginated(); + } + }, + + setFilterTable(value) { + this.filterTable = value; + this.currentPage = 1; + this.computeUnvalidatedFiltered(); + this.computeUnvalidatedSorted(); + this.computeUnvalidatedTotalPages(); + this.computeUnvalidatedPaginated(); }, // Compute methods - called only when dependencies change @@ -82,35 +99,6 @@ document.addEventListener('alpine:init', () => { this.filter.date1 = this.today; this.filter.date2 = this.today; - this.$watch('filterTable', () => { - this.currentPage = 1; - }); - - // Watchers for reactive updates - this.$watch('unvalidatedList', () => { - this.computeUnvalidatedFiltered(); - this.computeUnvalidatedCount(); - }); - this.$watch('filterTable', () => { - this.computeUnvalidatedFiltered(); - }); - this.$watch('unvalidatedFiltered', () => { - this.computeUnvalidatedSorted(); - this.computeUnvalidatedTotalPages(); - }); - this.$watch('sortCol', () => { - this.computeUnvalidatedSorted(); - }); - this.$watch('sortAsc', () => { - this.computeUnvalidatedSorted(); - }); - this.$watch('unvalidatedSorted', () => { - this.computeUnvalidatedPaginated(); - }); - this.$watch('currentPage', () => { - this.computeUnvalidatedPaginated(); - }); - // Initial load only - no auto-refresh this.fetchUnvalidated(); @@ -137,6 +125,12 @@ document.addEventListener('alpine:init', () => { headers: { 'Content-Type': 'application/json' }, }).then(res => res.json()).then(data => { this.unvalidatedList = data.data ?? []; + // Compute derived data after list is loaded + this.computeUnvalidatedFiltered(); + this.computeUnvalidatedCount(); + this.computeUnvalidatedSorted(); + this.computeUnvalidatedTotalPages(); + this.computeUnvalidatedPaginated(); }).finally(() => { this.isLoading = false; });