Skip to content

Commit

Permalink
Fetch sub-collection when drilling down if not in store
Browse files Browse the repository at this point in the history
The DCObject information does not contain enough information (like `element_count` or `collection_id`) to handle the sub-collection elements navigation downstream.
  • Loading branch information
davelopez committed Sep 26, 2023
1 parent 69e924d commit 92f7a7d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import ExpandedItems from "@/components/History/Content/ExpandedItems";
import { updateContentFields } from "@/components/History/model/queries";
import { useCollectionElementsStore } from "@/stores/collectionElementsStore";
import { HistorySummary } from "@/stores/historyStore";
import { DCESummary, HDCASummary } from "@/stores/services";
import { DCESummary, DCObject, HDCASummary } from "@/stores/services";

import CollectionDetails from "./CollectionDetails.vue";
import CollectionNavigation from "./CollectionNavigation.vue";
Expand Down Expand Up @@ -59,19 +59,9 @@ function onScroll(newOffset: number) {
offset.value = newOffset;
}

/**
* Passes a sub-collection i.e a collection element object containing another collection, into
* a populated object for drill-down without the need for a separate data request. This object
* is used for breadcrumbs in the navigation component and to render the collection details and
* description at the top of the collection panel. Details include the collection name, the
* collection type, and the element count.
*/
function onViewSubCollection(itemObject: HDCASummary, elementIdentifier: string) {
const collectionObject = {
name: elementIdentifier,
...itemObject,
};
emit("view-collection", collectionObject);
async function onViewSubCollection(itemObject: DCObject) {
const collection = await collectionElementsStore.getCollection(itemObject.id);
emit("view-collection", collection);
}

watch(
Expand Down
1 change: 1 addition & 0 deletions client/src/stores/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export type DatasetDetails = components["schemas"]["HDADetailed"];
export type DCESummary = components["schemas"]["DCESummary"];
export type HDCASummary = components["schemas"]["HDCASummary"];
export type HDCADetailed = components["schemas"]["HDCADetailed"];
export type DCObject = components["schemas"]["DCObject"];

export type HistoryContentItemBase = components["schemas"]["EncodedHistoryContentItem"];

Expand Down

0 comments on commit 92f7a7d

Please sign in to comment.