Skip to content

Commit

Permalink
Merge branch 'lineup-v4' into sgratzl/dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkh committed Mar 26, 2020
2 parents 2a14508 + b522990 commit 70b641c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
22 changes: 20 additions & 2 deletions src/model/StringColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Column, {widthChanged, labelChanged, metaDataChanged, dirty, dirtyHeader,
import {defaultGroup, IDataRow, IGroup, ECompareValueType, IValueColumnDesc, othersGroup, ITypeFactory} from './interfaces';
import {missingGroup, isMissingValue} from './missing';
import ValueColumn, {dataLoaded} from './ValueColumn';
import {equal, IEventListener} from '../internal';
import {equal, IEventListener, ISequence, isSeqEmpty} from '../internal';
import {integrateDefaults} from './internal';

export enum EAlignment {
Expand Down Expand Up @@ -62,7 +62,7 @@ export declare function groupingChanged_SC(previous: (RegExp | string)[][], curr
/**
* a string column with optional alignment
*/
@toolbar('search', 'groupBy', 'filterString')
@toolbar('search', 'groupBy', 'sortGroupBy', 'filterString')
@dialogAddons('group', 'groupString')
@Category('string')
export default class StringColumn extends ValueColumn<string> {
Expand Down Expand Up @@ -289,5 +289,23 @@ export default class StringColumn extends ValueColumn<string> {
toCompareValueType() {
return ECompareValueType.STRING;
}

toCompareGroupValue(rows: ISequence<IDataRow>, _group: IGroup, valueCache?: ISequence<any>) {
if (isSeqEmpty(rows)) {
return null;
}
// take the smallest one
if (valueCache) {
return valueCache.reduce((acc, v) => acc == null || v < acc ? v : acc, <null |string>null);
}
return rows.reduce((acc, d) => {
const v = this.getValue(d);
return acc == null || (v != null && v < acc) ? v : acc;
}, <null | string>null);
}

toCompareGroupValueType() {
return ECompareValueType.STRING;
}
}

4 changes: 2 additions & 2 deletions src/ui/toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ const rename: IToolbarAction = {
dialog.open();
},
options: {
order: 4,
order: 5,
featureCategory: 'ui',
featureLevel: 'advanced'
}
Expand Down Expand Up @@ -276,7 +276,7 @@ export const toolbarActions: {[key: string]: IToolbarAction | IToolbarDialogAddo
remove,
rename,
setShowTopN,
search: uiDialog('Search &hellip;', SearchDialog, (ctx) => [ctx.provider], {shortcut: true, order: 3, featureCategory: 'ranking', featureLevel: 'basic'}),
search: uiDialog('Search &hellip;', SearchDialog, (ctx) => [ctx.provider], {shortcut: true, order: 4, featureCategory: 'ranking', featureLevel: 'basic'}),
filterNumber: uiDialog('Filter &hellip;', NumberFilterDialog, (ctx) => [ctx], {shortcut: true, featureCategory: 'ranking', featureLevel: 'basic'}),
filterDate: uiDialog('Filter &hellip;', DateFilterDialog, (ctx) => [ctx], {shortcut: true, featureCategory: 'ranking', featureLevel: 'basic'}),
filterString: uiDialog('Filter &hellip;', StringFilterDialog, () => [], {shortcut: true, featureCategory: 'ranking', featureLevel: 'basic'}),
Expand Down

0 comments on commit 70b641c

Please sign in to comment.