Skip to content

Commit b616a04

Browse files
committed
small refactor in table component
1 parent 05fd1e8 commit b616a04

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/components/compounds/Table/Table.vue

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,6 @@ const Table = {
7373
props.data.switchPage()
7474
}
7575
76-
// if(props.checkable) {
77-
// let iterator = 0
78-
// props.data.rows.forEach(row => {
79-
// checkedBoxes[iterator++] = 0
80-
// })
81-
// }
82-
8376
const sortColumn = colName => {
8477
props.data.sortByColumn(colName, columnProperties.value[colName].ascendant)
8578
columnProperties.value[colName].ascendant = !columnProperties.value[colName].ascendant
@@ -113,19 +106,30 @@ const Table = {
113106
)
114107
})
115108
109+
const handleBackPage = () => {
110+
if (currentPage > 0)
111+
currentPage -= 1
112+
}
113+
114+
const handleNextPage = () => {
115+
if (currentPage + 1 < Math.ceil(data.originalRows.length / rowsPerPage))
116+
currentPage += 1
117+
}
118+
116119
return {
117120
props,
118121
columnProperties,
119122
data,
120123
search,
121124
sortColumn,
122125
rowsPerPage,
123-
// checkedBoxes,
124126
currentPage,
125127
rootClasses,
126128
expanded,
127129
toggleExpanded,
128130
countColumns,
131+
handleBackPage,
132+
handleNextPage
129133
}
130134
},
131135
}
@@ -226,12 +230,10 @@ export default Table
226230
</option>
227231
</v-select>
228232
<!-- using :disabled wont work, so instead the click action is conditioned and the buttons are always clickable -->
229-
<a class="pagination-previous" @click="currentPage > 0 && (currentPage -= 1)">Previous</a>
233+
<a class="pagination-previous" @click="handleBackPage">Previous</a>
230234
<a
231235
class="pagination-next"
232-
@click="
233-
currentPage + 1 < Math.ceil(data.originalRows.length / rowsPerPage) && (currentPage += 1)
234-
"
236+
@click="handleNextPage"
235237
>Next page</a
236238
>
237239
</div>

0 commit comments

Comments
 (0)