From 9ea3f4c3a6168e0cb9fe702eb6c7d82f6a5b726c Mon Sep 17 00:00:00 2001 From: Vyacheslav Tumanov Date: Thu, 15 Jun 2023 10:31:36 +0500 Subject: [PATCH] UBER-480: Fix ValueFilter for space-like objects (#3428) --- .../src/components/filter/ValueFilter.svelte | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/plugins/view-resources/src/components/filter/ValueFilter.svelte b/plugins/view-resources/src/components/filter/ValueFilter.svelte index c6e0de141d..a7a30a1271 100644 --- a/plugins/view-resources/src/components/filter/ValueFilter.svelte +++ b/plugins/view-resources/src/components/filter/ValueFilter.svelte @@ -67,26 +67,30 @@ } : {} let prefix = '' - const hieararchy = client.getHierarchy() - const attr = hieararchy.getAttribute(filter.key._class, filter.key.key) - if (hieararchy.isMixin(attr.attributeOf)) { + const hierarchy = client.getHierarchy() + const attr = hierarchy.getAttribute(filter.key._class, filter.key.key) + if (hierarchy.isMixin(attr.attributeOf)) { prefix = attr.attributeOf + '.' } + const isDerivedFromSpace = hierarchy.isDerived(_class, core.class.Space) objectsPromise = client.findAll( _class, - { ...resultQuery, ...(space ? { space } : { '$lookup.space.archived': false }) }, + { + ...resultQuery, + ...(space ? { space } : isDerivedFromSpace ? { archived: false } : { '$lookup.space.archived': false }) + }, { sort: { [filter.key.key]: SortingOrder.Ascending }, projection: { [prefix + filter.key.key]: 1, space: 1 }, - ...(space ? {} : { lookup: { space: core.class.Space } }) + ...(space || isDerivedFromSpace ? {} : { lookup: { space: core.class.Space } }) } ) const res = await objectsPromise for (const object of res) { let asDoc = object - if (hieararchy.isMixin(filter.key._class)) { - asDoc = hieararchy.as(object, filter.key._class) + if (hierarchy.isMixin(filter.key._class)) { + asDoc = hierarchy.as(object, filter.key._class) } const realValue = getObjectValue(filter.key.key, asDoc) const value = getValue(realValue)