Skip to content

Commit

Permalink
Merge pull request #227 from m2ms/allfunctionality
Browse files Browse the repository at this point in the history
Action capture fixes
  • Loading branch information
boriskovar-m2ms authored Jan 22, 2021
2 parents 2bb6a6f + 2d72fa1 commit 19864ba
Show file tree
Hide file tree
Showing 63 changed files with 3,136 additions and 774 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ npm-debug.log
*.offsets
yarn-error.log
/yarn.lock
/debug.log
15 changes: 10 additions & 5 deletions js/components/datasets/crossReferenceDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
} from './redux/dispatchActions';
import { Button } from '../common/Inputs/Button';
import classNames from 'classnames';
import { useDisableUserInteraction } from '../helpers/useEnableUserInteracion';
// import { useDisableUserInteraction } from '../helpers/useEnableUserInteracion';
import { colourList, DatasetMoleculeView } from './datasetMoleculeView';
import { NglContext } from '../nglView/nglProvider';
import { VIEWS } from '../../constants/constants';
Expand Down Expand Up @@ -132,7 +132,7 @@ export const CrossReferenceDialog = memo(

const { getNglView } = useContext(NglContext);
const stage = getNglView(VIEWS.MAJOR_VIEW) && getNglView(VIEWS.MAJOR_VIEW).stage;
const disableUserInteraction = useDisableUserInteraction();
// const disableUserInteraction = useDisableUserInteraction();

const moleculeList = useSelector(state => getCrossReferenceCompoundListByCompoundName(state));
const isLoadingCrossReferenceScores = useSelector(state => state.datasetsReducers.isLoadingCrossReferenceScores);
Expand Down Expand Up @@ -272,7 +272,7 @@ export const CrossReferenceDialog = memo(
onClick={() =>
dispatch(handleAllLigandsOfCrossReferenceDialog(isLigandOn, moleculeList, stage))
}
disabled={disableUserInteraction}
disabled={false}
>
L
</Button>
Expand All @@ -289,7 +289,7 @@ export const CrossReferenceDialog = memo(
onClick={() =>
dispatch(removeOrAddAllHitProteinsOfList(isProteinOn, moleculeList, stage))
}
disabled={disableUserInteraction}
disabled={false}
>
P
</Button>
Expand All @@ -305,7 +305,7 @@ export const CrossReferenceDialog = memo(
[classes.contColButtonHalfSelected]: isComplexOn === null
})}
onClick={() => dispatch(removeOrAddAllComplexesOfList(isComplexOn, moleculeList, stage))}
disabled={disableUserInteraction}
disabled={false}
>
C
</Button>
Expand Down Expand Up @@ -336,6 +336,11 @@ export const CrossReferenceDialog = memo(
previousItemData={previousData}
nextItemData={nextData}
removeOfAllSelectedTypes={removeOfAllSelectedTypes}
L={ligandList.includes(data.id)}
P={proteinList.includes(data.id)}
C={complexList.includes(data.id)}
S={false}
V={false}
/>
);
})}
Expand Down
84 changes: 53 additions & 31 deletions js/components/datasets/datasetMoleculeList.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
IconButton,
ButtonGroup
} from '@material-ui/core';
import React, { useState, useEffect, memo, useRef, useContext, useCallback } from 'react';
import React, { useState, useEffect, memo, useRef, useContext } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { DatasetMoleculeView, colourList } from './datasetMoleculeView';
import InfiniteScroll from 'react-infinite-scroller';
Expand All @@ -23,7 +23,7 @@ import { Panel } from '../common/Surfaces/Panel';
import { ComputeSize } from '../../utils/computeSize';
import { VIEWS } from '../../constants/constants';
import { NglContext } from '../nglView/nglProvider';
import { useDisableUserInteraction } from '../helpers/useEnableUserInteracion';
// import { useDisableUserInteraction } from '../helpers/useEnableUserInteracion';
import classNames from 'classnames';
import {
addDatasetLigand,
Expand All @@ -34,7 +34,9 @@ import {
removeDatasetComplex,
addDatasetSurface,
removeDatasetSurface,
autoHideDatasetDialogsOnScroll
autoHideDatasetDialogsOnScroll,
moveMoleculeInspirationsSettings,
removeAllSelectedDatasetMolecules
} from './redux/dispatchActions';
import { setFilterDialogOpen, setSearchStringOfCompoundSet } from './redux/actions';
import { DatasetFilter } from './datasetFilter';
Expand All @@ -44,6 +46,8 @@ import { debounce } from 'lodash';
import { InspirationDialog } from './inspirationDialog';
import { CrossReferenceDialog } from './crossReferenceDialog';
import { AlertModal } from '../common/Modal/AlertModal';
import { hideAllSelectedMolecules } from '../preview/molecule/redux/dispatchActions';
import { getMoleculeList } from '../preview/molecule/redux/selectors';
import { setSelectedAllByType, setDeselectedAllByType } from './redux/actions';

const useStyles = makeStyles(theme => ({
Expand Down Expand Up @@ -226,7 +230,10 @@ export const DatasetMoleculeList = memo(
const filterRef = useRef();
let joinedMoleculeLists = moleculeLists[datasetID] || [];

const disableUserInteraction = useDisableUserInteraction();
const getJoinedMoleculeList = useSelector(state => getMoleculeList(state));
const inspirationMoleculeDataList = useSelector(state => state.datasetsReducers.allInspirationMoleculeDataList);

// const disableUserInteraction = useDisableUserInteraction();

// TODO Reset Infinity scroll

Expand Down Expand Up @@ -258,6 +265,15 @@ export const DatasetMoleculeList = memo(

const selectedAll = useRef(false);

const objectsInView = useSelector(state => state.nglReducers.objectsInView) || {};

const proteinListMolecule = useSelector(state => state.selectionReducers.proteinList);
const complexListMolecule = useSelector(state => state.selectionReducers.complexList);
const fragmentDisplayListMolecule = useSelector(state => state.selectionReducers.fragmentDisplayList);
const surfaceListMolecule = useSelector(state => state.selectionReducers.surfaceList);
const densityListMolecule = useSelector(state => state.selectionReducers.densityList);
const vectorOnListMolecule = useSelector(state => state.selectionReducers.vectorOnList);

const ligandList = useSelector(state => state.datasetsReducers.ligandLists[datasetID]);
const proteinList = useSelector(state => state.datasetsReducers.proteinLists[datasetID]);
const complexList = useSelector(state => state.datasetsReducers.complexLists[datasetID]);
Expand All @@ -280,31 +296,30 @@ export const DatasetMoleculeList = memo(
surface: removeDatasetSurface
};

const removeOfAllSelectedTypesOfInspirations = () => {
let molecules = [...getJoinedMoleculeList, ...inspirationMoleculeDataList];
dispatch(hideAllSelectedMolecules(stage, [...molecules]));
};

const removeOfAllSelectedTypes = () => {
ligandList?.forEach(moleculeID => {
const foundedMolecule = joinedMoleculeLists?.find(mol => mol.id === moleculeID);
dispatch(
removeDatasetLigand(stage, foundedMolecule, colourList[foundedMolecule.id % colourList.length], datasetID)
);
});
proteinList?.forEach(moleculeID => {
const foundedMolecule = joinedMoleculeLists?.find(mol => mol.id === moleculeID);
dispatch(
removeDatasetHitProtein(stage, foundedMolecule, colourList[foundedMolecule.id % colourList.length], datasetID)
);
});
complexList?.forEach(moleculeID => {
const foundedMolecule = joinedMoleculeLists?.find(mol => mol.id === moleculeID);
dispatch(
removeDatasetComplex(stage, foundedMolecule, colourList[foundedMolecule.id % colourList.length], datasetID)
);
});
surfaceList?.forEach(moleculeID => {
const foundedMolecule = joinedMoleculeLists?.find(mol => mol.id === moleculeID);
dispatch(
removeDatasetSurface(stage, foundedMolecule, colourList[foundedMolecule.id % colourList.length], datasetID)
);
});
dispatch(removeAllSelectedDatasetMolecules(stage));
};

const moveSelectedMoleculeInspirationsSettings = (data, newItemData) => (dispatch, getState) => {
dispatch(
moveMoleculeInspirationsSettings(
data,
newItemData,
stage,
objectsInView,
fragmentDisplayListMolecule,
proteinListMolecule,
complexListMolecule,
surfaceListMolecule,
densityListMolecule,
vectorOnListMolecule
)
);
};

// TODO "currentMolecules" do not need to correspondent to selections in {type}List
Expand Down Expand Up @@ -552,7 +567,7 @@ export const DatasetMoleculeList = memo(
[classes.contColButtonSelected]: isLigandOn
})}
onClick={() => onButtonToggle('ligand')}
disabled={disableUserInteraction}
disabled={false}
>
L
</Button>
Expand All @@ -566,7 +581,7 @@ export const DatasetMoleculeList = memo(
[classes.contColButtonSelected]: isProteinOn
})}
onClick={() => onButtonToggle('protein')}
disabled={disableUserInteraction}
disabled={false}
>
P
</Button>
Expand All @@ -581,7 +596,7 @@ export const DatasetMoleculeList = memo(
[classes.contColButtonSelected]: isComplexOn
})}
onClick={() => onButtonToggle('complex')}
disabled={disableUserInteraction}
disabled={false}
>
C
</Button>
Expand Down Expand Up @@ -646,6 +661,13 @@ export const DatasetMoleculeList = memo(
previousItemData={index > 0 && array[index - 1]}
nextItemData={index < array?.length && array[index + 1]}
removeOfAllSelectedTypes={removeOfAllSelectedTypes}
removeOfAllSelectedTypesOfInspirations={removeOfAllSelectedTypesOfInspirations}
moveSelectedMoleculeInspirationsSettings={moveSelectedMoleculeInspirationsSettings}
L={ligandList.includes(data.id)}
P={proteinList.includes(data.id)}
C={complexList.includes(data.id)}
S={surfaceList.includes(data.id)}
V={false}
/>
))}
</InfiniteScroll>
Expand Down
Loading

0 comments on commit 19864ba

Please sign in to comment.