Skip to content

Commit 6631373

Browse files
- #1563 - all the UI and infrastructure and search by shortcode and compound id is done
1 parent 4118297 commit 6631373

9 files changed

Lines changed: 368 additions & 142 deletions

File tree

js/components/common/Components/SearchField/index.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useMemo } from 'react';
2-
import { makeStyles, TextField, InputAdornment } from '@material-ui/core';
2+
import { makeStyles, TextField, InputAdornment, IconButton } from '@material-ui/core';
33
import { Search } from '@material-ui/icons';
44
import classNames from 'classnames';
55
import { debounce } from 'lodash';
@@ -31,9 +31,18 @@ const useStyles = makeStyles(theme => ({
3131
}
3232
}));
3333

34-
const SearchField = ({ className, id, placeholder, size, onChange, disabled, searchString }) => {
34+
const SearchField = ({
35+
className,
36+
id,
37+
placeholder,
38+
size,
39+
onChange,
40+
disabled,
41+
searchString,
42+
searchIconAction = null
43+
}) => {
3544
const classes = useStyles();
36-
let value = searchString ?? '';
45+
let value = searchString ?? '';
3746

3847
const debounced = useMemo(
3948
() =>
@@ -57,7 +66,17 @@ const SearchField = ({ className, id, placeholder, size, onChange, disabled, sea
5766
InputProps={{
5867
startAdornment: (
5968
<InputAdornment position="start">
60-
<Search color="inherit" />
69+
{searchIconAction ? (
70+
<IconButton
71+
color="inherit"
72+
sx={{ pointerEvents: 'auto', cursor: 'pointer' }}
73+
onClick={() => searchIconAction(true)}
74+
>
75+
<Search color="inherit" />
76+
</IconButton>
77+
) : (
78+
<Search color="inherit" />
79+
)}
6180
</InputAdornment>
6281
),
6382
className: classes.input

js/components/preview/molecule/moleculeList.js

Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ import {
4545
withDisabledMoleculesNglControlButtons,
4646
removeSelectedTypesInHitNavigator,
4747
selectAllHits,
48-
autoHideTagEditorDialogsOnScroll
48+
autoHideTagEditorDialogsOnScroll,
49+
searchForObservations
4950
} from './redux/dispatchActions';
5051
import { DEFAULT_FILTER, PREDEFINED_FILTERS } from '../../../reducers/selection/constants';
5152
import { Edit, FilterList } from '@material-ui/icons';
@@ -288,6 +289,8 @@ export const MoleculeList = memo(({ hideProjects }) => {
288289

289290
const object_selection = useSelector(state => state.selectionReducers.mol_group_selection);
290291

292+
const searchSettings = useSelector(state => state.selectionReducers.searchSettings);
293+
291294
const all_mol_lists = useSelector(state => state.apiReducers.all_mol_lists);
292295
const directDisplay = useSelector(state => state.apiReducers.direct_access);
293296
const directAccessProcessed = useSelector(state => state.apiReducers.direct_access_processed);
@@ -321,17 +324,13 @@ export const MoleculeList = memo(({ hideProjects }) => {
321324
}, [object_selection]);*/
322325

323326
let joinedMoleculeLists = useMemo(() => {
324-
// const searchedString = currentActionList.find(action => action.type === 'SEARCH_STRING_HIT_NAVIGATOR');
325327
if (searchString) {
326-
return allMoleculesList.filter(molecule => molecule.code.toLowerCase().includes(searchString.toLowerCase()));
327-
// } else if (searchedString) {
328-
// return getJoinedMoleculeList.filter(molecule =>
329-
// molecule.protein_code.toLowerCase().includes(searchedString.searchStringHitNavigator.toLowerCase())
330-
// );
328+
// return allMoleculesList.filter(molecule => molecule.code.toLowerCase().includes(searchString.toLowerCase()));
329+
return dispatch(searchForObservations(searchString, allMoleculesList, searchSettings));
331330
} else {
332331
return getJoinedMoleculeList;
333332
}
334-
}, [getJoinedMoleculeList, allMoleculesList, searchString]);
333+
}, [searchString, dispatch, allMoleculesList, searchSettings, getJoinedMoleculeList]);
335334

336335
const addSelectedMoleculesFromUnselectedSites = useCallback(
337336
(joinedMoleculeLists, list) => {
@@ -849,40 +848,7 @@ export const MoleculeList = memo(({ hideProjects }) => {
849848

850849
const openGlobalTagEditor = () => {};
851850

852-
// let filterSearchString = '';
853-
// const getSearchedString = () => {
854-
// filterSearchString = currentActionList.find(action => action.type === 'SEARCH_STRING_HIT_NAVIGATOR');
855-
// };
856-
// getSearchedString();
857-
858-
// useEffect(() => {
859-
// if (filterSearchString?.searchStringHitNavigator !== '') {
860-
// setSearchString(filterSearchString.searchStringHitNavigator);
861-
// }
862-
// }, [filterSearchString]);
863-
864851
const actions = [
865-
/* do not disable filter by itself if it does not have any result */
866-
/*<FormControl className={classes.formControl} disabled={({predefinedFilter} === 'none' && !joinedMoleculeListsCopy.length) || sortDialogOpen}>
867-
<Select
868-
className={classes.select}
869-
value={predefinedFilter}
870-
onChange={changePredefinedFilter}
871-
inputProps={{
872-
name: 'predefined',
873-
id: 'predefined-label-placeholder',
874-
classes: { icon: classes.selectIcon }
875-
}}
876-
displayEmpty
877-
name="predefined"
878-
>
879-
{Object.keys(PREDEFINED_FILTERS).map(preFilterKey => (
880-
<MenuItem key={`Predefined-filter-${preFilterKey}`} value={preFilterKey}>
881-
{PREDEFINED_FILTERS[preFilterKey].name}
882-
</MenuItem>
883-
))}
884-
</Select>
885-
</FormControl>,*/
886852
<SearchField
887853
className={classes.search}
888854
id="search-hit-navigator"

js/components/preview/molecule/observationCmpList.js

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ import {
4949
removeSelectedTypesInHitNavigator,
5050
selectAllHits,
5151
autoHideTagEditorDialogsOnScroll,
52-
selectAllVisibleObservations
52+
selectAllVisibleObservations,
53+
searchForObservations
5354
} from './redux/dispatchActions';
5455
import { DEFAULT_FILTER, PREDEFINED_FILTERS } from '../../../reducers/selection/constants';
5556
import { Edit, FilterList } from '@material-ui/icons';
@@ -64,7 +65,8 @@ import {
6465
setOpenObservationsDialog,
6566
setLHSCompoundsInitialized,
6667
setPoseIdForObservationsDialog,
67-
setObservationDialogAction
68+
setObservationDialogAction,
69+
setSearchSettingsDialogOpen
6870
} from '../../../reducers/selection/actions';
6971
import { initializeFilter } from '../../../reducers/selection/dispatchActions';
7072
import * as listType from '../../../constants/listTypes';
@@ -88,6 +90,7 @@ import { DJANGO_CONTEXT } from '../../../utils/djangoContext';
8890
import ObservationCmpView from './observationCmpView';
8991
import { ObservationsDialog } from './observationsDialog';
9092
import { useScrollToSelectedPose } from './useScrollToSelectedPose';
93+
import { SearchSettingsDialog } from './searchSettingsDialog';
9194

9295
const useStyles = makeStyles(theme => ({
9396
container: {
@@ -277,7 +280,6 @@ export const ObservationCmpList = memo(({ hideProjects }) => {
277280
const moleculesPerPage = 30;
278281
const [currentPage, setCurrentPage] = useState(0);
279282
const searchString = useSelector(state => state.previewReducers.molecule.searchStringLHS);
280-
// const [searchString, setSearchString] = useState(null);
281283
const [sortDialogAnchorEl, setSortDialogAnchorEl] = useState(null);
282284
const oldUrl = useRef('');
283285
const setOldUrl = url => {
@@ -327,6 +329,9 @@ export const ObservationCmpList = memo(({ hideProjects }) => {
327329

328330
const proteinsHasLoaded = useSelector(state => state.nglReducers.proteinsHasLoaded);
329331

332+
const searchSettingsDialogOpen = useSelector(state => state.selectionReducers.searchSettingsDialogOpen);
333+
const searchSettings = useSelector(state => state.selectionReducers.searchSettings);
334+
330335
const [predefinedFilter, setPredefinedFilter] = useState(filter !== undefined ? filter.predefined : DEFAULT_FILTER);
331336

332337
const [ascending, setAscending] = useState(true);
@@ -467,17 +472,12 @@ export const ObservationCmpList = memo(({ hideProjects }) => {
467472
}, [object_selection]);*/
468473

469474
let joinedMoleculeLists = useMemo(() => {
470-
// const searchedString = currentActionList.find(action => action.type === 'SEARCH_STRING_HIT_NAVIGATOR');
471475
if (searchString) {
472-
return allMoleculesList.filter(molecule => molecule.code.toLowerCase().includes(searchString.toLowerCase()));
473-
// } else if (searchedString) {
474-
// return getJoinedMoleculeList.filter(molecule =>
475-
// molecule.protein_code.toLowerCase().includes(searchedString.searchStringHitNavigator.toLowerCase())
476-
// );
476+
return dispatch(searchForObservations(searchString, allMoleculesList, searchSettings));
477477
} else {
478478
return getJoinedMoleculeList;
479479
}
480-
}, [getJoinedMoleculeList, allMoleculesList, searchString]);
480+
}, [searchString, dispatch, allMoleculesList, getJoinedMoleculeList, searchSettings]);
481481

482482
const addSelectedMoleculesFromUnselectedSites = useCallback(
483483
(joinedMoleculeLists, list) => {
@@ -1014,6 +1014,10 @@ export const ObservationCmpList = memo(({ hideProjects }) => {
10141014
return molecules;
10151015
};
10161016

1017+
const openSearchSettingsDialog = open => {
1018+
dispatch(setSearchSettingsDialogOpen(open));
1019+
};
1020+
10171021
const actions = [
10181022
<SearchField
10191023
className={classes.search}
@@ -1026,6 +1030,7 @@ export const ObservationCmpList = memo(({ hideProjects }) => {
10261030
// searchString={filterSearchString?.searchStringHitNavigator ?? ''}
10271031
searchString={searchString ?? ''}
10281032
placeholder="Search"
1033+
searchIconAction={openSearchSettingsDialog}
10291034
/>,
10301035

10311036
<IconButton
@@ -1118,6 +1123,9 @@ export const ObservationCmpList = memo(({ hideProjects }) => {
11181123
setIsOpenLPCAlert(false);
11191124
}}
11201125
/>
1126+
{searchSettingsDialogOpen && (
1127+
<SearchSettingsDialog openDialog={searchSettingsDialogOpen} setOpenDialog={openSearchSettingsDialog} />
1128+
)}
11211129
{isObservationDialogOpen && (
11221130
<ObservationsDialog open={isObservationDialogOpen} anchorEl={tagEditorAnchorEl} ref={tagEditorRef} />
11231131
)}

0 commit comments

Comments
 (0)