summaryrefslogtreecommitdiffstats
path: root/webapp
diff options
context:
space:
mode:
authorUdo Walter2019-02-23 03:07:07 +0100
committerUdo Walter2019-02-23 03:07:07 +0100
commit558815d4e82e231a267b65de1bbf347a816e22d6 (patch)
tree615b7f207f385a6724a7e87f4cdfef89e9498e5f /webapp
parent[webapp/datatable] code cleanup (diff)
downloadbas-558815d4e82e231a267b65de1bbf347a816e22d6.tar.gz
bas-558815d4e82e231a267b65de1bbf347a816e22d6.tar.xz
bas-558815d4e82e231a267b65de1bbf347a816e22d6.zip
[webapp/datatable] fix filter by selected not working; add filtering indicator
Diffstat (limited to 'webapp')
-rw-r--r--webapp/src/components/DataTable.vue8
-rw-r--r--webapp/src/main.js14
2 files changed, 13 insertions, 9 deletions
diff --git a/webapp/src/components/DataTable.vue b/webapp/src/components/DataTable.vue
index 7d2ff73..38c5dc9 100644
--- a/webapp/src/components/DataTable.vue
+++ b/webapp/src/components/DataTable.vue
@@ -144,7 +144,7 @@
</v-icon>
</div>
</div>
- <v-progress-linear v-if="loading" :indeterminate="true" :height="2" style="margin: 0"></v-progress-linear>
+ <v-progress-linear v-if="filteringLoop.running || loading" :indeterminate="true" :height="2" style="margin: 0"></v-progress-linear>
<div v-else class="header-separator"></div>
</div>
</template>
@@ -204,7 +204,7 @@ export default {
lastSelectIndex: null,
shiftKey: false,
filteredRows: [],
- filteringLoop: null
+ filteringLoop: { running: false, cancel: () => true }
}
},
computed: {
@@ -396,7 +396,7 @@ export default {
},
filterRows () {
// Cancel the last filtering loop
- if (this.filteringLoop) this.filteringLoop.cancel()
+ this.filteringLoop.cancel()
// Skip filtering if all search strings are empty
if (this.search.every(s => s.text.raw === '') && !this.onlyShowSelected) {
@@ -409,7 +409,7 @@ export default {
this.filteringLoop = this.$loop(this.sortedRows.length, 1000,
i => {
const row = this.sortedRows[i]
- if ((!this.onlySelected || (this.onlySelected && row.selected)) && this.search.every(s => {
+ if ((!this.onlyShowSelected || (this.onlyShowSelected && row.selected)) && this.search.every(s => {
if (s.key === null) {
return this.dataKeys.some(key => {
return this.filterFunction(s, String(row.data[key]))
diff --git a/webapp/src/main.js b/webapp/src/main.js
index cc53b76..6ed1d53 100644
--- a/webapp/src/main.js
+++ b/webapp/src/main.js
@@ -96,21 +96,25 @@ Vue.prototype.$snackbar = function (data) {
// Loop that processes work in chunks to allow the UI to refresh inbetween and prevents freezing.
Vue.prototype.$loop = function (count, chunksize, iteration, callback = () => {}) {
var i = 0
- var breakCondition = false
+ var running = true
const chunk = () => {
- if (breakCondition) return
+ if (!running) return
var end = Math.min(i + chunksize, count)
- for (; i < end; ++i) {
+ for (; i < end; i++) {
iteration(i)
}
if (i < count) {
setTimeout(chunk, 0)
} else {
+ running = false
callback()
}
}
- chunk()
- return { cancel: () => { breakCondition = true } }
+ setTimeout(chunk, 0)
+ const loop = {}
+ Object.defineProperty(loop, 'running', { get: () => running })
+ Object.defineProperty(loop, 'cancel', { value: () => { running = false } })
+ return loop
}
new Vue({