From 4842c1911b3e4da6f4967965ff946ebe55294894 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Mon, 17 Apr 2023 02:11:13 +0200 Subject: [PATCH] Frontend entities should have a reference to `allEntities`. There are probably more optimal ways of achieving this other than passing a reference to the full list of entities to each of the entities, such as running a BFS to recursively expand all the entities within the child hierarchy of an entity. This is needed because the entity needs to know which entities aren't direct children, but are two or more layers down in the hierarchy, so they should be passed to their own child entities. --- .../src/components/panels/Entities/Entity.vue | 16 +++++++++++++++- .../components/panels/Entities/EntityMixin.vue | 5 +++++ .../src/components/panels/Entities/Index.vue | 1 + 3 files changed, 21 insertions(+), 1 deletion(-) 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 cb997863a..893086fcb 100644 --- a/platypush/backend/http/webapp/src/components/panels/Entities/Entity.vue +++ b/platypush/backend/http/webapp/src/components/panels/Entities/Entity.vue @@ -24,11 +24,12 @@ -
+
entity + && entity.parent_id === parentId + && !entity.is_configuration + ). + reduce((obj, entity) => { + obj[entity.id] = entity + return obj + }, {}) + }, + onClick(event) { event.stopPropagation() diff --git a/platypush/backend/http/webapp/src/components/panels/Entities/EntityMixin.vue b/platypush/backend/http/webapp/src/components/panels/Entities/EntityMixin.vue index 337da2ae7..a00cd69ca 100644 --- a/platypush/backend/http/webapp/src/components/panels/Entities/EntityMixin.vue +++ b/platypush/backend/http/webapp/src/components/panels/Entities/EntityMixin.vue @@ -31,6 +31,11 @@ export default { default: () => {}, }, + allEntities: { + type: Object, + default: () => {}, + }, + level: { type: Number, default: 0, diff --git a/platypush/backend/http/webapp/src/components/panels/Entities/Index.vue b/platypush/backend/http/webapp/src/components/panels/Entities/Index.vue index ed1ccf58d..699242e2c 100644 --- a/platypush/backend/http/webapp/src/components/panels/Entities/Index.vue +++ b/platypush/backend/http/webapp/src/components/panels/Entities/Index.vue @@ -57,6 +57,7 @@