From 5b3e1317f498fc1c404f7f1aba08e98ab69a2488 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Mon, 30 May 2022 09:23:25 +0200 Subject: [PATCH] Only refresh entities that are visible on the interface --- .../components/panels/Entities/Selector.vue | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/platypush/backend/http/webapp/src/components/panels/Entities/Selector.vue b/platypush/backend/http/webapp/src/components/panels/Entities/Selector.vue index 5715924f3..d8abd90b4 100644 --- a/platypush/backend/http/webapp/src/components/panels/Entities/Selector.vue +++ b/platypush/backend/http/webapp/src/components/panels/Entities/Selector.vue @@ -127,25 +127,27 @@ export default { this.$emit('input', value) }, - resetGroupFilter() { - this.selectedGroups = Object.keys( - this.entityGroups[this.value?.grouping] || {} - ).reduce( - (obj, group) => { - obj[group] = true - return obj - }, {} - ) + refreshGroupFilter(reset) { + if (reset) + this.selectedGroups = Object.keys( + this.entityGroups[this.value?.grouping] || {} + ).reduce( + (obj, group) => { + obj[group] = true + return obj + }, {} + ) + else { + for (const group of Object.keys(this.entityGroups[this.value?.grouping])) + if (this.selectedGroups[group] == null) + this.selectedGroups[group] = true + } this.synchronizeSelectedEntities() }, toggleGroup(group) { - if (this.selectedGroups[group]) - delete this.selectedGroups[group] - else - this.selectedGroups[group] = true - + this.selectedGroups[group] = !this.selectedGroups[group] this.synchronizeSelectedEntities() }, @@ -160,10 +162,10 @@ export default { }, mounted() { - this.resetGroupFilter() - this.$watch(() => this.value?.grouping, this.resetGroupFilter) + this.refreshGroupFilter(true) + this.$watch(() => this.value?.grouping, () => { this.refreshGroupFilter(true) }) this.$watch(() => this.searchTerm, this.updateSearchTerm) - this.$watch(() => this.entityGroups, this.resetGroupFilter) + this.$watch(() => this.entityGroups, () => { this.refreshGroupFilter(false) }) }, }