Skip to content

Commit

Permalink
Fixes #866. Was using .includes(parseInt(row.concept_id)) for expand
Browse files Browse the repository at this point in the history
collapse; forgot that unlinked concepts have a fake parent with
concept_id of 'unlinked'.
  • Loading branch information
Sigfried committed Sep 5, 2024
1 parent 6c9ec11 commit 234bb01
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
7 changes: 5 additions & 2 deletions frontend/src/components/CsetComparisonPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -679,8 +679,11 @@ function getCollapseIconAndName(
let Component;
let direction;
if (
graphOptions.specificNodesExpanded.includes(parseInt(row.concept_id)) ||
(graphOptions.expandAll && !graphOptions.specificNodesCollapsed.includes(parseInt(row.concept_id)))
// graphOptions.specificNodesExpanded.includes(parseInt(row.concept_id)) ||
// (graphOptions.expandAll && !graphOptions.specificNodesCollapsed.includes(parseInt(row.concept_id)))
// parseInt means it doesn't work with the 'unlinked' node
graphOptions.specificNodesExpanded.find(d => d == row.concept_id) ||
(graphOptions.expandAll && !graphOptions.specificNodesCollapsed.find(d => d == row.concept_id))
) {
Component = RemoveCircleOutline;
direction = 'collapse';
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/state/GraphState.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ export class GraphContainer {
// this.displayedRows.push(row);

if ((row.expanded || graphOptions.expandAll || // todo: get rid of row.expanded property -- not using anymore, right?
graphOptions.specificNodesExpanded.includes(parseInt(nodeId))) &&
! graphOptions.specificNodesCollapsed.includes(parseInt(nodeId))
graphOptions.specificNodesExpanded.find(d => d == row.concept_id) &&
! graphOptions.specificNodesCollapsed.find(d => d == row.concept_id))
) {
// now with tracking specificNodesExpanded/Collapsed, I'm not sure if we
// still need to check row.expanded
Expand Down Expand Up @@ -494,20 +494,20 @@ export class GraphContainer {
if (typeof(displayOption.specialTreatmentDefault) !== 'undefined') {
if (typeof (displayOption.specialTreatment) === 'undefined') {
// set specialTreatment to default only when initializing stats options
type === 'addedCids' && console.log(`setting ${type} to default`);
// type === 'addedCids' && console.log(`setting ${type} to default`);
displayOption.specialTreatment = displayOption.specialTreatmentDefault;
}
if (typeof(graphOptions.specialConceptTreatment[type]) === 'undefined') {
// set specialConceptTreatment[type] only when not already in graphOptions
type === 'addedCids' && console.log(`setting graphOption.specialConceptTreatment.${type} to ${displayOption.specialTreatment}`);
// type === 'addedCids' && console.log(`setting graphOption.specialConceptTreatment.${type} to ${displayOption.specialTreatment}`);
graphOptions.specialConceptTreatment[type] = displayOption.specialTreatment;
} else {
// already have an option set, use that
// this is wrong, but allows flipping bit if other bit is true
// graphOptions.specialConceptTreatment[type] = (Boolean(graphOptions.specialConceptTreatment[type] + displayOption.specialTreatment) % 2);
// no this is wrong
displayOption.specialTreatment = graphOptions.specialConceptTreatment[type];
type === 'addedCids' && console.log(`just set specialTreatment.${type} to ${displayOption.specialTreatment}`);
// type === 'addedCids' && console.log(`just set specialTreatment.${type} to ${displayOption.specialTreatment}`);
}
}
displayOptions[type] = displayOption;
Expand Down

0 comments on commit 234bb01

Please sign in to comment.