+3
@@ -0,0 +1,3 @@
|
||||
import { GraphOrderBy } from '~/generated/graphql';
|
||||
|
||||
export const GRAPH_DEFAULT_ORDER_BY = GraphOrderBy.FIELD_ASC;
|
||||
+77
@@ -10,6 +10,14 @@ exports[`generateGroupByQueryVariablesFromBarOrLineChartConfiguration Bar Chart
|
||||
"ownerId": true,
|
||||
},
|
||||
],
|
||||
"orderBy": [
|
||||
{
|
||||
"stage": "AscNullsLast",
|
||||
},
|
||||
{
|
||||
"ownerId": "AscNullsLast",
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -20,6 +28,11 @@ exports[`generateGroupByQueryVariablesFromBarOrLineChartConfiguration Bar Chart
|
||||
"stage": true,
|
||||
},
|
||||
],
|
||||
"orderBy": [
|
||||
{
|
||||
"stage": "AscNullsLast",
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -32,6 +45,13 @@ exports[`generateGroupByQueryVariablesFromBarOrLineChartConfiguration Bar Chart
|
||||
},
|
||||
},
|
||||
],
|
||||
"orderBy": [
|
||||
{
|
||||
"name": {
|
||||
"firstName": "AscNullsLast",
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -44,6 +64,14 @@ exports[`generateGroupByQueryVariablesFromBarOrLineChartConfiguration Bar Chart
|
||||
},
|
||||
},
|
||||
],
|
||||
"orderBy": [
|
||||
{
|
||||
"createdAt": {
|
||||
"granularity": "MONTH",
|
||||
"orderBy": "AscNullsLast",
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -54,6 +82,11 @@ exports[`generateGroupByQueryVariablesFromBarOrLineChartConfiguration Bar Chart
|
||||
"stage": true,
|
||||
},
|
||||
],
|
||||
"orderBy": [
|
||||
{
|
||||
"stage": "AscNullsLast",
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -67,6 +100,14 @@ exports[`generateGroupByQueryVariablesFromBarOrLineChartConfiguration Bar Chart
|
||||
"ownerId": true,
|
||||
},
|
||||
],
|
||||
"orderBy": [
|
||||
{
|
||||
"stage": "AscNullsLast",
|
||||
},
|
||||
{
|
||||
"ownerId": "AscNullsLast",
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -79,6 +120,13 @@ exports[`generateGroupByQueryVariablesFromBarOrLineChartConfiguration Line Chart
|
||||
},
|
||||
},
|
||||
],
|
||||
"orderBy": [
|
||||
{
|
||||
"name": {
|
||||
"firstName": "AscNullsLast",
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -91,6 +139,14 @@ exports[`generateGroupByQueryVariablesFromBarOrLineChartConfiguration Line Chart
|
||||
},
|
||||
},
|
||||
],
|
||||
"orderBy": [
|
||||
{
|
||||
"createdAt": {
|
||||
"granularity": "MONTH",
|
||||
"orderBy": "AscNullsLast",
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -104,6 +160,14 @@ exports[`generateGroupByQueryVariablesFromBarOrLineChartConfiguration Line Chart
|
||||
"ownerId": true,
|
||||
},
|
||||
],
|
||||
"orderBy": [
|
||||
{
|
||||
"stage": "AscNullsLast",
|
||||
},
|
||||
{
|
||||
"ownerId": "AscNullsLast",
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -114,6 +178,11 @@ exports[`generateGroupByQueryVariablesFromBarOrLineChartConfiguration Line Chart
|
||||
"stage": true,
|
||||
},
|
||||
],
|
||||
"orderBy": [
|
||||
{
|
||||
"stage": "AscNullsLast",
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -127,5 +196,13 @@ exports[`generateGroupByQueryVariablesFromBarOrLineChartConfiguration Line Chart
|
||||
"ownerId": true,
|
||||
},
|
||||
],
|
||||
"orderBy": [
|
||||
{
|
||||
"stage": "AscNullsLast",
|
||||
},
|
||||
{
|
||||
"ownerId": "AscNullsLast",
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
+19
-20
@@ -1,5 +1,6 @@
|
||||
import { type ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
import { GRAPH_DEFAULT_DATE_GRANULARITY } from '@/page-layout/widgets/graph/constants/GraphDefaultDateGranularity.constant';
|
||||
import { GRAPH_DEFAULT_ORDER_BY } from '@/page-layout/widgets/graph/constants/GraphDefaultOrderBy';
|
||||
import { getGroupByOrderBy } from '@/page-layout/widgets/graph/utils/getGroupByOrderBy';
|
||||
import { isRelationNestedFieldDateKind } from '@/page-layout/widgets/graph/utils/isRelationNestedFieldDateKind';
|
||||
import {
|
||||
@@ -117,24 +118,21 @@ export const generateGroupByQueryVariablesFromBarOrLineChartConfiguration = ({
|
||||
| ObjectRecordOrderByForRelationField
|
||||
> = [];
|
||||
|
||||
if (isDefined(chartConfiguration.primaryAxisOrderBy)) {
|
||||
orderBy.push(
|
||||
getGroupByOrderBy({
|
||||
graphOrderBy: chartConfiguration.primaryAxisOrderBy,
|
||||
groupByField: groupByFieldX,
|
||||
groupBySubFieldName: chartConfiguration.primaryAxisGroupBySubFieldName,
|
||||
aggregateOperation,
|
||||
dateGranularity: shouldApplyDateGranularityX
|
||||
? (chartConfiguration.primaryAxisDateGranularity ??
|
||||
GRAPH_DEFAULT_DATE_GRANULARITY)
|
||||
: undefined,
|
||||
}),
|
||||
);
|
||||
}
|
||||
if (
|
||||
isDefined(groupByFieldY) &&
|
||||
isDefined(chartConfiguration.secondaryAxisOrderBy)
|
||||
) {
|
||||
orderBy.push(
|
||||
getGroupByOrderBy({
|
||||
graphOrderBy:
|
||||
chartConfiguration.primaryAxisOrderBy ?? GRAPH_DEFAULT_ORDER_BY,
|
||||
groupByField: groupByFieldX,
|
||||
groupBySubFieldName: chartConfiguration.primaryAxisGroupBySubFieldName,
|
||||
aggregateOperation,
|
||||
dateGranularity: shouldApplyDateGranularityX
|
||||
? (chartConfiguration.primaryAxisDateGranularity ??
|
||||
GRAPH_DEFAULT_DATE_GRANULARITY)
|
||||
: undefined,
|
||||
}),
|
||||
);
|
||||
|
||||
if (isDefined(groupByFieldY)) {
|
||||
const isFieldYDateForOrderBy = isFieldMetadataDateKind(groupByFieldY.type);
|
||||
|
||||
const isFieldYNestedDateForOrderBy = isRelationNestedFieldDateKind({
|
||||
@@ -148,7 +146,8 @@ export const generateGroupByQueryVariablesFromBarOrLineChartConfiguration = ({
|
||||
|
||||
orderBy.push(
|
||||
getGroupByOrderBy({
|
||||
graphOrderBy: chartConfiguration.secondaryAxisOrderBy,
|
||||
graphOrderBy:
|
||||
chartConfiguration.secondaryAxisOrderBy ?? GRAPH_DEFAULT_ORDER_BY,
|
||||
groupByField: groupByFieldY,
|
||||
groupBySubFieldName:
|
||||
chartConfiguration.secondaryAxisGroupBySubFieldName,
|
||||
@@ -163,7 +162,7 @@ export const generateGroupByQueryVariablesFromBarOrLineChartConfiguration = ({
|
||||
|
||||
return {
|
||||
groupBy,
|
||||
...(orderBy.length > 0 && { orderBy }),
|
||||
orderBy,
|
||||
...(isDefined(limit) && { limit }),
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user