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 a bug where failing to start filtering by current value after the column results are re-ordered #2483

Merged
merged 1 commit into from
Aug 9, 2023
Merged
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
3 changes: 3 additions & 0 deletions .changeset/five-pants-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
'@finos/legend-graph': patch
---
5 changes: 5 additions & 0 deletions .changeset/shy-oranges-cheer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@finos/legend-query-builder': patch
---

Fix a bug where failing to start filtering by current value after the column results are re-ordered
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { uuid } from '@finos/legend-shared';
import { guaranteeNonNullable, uuid } from '@finos/legend-shared';

// Core
export enum BuilderType {
Expand Down Expand Up @@ -138,3 +138,19 @@ export class ClassExecutionResult extends ExecutionResult {
override builder = new ClassBuilder(BuilderType.CLASS_BUILDER);
objects!: object;
}

export const getTDSRowRankByColumnInAsc = (
a: TDSRow,
b: TDSRow,
colIndex: number,
): number => {
const a1 =
a.values[colIndex] === null || a.values[colIndex] === undefined
? -Infinity
: a.values[colIndex];
const b1 =
b.values[colIndex] === null || b.values[colIndex] === undefined
? -Infinity
: b.values[colIndex];
return Number(guaranteeNonNullable(a1)) - Number(guaranteeNonNullable(b1));
};
1 change: 1 addition & 0 deletions packages/legend-graph/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ export {
TDSExecutionResult as TDSExecutionResult,
RawExecutionResult,
EXECUTION_SERIALIZATION_FORMAT,
getTDSRowRankByColumnInAsc,
} from './graph-manager/action/execution/ExecutionResult.js';
export { ExternalFormatDescription } from './graph-manager/action/externalFormat/ExternalFormatDescription.js';
export * from './graph-manager/action/generation/ArtifactGenerationExtensionResult.js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import {
EnumValueInstanceValue,
EnumValueExplicitReference,
RelationalExecutionActivities,
getTDSRowRankByColumnInAsc,
} from '@finos/legend-graph';
import {
ActionAlertActionType,
Expand Down Expand Up @@ -523,10 +524,19 @@ const QueryResultCellRenderer = observer(
) {
return undefined;
}

return resultState.executionResult.result.rows[rowIndex]?.values[
colIndex
const sortedExecutionResult = [
...resultState.executionResult.result.rows,
];
if (params.columnApi.getColumnState()[colIndex]?.sort === 'asc') {
sortedExecutionResult.sort((a, b) =>
getTDSRowRankByColumnInAsc(a, b, colIndex),
);
} else if (params.columnApi.getColumnState()[colIndex]?.sort === 'desc') {
sortedExecutionResult.sort((a, b) =>
getTDSRowRankByColumnInAsc(b, a, colIndex),
);
}
return sortedExecutionResult[rowIndex]?.values[colIndex];
};

const isCoordinatesSelected = (
Expand Down