Skip to content

Commit

Permalink
#1340 and #1341
Browse files Browse the repository at this point in the history
  • Loading branch information
boriskovar-m2ms committed Feb 20, 2024
1 parent b543e50 commit 7caa384
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 14 deletions.
4 changes: 2 additions & 2 deletions js/components/preview/molecule/observationCmpList.js
Original file line number Diff line number Diff line change
Expand Up @@ -701,8 +701,8 @@ export const ObservationCmpList = memo(({ hideProjects }) => {
let filteredLHSCompoundsList = useMemo(() => {
const compounds = [];
lhsCompoundsList.forEach(compound => {
const molsForCmp = joinedMoleculeLists.filter(molecule => molecule.cmpd === compound.origId);
if (molsForCmp?.length > 0) {
const molsForCmp = joinedMoleculeLists.some(molecule => molecule.cmpd === compound.origId);
if (molsForCmp && compound.associatedObs.some(obs => joinedMoleculeLists.some(mol => mol.id === obs.id))) {
compounds.push(compound);
}
});
Expand Down
15 changes: 7 additions & 8 deletions js/components/preview/molecule/redux/dispatchActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ export const initializeMolecules = majorView => (dispatch, getState) => {
} else if (noTagsReceived) {
// firstMolecule = dispatch(getFirstMolecule());
}
firstMolecule = dispatch(getFirstMolOfFirstCompound());
firstMolecule = dispatch(getFirstMolOfFirstCompound(firstTag));
if (firstMolecule) {
dispatch(addHitProtein(majorView, firstMolecule, colourList[firstMolecule.id % colourList.length], true)).then(
() => {
Expand Down Expand Up @@ -705,16 +705,15 @@ export const getFirstTagAlphabetically = () => (dispatch, getState) => {
return sortedTags && sortedTags.length > 0 ? sortedTags[0] : null;
};

export const getFirstMolOfFirstCompound = () => (dispatch, getState) => {
export const getFirstMolOfFirstCompound = tag => (dispatch, getState) => {
const state = getState();
const compoundsList = state.apiReducers.lhs_compounds_list;
const firstCompound = compoundsList[0];
const firstCompound = compoundsList?.find(c => c.associatedObs.some(obs => obs.tags_set.includes(tag.id)));
if (firstCompound) {
if (firstCompound.associatedObs?.length > 0) {
return firstCompound.associatedObs[0];
} else {
return null;
}
let firstObs = null;
firstObs = firstCompound.associatedObs.find(obs => obs.tags_set.includes(tag.id));

return firstObs;
} else {
return null;
}
Expand Down
9 changes: 6 additions & 3 deletions js/components/preview/tags/details/tagDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import {
compareTagsByCreatorAsc,
compareTagsByCreatorDesc,
compareTagsByDateAsc,
compareTagsByDateDesc
compareTagsByDateDesc,
getCategoriesToBeRemovedFromTagDetails
} from '../utils/tagUtils';
import { UnfoldMore, KeyboardArrowDown, KeyboardArrowUp } from '@material-ui/icons';
import { getMoleculeForId } from '../redux/dispatchActions';
Expand Down Expand Up @@ -165,6 +166,7 @@ const TagDetails = memo(() => {
const displayUntaggedMolecules = useSelector(state => state.selectionReducers.displayUntaggedMolecules);
let tagDetailView = useSelector(state => state.selectionReducers.tagDetailView);
const resizableLayout = useSelector(state => state.selectionReducers.resizableLayout);
const tagCategories = useSelector(state => state.apiReducers.categoryList);

const [tagList, setTagList] = useState([]);
const [selectAll, setSelectAll] = useState(true);
Expand All @@ -180,8 +182,9 @@ const TagDetails = memo(() => {
}, [searchString, tagList]);

useEffect(() => {
const categoriesToRemove = getCategoriesToBeRemovedFromTagDetails(tagCategories);
const newTagList = preTagList.filter(t => {
if (t.additional_info?.downloadName) {
if (t.additional_info?.downloadName || categoriesToRemove.some(c => c.id === t.category)) {
return false;
} else {
return true;
Expand All @@ -191,7 +194,7 @@ const TagDetails = memo(() => {
return () => {
setTagList([]);
};
}, [preTagList]);
}, [preTagList, tagCategories]);

const moleculesToEditIds = useSelector(state => state.selectionReducers.moleculesToEdit);
const moleculesToEdit =
Expand Down
16 changes: 15 additions & 1 deletion js/components/preview/tags/utils/tagUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { is } from 'date-fns/locale';
import {
CATEGORY_TYPE_BY_ID,
OBSERVATION_TAG_CATEGORIES,
COMPOUND_PRIO_TAG_CATEGORIES
COMPOUND_PRIO_TAG_CATEGORIES,
TAG_DETAILS_REMOVED_CATEGORIES
} from '../../../../constants/constants';

export const DEFAULT_TAG_COLOR = '#E0E0E0';
Expand Down Expand Up @@ -166,6 +167,19 @@ export const getAllTagsForObservation = (obs, tagList, tagCategoryList) => {
return result;
};

export const getCategoriesToBeRemovedFromTagDetails = tagCategoryList => {
const result = [];

TAG_DETAILS_REMOVED_CATEGORIES.forEach(categName => {
const categ = tagCategoryList.find(c => c.category === categName);
if (categ) {
result.push({ ...categ });
}
});

return result;
};

export const getCompoundPriorityTagConfig = (tagCategoryList, isSingleObs) => {
const result = [];

Expand Down
1 change: 1 addition & 0 deletions js/constants/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const CATEGORY_TYPE_BY_ID = {

export const OBSERVATION_TAG_CATEGORIES = ['ConformerSites', 'CrystalformSites', 'Quatassemblies', 'Crystalforms'];
export const COMPOUND_PRIO_TAG_CATEGORIES = ['CanonSites'];
export const TAG_DETAILS_REMOVED_CATEGORIES = ['CrystalformSites', 'ConformerSites'];

export const TAG_TYPE = {
ALL: 'ALL',
Expand Down

0 comments on commit 7caa384

Please sign in to comment.