|
12 | 12 | const defaultColumns = ['date', 'pilotname', 'route', 'status', 'flighttime']; |
13 | 13 | var columns = localStorage.getItem('table__pireps-admin') ? JSON.parse(localStorage.getItem('table__pireps-admin')) : defaultColumns; |
14 | 14 | </script> |
15 | | -<div id="content" class="text-black dark:text-white" x-data="{ table: { current: [], orderBy: (x) => x.date, orderByName: 'Date', order: 'desc', search: '', filters: [acceptedFilter] }, refresh() { return updateDataTable(allEntries, this.table) }, }"> |
| 15 | +<div id="content" class="text-black dark:text-white" x-data="{ table: { current: [], orderBy: (x) => x.date, orderByName: 'Date', order: 'desc', search: '', filters: [acceptedFilter], limit: 25 }, refresh() { return updateDataTable(allEntries, this.table) }, }"> |
16 | 16 | <div class="flex w-full p-5 dark:bg-gray-600 bg-gray-100 py-7 mb-4 items-center gap-2"> |
17 | 17 | <h2 class="flex-1 text-2xl font-bold lg:text-4xl"> |
18 | 18 | All PIREPs |
|
21 | 21 |
|
22 | 22 | <div class="md:px-5 px-2 max-w-full"> |
23 | 23 | <div class="flex gap-2 items-center mb-2"> |
24 | | - <input type="text" :value="table.search" class="form-control flex-1" placeholder="Search" @input="table.search = $event.target.value; updateDataTable(allEntries, table);" /> |
| 24 | + <input type="text" :value="table.search" class="form-control flex-1" placeholder="Search" @input="table.search = $event.target.value; table.limit = 25; refresh();" /> |
25 | 25 | <div class="text-sm"> |
26 | 26 | <p x-text="`Ordering by ${table.orderByName}`"></p> |
27 | | - <p x-text="`${table.current.length} result${table.current.length == 1 ? '' : 's'}`"></p> |
| 27 | + <p x-text="`${table.current.actualLength} result${table.current.actualLength == 1 ? '' : 's'}`"></p> |
28 | 28 | </div> |
29 | 29 | </div> |
30 | 30 | <div class="table-wrapper mb-1"> |
|
50 | 50 | <input type="hidden" name="action" value="delpirep" /> |
51 | 51 | <input type="hidden" name="id" x-ref="delpirep-id" value="" /> |
52 | 52 | </form> |
53 | | - <template x-for="pirep in table.current" :key="pirep.id"> |
54 | | - <tr class="hover:bg-black/20 cursor-pointer" @click="window.location.href = `/pireps/${pirep.id}`"> |
| 53 | + <template x-for="(pirep, index) in table.current" :key="pirep.id"> |
| 54 | + <tr class="hover:bg-black/20 cursor-pointer" @click="window.location.href = `/pireps/${pirep.id}`" x-intersect="if ((index + 1) % 25 === 0 && table.limit === index + 1) { table.limit = index + 26; refresh(); }"> |
55 | 55 | <td class="hidden md:table-cell" x-text="new Date(pirep.date).toLocaleDateString()" x-show="columns.includes('date')"></td> |
56 | 56 | <td class="hidden md:table-cell" x-text="pirep.pilotname" x-show="columns.includes('pilotname')"></td> |
57 | 57 | <td class="hidden md:table-cell" x-text="pirep.pilotcallsign" x-show="columns.includes('callsign')"></td> |
|
0 commit comments