Skip to content

Commit

Permalink
- implemented #1172
Browse files Browse the repository at this point in the history
  • Loading branch information
boriskovar-m2ms committed Oct 13, 2023
1 parent 997d250 commit 574c7b5
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion js/components/datasets/selectedCompoundsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { CrossReferenceDialog } from './crossReferenceDialog';
import {
autoHideDatasetDialogsOnScroll,
getAllVisibleButNotLockedSelectedCompounds,
getInspirationsForMol,
isCompoundLocked,
isCompoundVisible,
moveDatasetMoleculeUpDown,
Expand Down Expand Up @@ -419,7 +420,9 @@ export const SelectedCompoundList = memo(() => {
const getUsedDatasets = mols => {
const setOfDataSets = {};
mols.forEach(mol => {
if (!setOfDataSets.hasOwnProperty(mol.datasetID)) setOfDataSets[mol.datasetID] = mol.datasetID;
if (!setOfDataSets.hasOwnProperty(mol.datasetID)) {
setOfDataSets[mol.datasetID] = mol.datasetID;
}
});

return setOfDataSets;
Expand Down Expand Up @@ -492,10 +495,36 @@ export const SelectedCompoundList = memo(() => {
});
});

const hasName = filteredCompounds.find(cmp => !!cmp.molecule.name);
let maxNumOfInspirations = 0;
const allInspirations = state.datasetsReducers.allInspirations;
filteredCompounds.forEach(cmp => {
const inspirations = getInspirationsForMol(allInspirations, cmp.datasetID, cmp.molecule.id);
if (inspirations?.length > maxNumOfInspirations) {
maxNumOfInspirations = inspirations.length;
}
});

filteredCompounds.forEach(compound => {
let molObj = getEmptyMolObject(props, ids);

if (hasName) {
molObj['name'] = compound.molecule.name ? compound.molecule.name : '';
}

molObj = populateMolObject(molObj, compound, props, ids);

if (maxNumOfInspirations) {
const inspirations = getInspirationsForMol(allInspirations, compound.datasetID, compound.molecule.id);
for (let i = 0; i < maxNumOfInspirations; i++) {
if (inspirations?.[i]) {
molObj[`inspiration_${i + 1}`] = inspirations[i].protein_code;
} else {
molObj[`inspiration_${i + 1}`] = '';
}
}
}

let shoppingCartColors = [];
if (isCompoundFromVectorSelector(compound.molecule)) {
shoppingCartColors = [compound.molecule.class];
Expand Down

0 comments on commit 574c7b5

Please sign in to comment.