Skip to content

Commit

Permalink
10467: add "Files & Links" tab of the Patient View to the Study View
Browse files Browse the repository at this point in the history
fixing a bug
  • Loading branch information
Nelliney committed Aug 9, 2024
1 parent 23d4233 commit 0cecacb
Show file tree
Hide file tree
Showing 5 changed files with 428 additions and 12 deletions.
13 changes: 12 additions & 1 deletion src/pages/studyView/StudyViewPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,17 @@ export default class StudyViewPage extends React.Component<
}
}

@computed get shouldShowSampleResources() {
if (this.store.sampleResourceData.isComplete) {
return _.some(
this.store.sampleResourceData.result,
data => data.length > 0
);
} else {
return false;
}
}

@computed get shouldShowResources() {
if (this.store.resourceIdToResourceData.isComplete) {
return _.some(
Expand Down Expand Up @@ -725,7 +736,7 @@ export default class StudyViewPage extends React.Component<
StudyViewPageTabKeyEnum.FILES_AND_LINKS
}
linkText={RESOURCES_TAB_NAME}
hide={!this.shouldShowResources}
hide={!this.shouldShowSampleResources}
>
<div>
<ResourcesTab
Expand Down
37 changes: 37 additions & 0 deletions src/pages/studyView/StudyViewPageStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5784,6 +5784,43 @@ export class StudyViewPageStore
},
});

readonly sampleResourceData = remoteData<{
[sampleId: string]: ResourceData[];
}>({
await: () => [this.resourceDefinitions, this.samples],
invoke: () => {
const sampleResourceDefinitions = this.resourceDefinitions.result!.filter(
d => d.resourceType === 'SAMPLE'
);
if (!sampleResourceDefinitions.length) {
return Promise.resolve({});
}

const samples = this.samples.result!;
const ret: { [sampleId: string]: ResourceData[] } = {};
const promises = [];
for (const sample of samples) {
for (const resource of sampleResourceDefinitions) {
promises.push(
internalClient
.getAllResourceDataOfSampleInStudyUsingGET({
sampleId: sample.sampleId,
studyId: sample.studyId, // TODO:
resourceId: resource.resourceId,
projection: 'DETAILED',
})
.then(data => {
ret[sample.sampleId] =
ret[sample.sampleId] || [];
ret[sample.sampleId].push(...data);
})
);
}
}
return Promise.all(promises).then(() => ret);
},
});

readonly resourceIdToResourceData = remoteData<{
[resourceId: string]: ResourceData[];
}>({
Expand Down
Loading

0 comments on commit 0cecacb

Please sign in to comment.