summaryrefslogtreecommitdiffstats
path: root/webapp/src/components/DataTable.vue
diff options
context:
space:
mode:
authorUdo Walter2019-02-23 01:16:42 +0100
committerUdo Walter2019-02-23 01:16:42 +0100
commit3bef583ba90f20d314f5973ef2521e9cfa2828c7 (patch)
treecf51f0adad42ec132fd1dccf40113e293f4c28ce /webapp/src/components/DataTable.vue
parent[webapp/datatable] Fix something. I really have no idea how to describe this ... (diff)
downloadbas-3bef583ba90f20d314f5973ef2521e9cfa2828c7.tar.gz
bas-3bef583ba90f20d314f5973ef2521e9cfa2828c7.tar.xz
bas-3bef583ba90f20d314f5973ef2521e9cfa2828c7.zip
[webapp/datatable] code cleanup
Diffstat (limited to 'webapp/src/components/DataTable.vue')
-rw-r--r--webapp/src/components/DataTable.vue32
1 files changed, 15 insertions, 17 deletions
diff --git a/webapp/src/components/DataTable.vue b/webapp/src/components/DataTable.vue
index 70a29bd..7d2ff73 100644
--- a/webapp/src/components/DataTable.vue
+++ b/webapp/src/components/DataTable.vue
@@ -204,7 +204,7 @@ export default {
lastSelectIndex: null,
shiftKey: false,
filteredRows: [],
- filteringLoop: { breakLoop: false }
+ filteringLoop: null
}
},
computed: {
@@ -395,32 +395,30 @@ export default {
if (this.filteredRows) this.calcSelectState()
},
filterRows () {
- if (this.search.every(s => s.text.raw === '') && !this.onlyShowSelected) this.filteredRows = this.sortedRows
- const onlySelected = this.onlyShowSelected
- const search = this.search
- const dataKeys = this.dataKeys
- const test = this.filterFunction
- const rows = this.sortedRows
+ // Cancel the last filtering loop
+ if (this.filteringLoop) this.filteringLoop.cancel()
- this.filteringLoop.breakLoop = true
- const newFilteringLoop = { breakLoop: false }
- this.filteringLoop = newFilteringLoop
+ // Skip filtering if all search strings are empty
+ if (this.search.every(s => s.text.raw === '') && !this.onlyShowSelected) {
+ this.filteredRows = this.sortedRows
+ return
+ }
+ // Filter rows using a time slicing loop
const result = []
- this.$loop(rows.length, 1000,
+ this.filteringLoop = this.$loop(this.sortedRows.length, 1000,
i => {
- const row = rows[i]
- if ((!onlySelected || (onlySelected && row.selected)) && search.every(s => {
+ const row = this.sortedRows[i]
+ if ((!this.onlySelected || (this.onlySelected && row.selected)) && this.search.every(s => {
if (s.key === null) {
- return dataKeys.some(key => {
- return test(s, String(row.data[key]))
+ return this.dataKeys.some(key => {
+ return this.filterFunction(s, String(row.data[key]))
})
} else {
- return test(s, String(row.data[s.key]))
+ return this.filterFunction(s, String(row.data[s.key]))
}
})) result.push(row)
},
- () => newFilteringLoop.breakLoop,
() => { this.filteredRows = result }
)
}