|
1 | 1 | <template> |
2 | 2 | <div class="vue-ui-table-main" :style="`font-family: ${FINAL_CONFIG.fontFamily}`"> |
3 | | - <div class="vue-ui-table-export-hub"> |
| 3 | + <div class="vue-ui-table-export-hub" v-if="FINAL_CONFIG.style.exportMenu.show"> |
4 | 4 | <button @click="isExportRequest = !isExportRequest" v-html="icons.export" |
5 | 5 | :style="`background:${FINAL_CONFIG.style.exportMenu.backgroundColor};color:${FINAL_CONFIG.style.exportMenu.color}`" /> |
6 | 6 | <div class="vue-ui-table-export-hub-dropdown" :data-is-open="isExportRequest || 'false'" |
|
40 | 40 | <div class="vue-ui-table__wrapper" :style="`max-height:${FINAL_CONFIG.maxHeight}px`" ref="tableWrapper"> |
41 | 41 | <table class="vue-ui-table"> |
42 | 42 | <!-- TABLE HEAD --> |
43 | | - <thead id="tableHead"> |
| 43 | + <thead id="tableHead" class="vue-ui-table__head" :style="{ |
| 44 | + background: FINAL_CONFIG.style.th.backgroundColor, |
| 45 | + boxShadow: `-1px 0 0 ${FINAL_CONFIG.style.th.backgroundColor}` |
| 46 | + }"> |
44 | 47 | <!-- HEADERS --> |
45 | 48 | <tr> |
46 | 49 | <th class="invisible-cell"></th> |
|
395 | 398 | {{ FINAL_CONFIG.translations.totalRows }} : {{ dataset.body.length }} | |
396 | 399 | {{ FINAL_CONFIG.translations.paginatorLabel }} : |
397 | 400 | <select id="paginatorSelector" v-model.number="itemsPerPage" v-if="bodyCopy.length > 10" |
398 | | - @change="resetSelection" |
| 401 | + @change="resetSelection(); onPageChange();" |
399 | 402 | :style="`background:${FINAL_CONFIG.style.inputs.backgroundColor};color:${FINAL_CONFIG.style.inputs.color};border:${FINAL_CONFIG.style.inputs.border}`"> |
400 | 403 | <template v-for="(option, i) in paginatorOptions"> |
401 | 404 | <option :key="`paginator_option_${i}`" |
@@ -572,6 +575,7 @@ export default { |
572 | 575 | } |
573 | 576 | }, |
574 | 577 | components: { VueUiXy, VueUiDonut }, |
| 578 | + emits: ['page-change'], |
575 | 579 | data() { |
576 | 580 | const uid = `vue-ui-table-${Math.random()}`; |
577 | 581 | return { |
@@ -1245,15 +1249,35 @@ export default { |
1245 | 1249 | return this.multiselects[index].length === this.getDropdownOptions(index).length; |
1246 | 1250 | } |
1247 | 1251 | }, |
| 1252 | + getCurrentPageData() { |
| 1253 | + return { |
| 1254 | + totalPages: this.pages.length, |
| 1255 | + itemsPerPage: this.itemsPerPage, |
| 1256 | + currentPage: this.currentPage, |
| 1257 | + currentPageData: this.visibleRows.map(r => r.td) |
| 1258 | + } |
| 1259 | + }, |
| 1260 | + onPageChange() { |
| 1261 | + this.$emit('page-change', this.getCurrentPageData()); |
| 1262 | + }, |
1248 | 1263 | navigate(direction) { |
1249 | 1264 | this.resetSelection(); |
1250 | 1265 | if (direction === 'next' && this.currentPage < this.pages.length) { |
| 1266 | + if (this.currentPage + 1 > this.pages.length - 1) { |
| 1267 | + return; |
| 1268 | + } |
1251 | 1269 | this.currentPage += 1; |
1252 | 1270 | } else if (direction === 'previous' && this.currentPage >= 1) { |
1253 | 1271 | this.currentPage -= 1; |
1254 | 1272 | } else { |
| 1273 | + if (direction - 1 < 0 || direction > this.pages.length || direction === 'previous') { |
| 1274 | + return; |
| 1275 | + } |
1255 | 1276 | this.currentPage = direction - 1; |
1256 | 1277 | } |
| 1278 | +
|
| 1279 | + this.onPageChange(); |
| 1280 | +
|
1257 | 1281 | const table = this.$refs.tableWrapper; |
1258 | 1282 | table.scrollTo({ |
1259 | 1283 | top: 0, |
@@ -1700,6 +1724,7 @@ export default { |
1700 | 1724 | } else { |
1701 | 1725 | this.currentPage = Number(event.target.value); |
1702 | 1726 | } |
| 1727 | + this.onPageChange(); |
1703 | 1728 | }, |
1704 | 1729 |
|
1705 | 1730 | // DONUTS |
@@ -2176,6 +2201,7 @@ button.th-reset:not(:disabled) { |
2176 | 2201 | } |
2177 | 2202 |
|
2178 | 2203 | .vue-ui-table-main td.vue-ui-table-td-iteration { |
| 2204 | + min-width: 48px; |
2179 | 2205 | font-size: 12px; |
2180 | 2206 | font-variant-numeric: tabular-nums; |
2181 | 2207 | text-align: right; |
@@ -2310,9 +2336,9 @@ button.th-reset:not(:disabled) { |
2310 | 2336 | } |
2311 | 2337 |
|
2312 | 2338 | .vue-ui-table-main .vue-ui-table-export-hub { |
2313 | | - left: 5px; |
| 2339 | + left: 20px; |
2314 | 2340 | position: absolute; |
2315 | | - top: 0; |
| 2341 | + top: 3px; |
2316 | 2342 | z-index: 1001; |
2317 | 2343 | } |
2318 | 2344 |
|
|
0 commit comments