From 80c2c77272ae4ac09d925123094e06947571dbef Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 1 Jan 2023 23:06:40 +0100 Subject: [PATCH] Support for entities with children on the frontend --- .../src/components/panels/Entities/Device.vue | 37 ++++++++ .../src/components/panels/Entities/Entity.vue | 92 +++++++++++++++++-- .../panels/Entities/EntityMixin.vue | 10 ++ .../src/components/panels/Entities/Index.vue | 61 +++++++----- .../src/components/panels/Entities/Sensor.vue | 2 +- 5 files changed, 171 insertions(+), 31 deletions(-) create mode 100644 platypush/backend/http/webapp/src/components/panels/Entities/Device.vue diff --git a/platypush/backend/http/webapp/src/components/panels/Entities/Device.vue b/platypush/backend/http/webapp/src/components/panels/Entities/Device.vue new file mode 100644 index 00000000..91fe95f3 --- /dev/null +++ b/platypush/backend/http/webapp/src/components/panels/Entities/Device.vue @@ -0,0 +1,37 @@ + + + + + diff --git a/platypush/backend/http/webapp/src/components/panels/Entities/Entity.vue b/platypush/backend/http/webapp/src/components/panels/Entities/Entity.vue index 2b44f1ba..a64d52c7 100644 --- a/platypush/backend/http/webapp/src/components/panels/Entities/Entity.vue +++ b/platypush/backend/http/webapp/src/components/panels/Entities/Entity.vue @@ -1,12 +1,33 @@ @@ -22,10 +43,28 @@ export default { data() { return { component: null, + collapsed: true, justUpdated: false, } }, + computed: { + computedChildren() { + return Object.values(this.children || {}).filter((child) => child) + }, + + hasChildren() { + return !!this.computedChildren.length + }, + + isCollapsed() { + if (!this.hasChildren) + return true + + return this.collapsed + }, + }, + methods: { valuesEqual(a, b) { a = {...a} @@ -68,10 +107,47 @@ export default {