diff --git a/frontend/src/components/object/ObjectFilters.vue b/frontend/src/components/object/ObjectFilters.vue index 919ba31f..67227c67 100644 --- a/frontend/src/components/object/ObjectFilters.vue +++ b/frontend/src/components/object/ObjectFilters.vue @@ -22,7 +22,7 @@ const metadataStore = useMetadataStore(); const objectStore = useObjectStore(); const tagStore = useTagStore(); const { getMetadataSearchResults } = storeToRefs(useMetadataStore()); -const { getObjects } = storeToRefs(useObjectStore()); +const { getUnfilteredObjectIds } = storeToRefs(useObjectStore()); const { getTagSearchResults } = storeToRefs(useTagStore()); // State @@ -49,9 +49,10 @@ objectStore.$onAction( // Computed const metadataValues = computed(() => { // Filter out any tags that don't have an objectID that exist in getObjects - const filteredVals = getMetadataSearchResults.value.filter((val) => - getObjects.value.some((obj) => obj.id === val.objectId) + const filteredVals = getMetadataSearchResults.value.filter((searchRes) => + getUnfilteredObjectIds.value.some((obj) => obj === searchRes.objectId) ); + // Take the metadata for the objects, and flatten them into a single array const metadataVals = [ ...new Set(filteredVals.flatMap((obj) => obj.metadata)), @@ -68,10 +69,11 @@ const metadataValues = computed(() => { }); const tagsetValues = computed(() => { - // Filter out any tags that don't have an objectID that exist in getObjects - const filteredVals = getTagSearchResults.value.filter((val) => - getObjects.value.some((obj) => obj.id === val.objectId) + // Filter out any tags that don't have an objectID that exist in getUnfilteredObjectIds + const filteredVals = getTagSearchResults.value.filter((searchRes) => + getUnfilteredObjectIds.value.some((obj) => obj === searchRes.objectId) ); + // Take the tags for the objects, and flatten them into a single array const taggingVals = [ ...new Set(filteredVals.flatMap((obj) => obj.tagset)), diff --git a/frontend/src/store/objectStore.ts b/frontend/src/store/objectStore.ts index 451128ac..6806ebb0 100644 --- a/frontend/src/store/objectStore.ts +++ b/frontend/src/store/objectStore.ts @@ -13,6 +13,7 @@ import type { COMSObject, MetadataPair, ObjectSearchPermissionsOptions, Tag } fr export type ObjectStoreState = { objects: Ref>; selectedObjects: Ref>; // All selected table row items + unfilteredObjectIds: Ref>; } export const useObjectStore = defineStore('object', () => { @@ -27,12 +28,14 @@ export const useObjectStore = defineStore('object', () => { const state: ObjectStoreState = { objects: ref([]), selectedObjects: ref([]), + unfilteredObjectIds: ref([]), }; // Getters const getters = { getObjects: computed(() => state.objects.value), - getSelectedObjects: computed(() => state.selectedObjects.value) + getSelectedObjects: computed(() => state.selectedObjects.value), + getUnfilteredObjectIds: computed(() => state.unfilteredObjectIds.value), }; // Actions @@ -155,9 +158,14 @@ export const useObjectStore = defineStore('object', () => { // Merge and assign state.objects.value = difference.concat(response); + // Track all the object IDs that the user would have access to in the table (even if filters are applied) + if(!tagset && !metadata) { + state.unfilteredObjectIds.value = state.objects.value.map((o) => o.id); + } } else { state.objects.value = response; + state.unfilteredObjectIds.value = []; } } }