From 63122eb9c63f7b647c578c50268ec3cb6069da9e Mon Sep 17 00:00:00 2001 From: Boris Kovar Date: Tue, 7 Nov 2023 12:03:11 +0100 Subject: [PATCH] - checkpoint --- .../preview/molecule/hitNavigator.js | 3 ++- .../preview/molecule/observationCmpList.js | 1 + .../observationCmpView/observationCmpView.js | 4 ++-- js/reducers/selection/actions.js | 21 +++++++++++++++++++ js/reducers/selection/constants.js | 4 ++++ js/reducers/selection/selectionReducers.js | 12 +++++++++++ 6 files changed, 42 insertions(+), 3 deletions(-) diff --git a/js/components/preview/molecule/hitNavigator.js b/js/components/preview/molecule/hitNavigator.js index a1625f336..18aa9876b 100644 --- a/js/components/preview/molecule/hitNavigator.js +++ b/js/components/preview/molecule/hitNavigator.js @@ -3,9 +3,10 @@ */ import React, { memo } from 'react'; import { MoleculeList } from './moleculeList'; +import { ObservationCmpList } from './observationCmpList'; const HitNavigator = memo(({ hideProjects }) => { - return ; + return ; }); export default HitNavigator; diff --git a/js/components/preview/molecule/observationCmpList.js b/js/components/preview/molecule/observationCmpList.js index afe0ceb23..4cb59732c 100644 --- a/js/components/preview/molecule/observationCmpList.js +++ b/js/components/preview/molecule/observationCmpList.js @@ -288,6 +288,7 @@ export const ObservationCmpList = memo(({ hideProjects }) => { const isTagEditorOpen = useSelector(state => state.selectionReducers.tagEditorOpened); const molForTagEditId = useSelector(state => state.selectionReducers.molForTagEdit); const moleculesToEditIds = useSelector(state => state.selectionReducers.moleculesToEdit); + const obsCmpsToEditIds = useSelector(state => state.selectionReducers.obsCmpsToEdit); const isGlobalEdit = useSelector(state => state.selectionReducers.isGlobalEdit); const object_selection = useSelector(state => state.selectionReducers.mol_group_selection); diff --git a/js/components/preview/molecule/observationCmpView/observationCmpView.js b/js/components/preview/molecule/observationCmpView/observationCmpView.js index a58bce78a..a61a6a2b5 100644 --- a/js/components/preview/molecule/observationCmpView/observationCmpView.js +++ b/js/components/preview/molecule/observationCmpView/observationCmpView.js @@ -50,13 +50,13 @@ import { MOL_TYPE } from '../redux/constants'; import { DensityMapsModal } from '../modals/densityMapsModal'; import { getRandomColor } from '../utils/color'; import { DEFAULT_TAG_COLOR, getAllTagsForMol } from '../../tags/utils/tagUtils'; -import MoleculeSelectCheckbox from './moleculeSelectCheckbox'; import useClipboard from 'react-use-clipboard'; import Popover from '@mui/material/Popover'; import Typography from '@mui/material/Typography'; import { Edit } from '@material-ui/icons'; import { DJANGO_CONTEXT } from '../../../../utils/djangoContext'; import { getFontColorByBackgroundColor } from '../../../../utils/colors'; +import MoleculeSelectCheckbox from '../moleculeView/moleculeSelectCheckbox'; const useStyles = makeStyles(theme => ({ container: { @@ -928,7 +928,7 @@ const ObservationCmpView = memo( }); }; - let moleculeTitle = data?.code.replace(new RegExp(`${target_on_name}-`, 'i'), ''); + let moleculeTitle = data.smiles; const moleculeLPCControlButtonDisabled = ['ligand', 'protein', 'complex'].some( type => disableMoleculeNglControlButtons[type] diff --git a/js/reducers/selection/actions.js b/js/reducers/selection/actions.js index 21ed3a241..7bd53f8c3 100644 --- a/js/reducers/selection/actions.js +++ b/js/reducers/selection/actions.js @@ -447,6 +447,27 @@ export const removeFromMolListToEdit = molId => { }; }; +export const setObsCmpListToEdit = list => { + return { + type: constants.SET_OBS_MOL_LIST_TO_EDIT, + list: list + }; +}; + +export const appendToObsCmpListToEdit = cmpId => { + return { + type: constants.APPEND_TO_OBS_MOL_LIST_TO_EDIT, + cmpId: cmpId + }; +}; + +export const removeFromObsCmpListToEdit = cmpId => { + return { + type: constants.REMOVE_FROM_OBS_MOL_LIST_TO_EDIT, + molId: cmpId + }; +}; + export const setTagToEdit = tag => { return { type: constants.SET_TAG_TO_EDIT, diff --git a/js/reducers/selection/constants.js b/js/reducers/selection/constants.js index 1fb8587bd..011716efa 100644 --- a/js/reducers/selection/constants.js +++ b/js/reducers/selection/constants.js @@ -72,6 +72,10 @@ export const constants = { APPEND_TO_MOL_LIST_TO_EDIT: prefix + 'APPEND_TO_MOL_LIST_TO_EDIT', REMOVE_FROM_MOL_LIST_TO_EDIT: prefix + 'REMOVE_FROM_MOL_LIST_TO_EDIT', + SET_OBS_MOL_LIST_TO_EDIT: prefix + 'SET_OBS_MOL_LIST_TO_EDIT', + APPEND_TO_OBS_MOL_LIST_TO_EDIT: prefix + 'APPEND_TO_OBS_MOL_LIST_TO_EDIT', + REMOVE_FROM_OBS_MOL_LIST_TO_EDIT: prefix + 'REMOVE_FROM_OBS_MOL_LIST_TO_EDIT', + SET_TAG_TO_EDIT: prefix + 'SET_TAG_TO_EDIT', SET_DISPLAY_ALL_MOLECULES: prefix + 'SET_DISPLAY_ALL_MOLECULES', SET_DISPLAY_UNTAGGED_MOLECULES: prefix + 'SET_DISPLAY_UNTAGGED_MOLECULES', diff --git a/js/reducers/selection/selectionReducers.js b/js/reducers/selection/selectionReducers.js index 7869186ad..95a200038 100644 --- a/js/reducers/selection/selectionReducers.js +++ b/js/reducers/selection/selectionReducers.js @@ -39,6 +39,8 @@ export const INITIAL_STATE = { currentVector: null, // selected vector smile (ID) of compoundsOfVectors moleculesToEdit: [], + obsCmpsToEdit: [], + // tags tagToEdit: null, //display all molecules in hit navigator regardless of the tag selection @@ -425,6 +427,16 @@ export function selectionReducers(state = INITIAL_STATE, action = {}) { let reducedMolListToEdit = state.moleculesToEdit.filter(mid => mid !== action.molId); return { ...state, moleculesToEdit: [...reducedMolListToEdit] }; + case constants.SET_OBS_MOL_LIST_TO_EDIT: + return { ...state, obsCmpsToEdit: [...action.list] }; + + case constants.APPEND_TO_OBS_MOL_LIST_TO_EDIT: + return { ...state, obsCmpsToEdit: [...state.obsCmpsToEdit, action.cmpId] }; + + case constants.REMOVE_FROM_OBS_MOL_LIST_TO_EDIT: + let reducedObsCmpListToEdit = state.obsCmpsToEdit.filter(cid => cid !== action.cmpId); + return { ...state, obsCmpsToEdit: [...reducedObsCmpListToEdit] }; + case constants.SET_TAG_TO_EDIT: { return Object.assign({}, state, { tagToEdit: action.tagToEdit