This commit is contained in:
parent
c965ed3b72
commit
38c5cde800
2 changed files with 34 additions and 2 deletions
|
@ -90,7 +90,8 @@ export const termsOperation: OperationDefinition<TermsIndexPatternColumn, 'field
|
||||||
buildColumn({ layer, field, indexPattern }) {
|
buildColumn({ layer, field, indexPattern }) {
|
||||||
const existingMetricColumn = Object.entries(layer.columns)
|
const existingMetricColumn = Object.entries(layer.columns)
|
||||||
.filter(
|
.filter(
|
||||||
([columnId, column]) => column && !column.isBucketed && !isReferenced(layer, columnId)
|
([columnId, column]) =>
|
||||||
|
column && !isReferenced(layer, columnId) && isSortableByColumn(column)
|
||||||
)
|
)
|
||||||
.map(([id]) => id)[0];
|
.map(([id]) => id)[0];
|
||||||
|
|
||||||
|
|
|
@ -305,7 +305,7 @@ describe('terms', () => {
|
||||||
expect(termsColumn.params.otherBucket).toEqual(false);
|
expect(termsColumn.params.otherBucket).toEqual(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should use existing metric column as order column', () => {
|
it('should use existing sortable metric column as order column', () => {
|
||||||
const termsColumn = termsOperation.buildColumn({
|
const termsColumn = termsOperation.buildColumn({
|
||||||
indexPattern: createMockedIndexPattern(),
|
indexPattern: createMockedIndexPattern(),
|
||||||
layer: {
|
layer: {
|
||||||
|
@ -335,6 +335,37 @@ describe('terms', () => {
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
it('should set alphabetical order type if metric column is of type last value', () => {
|
||||||
|
const termsColumn = termsOperation.buildColumn({
|
||||||
|
indexPattern: createMockedIndexPattern(),
|
||||||
|
layer: {
|
||||||
|
columns: {
|
||||||
|
col1: {
|
||||||
|
label: 'Last value of a',
|
||||||
|
dataType: 'number',
|
||||||
|
isBucketed: false,
|
||||||
|
sourceField: 'a',
|
||||||
|
operationType: 'last_value',
|
||||||
|
params: {
|
||||||
|
sortField: 'datefield',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
columnOrder: [],
|
||||||
|
indexPatternId: '',
|
||||||
|
},
|
||||||
|
field: {
|
||||||
|
aggregatable: true,
|
||||||
|
searchable: true,
|
||||||
|
type: 'boolean',
|
||||||
|
name: 'test',
|
||||||
|
displayName: 'test',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
expect(termsColumn.params).toEqual(
|
||||||
|
expect.objectContaining({ orderBy: { type: 'alphabetical' } })
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it('should use the default size when there is an existing bucket', () => {
|
it('should use the default size when there is an existing bucket', () => {
|
||||||
const termsColumn = termsOperation.buildColumn({
|
const termsColumn = termsOperation.buildColumn({
|
||||||
|
|
Loading…
Reference in a new issue