Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 2fd529e
Author: Boris Kovar <[email protected]>
Date:   Mon Dec 16 10:44:15 2024 +0100

    - changes labels in searchSettingsDialog

commit 12499a9
Author: Boris Kovar <[email protected]>
Date:   Mon Dec 16 09:47:05 2024 +0100

    -small fix

commit cbf95f1
Merge: 5bd7756 900d851
Author: Boris Kovar <[email protected]>
Date:   Thu Dec 12 13:34:14 2024 +0100

    Merge branch '#1563-LHS-search' of https://github.com/m2ms/fragalysis-frontend into #1563-LHS-search

commit 5bd7756
Author: Boris Kovar <[email protected]>
Date:   Thu Dec 12 13:30:00 2024 +0100

    - search aliases

commit 3e7540f
Author: Boris Kovar <[email protected]>
Date:   Tue Dec 10 12:12:03 2024 +0100

    - checkpoint

commit 6631373
Author: Boris Kovar <[email protected]>
Date:   Fri Dec 6 10:05:51 2024 +0100

    - #1563 - all the UI and infrastructure and search by shortcode and compound id is done

commit 900d851
Author: Boris Kovar <[email protected]>
Date:   Thu Dec 12 13:30:00 2024 +0100

    - search aliases

commit a72f427
Author: Boris Kovar <[email protected]>
Date:   Tue Dec 10 12:12:03 2024 +0100

    - checkpoint

commit 4b7d699
Merge: 4579a9d 32c837d
Author: Boris Kovar <[email protected]>
Date:   Tue Dec 10 10:26:34 2024 +0100

    Merge branch '#1563-LHS-search' of https://github.com/m2ms/fragalysis-frontend into #1563-LHS-search

commit 4579a9d
Author: Boris Kovar <[email protected]>
Date:   Fri Dec 6 10:05:51 2024 +0100

    - #1563 - all the UI and infrastructure and search by shortcode and compound id is done

commit 32c837d
Author: Boris Kovar <[email protected]>
Date:   Fri Dec 6 10:05:51 2024 +0100

    - #1563 - all the UI and infrastructure and search by shortcode and compound id is done
  • Loading branch information
boriskovar-m2ms committed Dec 16, 2024
1 parent 1561ea2 commit 3b607e9
Show file tree
Hide file tree
Showing 10 changed files with 372 additions and 144 deletions.
27 changes: 23 additions & 4 deletions js/components/common/Components/SearchField/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useMemo } from 'react';
import { makeStyles, TextField, InputAdornment } from '@material-ui/core';
import { makeStyles, TextField, InputAdornment, IconButton } from '@material-ui/core';
import { Search } from '@material-ui/icons';
import classNames from 'classnames';
import { debounce } from 'lodash';
Expand Down Expand Up @@ -31,9 +31,18 @@ const useStyles = makeStyles(theme => ({
}
}));

