Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/715 expand loses node text #715 #1004

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/card/CardThunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const updateReportTypeThunk = (id, type) => (dispatch: any, getState: any
};

export const updateFieldsThunk =
(id, fields, schema = false) =>
(id, fields, schema = false, additive = false) =>
(dispatch: any, getState: any) => {
try {
const state = getState();
Expand Down Expand Up @@ -118,7 +118,9 @@ export const updateFieldsThunk =
}
} else if (selectableFields[selection].type == SELECTION_TYPES.NODE_PROPERTIES) {
// For node property selections, select the most obvious properties of the node to display.
const selection = getSelectionBasedOnFields(fields, oldSelection, autoAssignSelectedProperties);
// Add in oldSelection and additive boolean to determine if we default to oldSelection first to reuse previously
// set selections
const selection = getSelectionBasedOnFields(fields, oldSelection, autoAssignSelectedProperties, additive);
dispatch(updateAllSelections(pagenumber, id, selection));
} else {
// Else, default the selection to the Nth item of the result set fields.
Expand Down
12 changes: 10 additions & 2 deletions src/chart/ChartUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,16 @@ export function castToNeo4jDate(value: object) {
/**
* Creates a default selection config for a node-property based chart footer.
*/
export function getSelectionBasedOnFields(fields, oldSelection = {}, autoAssignSelectedProperties = true) {
const selection = {};
export function getSelectionBasedOnFields(
fields,
oldSelection = {},
autoAssignSelectedProperties = true,
additive: boolean
) {
// if additive, keep the old selection
const selection = additive ? structuredClone(oldSelection) : {};

// if new field not found in old selection, use a default
fields.forEach((nodeLabelAndProperties) => {
const label = nodeLabelAndProperties[0];
const properties = nodeLabelAndProperties.slice(1);
Expand Down
10 changes: 5 additions & 5 deletions src/report/Report.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ export const NeoReport = ({
}
const debouncedRunCypherQuery = useCallback(debounce(runCypherQuery, RUN_QUERY_DELAY_MS), []);

const setSchema = (id, schema) => {
const setSchema = (id, schema, additive = false) => {
if (type === 'graph' || type === 'map' || type === 'gantt' || type === 'graph3d') {
setSchemaDispatch(id, schema);
setSchemaDispatch(id, schema, additive); // schema=true
}
};
const populateReport = (debounced = true) => {
Expand Down Expand Up @@ -221,7 +221,7 @@ export const NeoReport = ({
HARD_ROW_LIMITING,
queryTimeLimit,
(schema) => {
setSchema(id, schema);
setSchema(id, schema, true);
}
);
},
Expand Down Expand Up @@ -357,8 +357,8 @@ const mapDispatchToProps = (dispatch) => ({
getCustomDispatcher: () => {
return dispatch;
},
setSchemaDispatch: (id: any, schema: any) => {
dispatch(updateFieldsThunk(id, schema, true));
setSchemaDispatch: (id: any, schema: any, additive: boolean) => {
dispatch(updateFieldsThunk(id, schema, true, additive));
},
});

Expand Down