const SearchField = ({ className, id, placeholder, size, onChange, disabled, searchString }) => {
const SearchField = ({
className,
id,
placeholder,
size,
onChange,
disabled,
searchString,
searchIconAction = null
}) => {
const classes = useStyles();
let value = searchString ?? '';
let value = searchString ?? '';

const debounced = useMemo(
() =>
Expand All @@ -57,7 +66,17 @@ const SearchField = ({ className, id, placeholder, size, onChange, disabled, sea
InputProps={{
startAdornment: (
<InputAdornment position="start">
<Search color="inherit" />
{searchIconAction ? (
<IconButton
color="inherit"
sx={{ pointerEvents: 'auto', cursor: 'pointer' }}
onClick={() => searchIconAction(true)}
>
<Search color="inherit" />
</IconButton>
) : (
<Search color="inherit" />
)}
</InputAdornment>
),
className: classes.input
Expand Down
48 changes: 7 additions & 41 deletions js/components/preview/molecule/moleculeList.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ import {
withDisabledMoleculesNglControlButtons,
removeSelectedTypesInHitNavigator,
selectAllHits,
autoHideTagEditorDialogsOnScroll
autoHideTagEditorDialogsOnScroll,
searchForObservations
} from './redux/dispatchActions';
import { DEFAULT_FILTER, PREDEFINED_FILTERS } from '../../../reducers/selection/constants';
import { Edit, FilterList } from '@material-ui/icons';
Expand Down Expand Up @@ -288,6 +289,8 @@ export const MoleculeList = memo(({ hideProjects }) => {

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

const searchSettings = useSelector(state => state.selectionReducers.searchSettings);

const all_mol_lists = useSelector(state => state.apiReducers.all_mol_lists);
const directDisplay = useSelector(state => state.apiReducers.direct_access);
const directAccessProcessed = useSelector(state => state.apiReducers.direct_access_processed);
Expand Down Expand Up @@ -321,17 +324,13 @@ export const MoleculeList = memo(({ hideProjects }) => {
}, [object_selection]);*/

let joinedMoleculeLists = useMemo(() => {
// const searchedString = currentActionList.find(action => action.type === 'SEARCH_STRING_HIT_NAVIGATOR');
if (searchString) {
return allMoleculesList.filter(molecule => molecule.code.toLowerCase().includes(searchString.toLowerCase()));
// } else if (searchedString) {
// return getJoinedMoleculeList.filter(molecule =>
// molecule.protein_code.toLowerCase().includes(searchedString.searchStringHitNavigator.toLowerCase())
// );
// return allMoleculesList.filter(molecule => molecule.code.toLowerCase().includes(searchString.toLowerCase()));
return dispatch(searchForObservations(searchString, allMoleculesList, searchSettings));
} else {
return getJoinedMoleculeList;
}
}, [getJoinedMoleculeList, allMoleculesList, searchString]);
}, [searchString, dispatch, allMoleculesList, searchSettings, getJoinedMoleculeList]);

const addSelectedMoleculesFromUnselectedSites = useCallback(
(joinedMoleculeLists, list) => {
Expand Down Expand Up @@ -849,40 +848,7 @@ export const MoleculeList = memo(({ hideProjects }) => {

const openGlobalTagEditor = () => {};

// let filterSearchString = '';
// const getSearchedString = () => {
// filterSearchString = currentActionList.find(action => action.type === 'SEARCH_STRING_HIT_NAVIGATOR');
// };
// getSearchedString();

// useEffect(() => {
// if (filterSearchString?.searchStringHitNavigator !== '') {
// setSearchString(filterSearchString.searchStringHitNavigator);
// }
// }, [filterSearchString]);

const actions = [
/* do not disable filter by itself if it does not have any result */
/*<FormControl className={classes.formControl} disabled={({predefinedFilter} === 'none' && !joinedMoleculeListsCopy.length) || sortDialogOpen}>
<Select
className={classes.select}
value={predefinedFilter}
onChange={changePredefinedFilter}
inputProps={{
name: 'predefined',
id: 'predefined-label-placeholder',
classes: { icon: classes.selectIcon }
}}
displayEmpty
name="predefined"
>
{Object.keys(PREDEFINED_FILTERS).map(preFilterKey => (
<MenuItem key={`Predefined-filter-${preFilterKey}`} value={preFilterKey}>
{PREDEFINED_FILTERS[preFilterKey].name}
</MenuItem>
))}
</Select>
</FormControl>,*/
<SearchField
className={classes.search}
id="search-hit-navigator"
Expand Down
28 changes: 18 additions & 10 deletions js/components/preview/molecule/observationCmpList.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ import {
removeSelectedTypesInHitNavigator,
selectAllHits,
autoHideTagEditorDialogsOnScroll,
selectAllVisibleObservations
selectAllVisibleObservations,
searchForObservations
} from './redux/dispatchActions';
import { DEFAULT_FILTER, PREDEFINED_FILTERS } from '../../../reducers/selection/constants';
import { Edit, FilterList } from '@material-ui/icons';
Expand All @@ -64,7 +65,8 @@ import {
setOpenObservationsDialog,
setLHSCompoundsInitialized,
setPoseIdForObservationsDialog,
setObservationDialogAction
setObservationDialogAction,
setSearchSettingsDialogOpen
} from '../../../reducers/selection/actions';
import { initializeFilter } from '../../../reducers/selection/dispatchActions';
import * as listType from '../../../constants/listTypes';
Expand All @@ -88,6 +90,7 @@ import { DJANGO_CONTEXT } from '../../../utils/djangoContext';
import ObservationCmpView from './observationCmpView';
import { ObservationsDialog } from './observationsDialog';
import { useScrollToSelectedPose } from './useScrollToSelectedPose';
import { SearchSettingsDialog } from './searchSettingsDialog';

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

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

const searchSettingsDialogOpen = useSelector(state => state.selectionReducers.searchSettingsDialogOpen);
const searchSettings = useSelector(state => state.selectionReducers.searchSettings);

const [predefinedFilter, setPredefinedFilter] = useState(filter !== undefined ? filter.predefined : DEFAULT_FILTER);

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

let joinedMoleculeLists = useMemo(() => {
// const searchedString = currentActionList.find(action => action.type === 'SEARCH_STRING_HIT_NAVIGATOR');
if (searchString) {
return allMoleculesList.filter(molecule => molecule.code.toLowerCase().includes(searchString.toLowerCase()));
// } else if (searchedString) {
// return getJoinedMoleculeList.filter(molecule =>
// molecule.protein_code.toLowerCase().includes(searchedString.searchStringHitNavigator.toLowerCase())
// );
return dispatch(searchForObservations(searchString, allMoleculesList, searchSettings));
} else {
return getJoinedMoleculeList;
}
}, [getJoinedMoleculeList, allMoleculesList, searchString]);
}, [searchString, dispatch, allMoleculesList, getJoinedMoleculeList, searchSettings]);

const addSelectedMoleculesFromUnselectedSites = useCallback(
(joinedMoleculeLists, list) => {
Expand Down Expand Up @@ -1014,6 +1014,10 @@ export const ObservationCmpList = memo(({ hideProjects }) => {
return molecules;
};

const openSearchSettingsDialog = open => {
dispatch(setSearchSettingsDialogOpen(open));
};

const actions = [
<SearchField
className={classes.search}
Expand All @@ -1026,6 +1030,7 @@ export const ObservationCmpList = memo(({ hideProjects }) => {
// searchString={filterSearchString?.searchStringHitNavigator ?? ''}
searchString={searchString ?? ''}
placeholder="Search"
searchIconAction={openSearchSettingsDialog}
/>,

<IconButton
Expand Down Expand Up @@ -1118,6 +1123,9 @@ export const ObservationCmpList = memo(({ hideProjects }) => {
setIsOpenLPCAlert(false);
}}
/>
{searchSettingsDialogOpen && (
<SearchSettingsDialog openDialog={searchSettingsDialogOpen} setOpenDialog={openSearchSettingsDialog} />
)}
{isObservationDialogOpen && (
<ObservationsDialog open={isObservationDialogOpen} anchorEl={tagEditorAnchorEl} ref={tagEditorRef} />
)}
Expand Down
Loading

0 comments on commit 3b607e9

Please sign in to comment.