diff --git a/dist/components/dialogs.d.ts b/dist/components/dialogs.d.ts index 706b80bde..e0e8c9b63 100644 --- a/dist/components/dialogs.d.ts +++ b/dist/components/dialogs.d.ts @@ -1,5 +1,6 @@ /// /// +/// /// import '../webpack/_bootstrap'; export interface IDialogOptions { diff --git a/dist/lineup/selection/internal/ABaseSelectionAdapter.d.ts b/dist/lineup/selection/internal/ABaseSelectionAdapter.d.ts index b38805b2a..e5f264b90 100644 --- a/dist/lineup/selection/internal/ABaseSelectionAdapter.d.ts +++ b/dist/lineup/selection/internal/ABaseSelectionAdapter.d.ts @@ -1,6 +1,10 @@ import { IAdditionalColumnDesc } from '../../../base/interfaces'; import { ISelectionColumn, IContext } from '../ISelectionAdapter'; +import { IMultiSelectionAdapter } from './MultiSelectionAdapter'; +import { ISingleSelectionAdapter } from './SingleSelectionAdapter'; export declare abstract class ABaseSelectionAdapter { + protected readonly adapter: ISingleSelectionAdapter | IMultiSelectionAdapter; + constructor(adapter: ISingleSelectionAdapter | IMultiSelectionAdapter); protected addDynamicColumns(context: IContext, _ids: number[], ids: string[]): Promise; protected removeDynamicColumns(context: IContext, _ids: number[]): void; private waitingForSelection; diff --git a/dist/lineup/selection/internal/ABaseSelectionAdapter.js b/dist/lineup/selection/internal/ABaseSelectionAdapter.js index 92ece2842..d20f34f77 100644 --- a/dist/lineup/selection/internal/ABaseSelectionAdapter.js +++ b/dist/lineup/selection/internal/ABaseSelectionAdapter.js @@ -1,7 +1,8 @@ import { ResolveNow } from '../../../base'; import { LineupUtils } from '../../utils'; export class ABaseSelectionAdapter { - constructor() { + constructor(adapter) { + this.adapter = adapter; this.waitingForSelection = null; this.waitingForParameter = null; } @@ -51,6 +52,10 @@ export class ABaseSelectionAdapter { } selectionChangedImpl(context) { const selectedIds = context.selection.range.dim(0).asList(); + if (this.adapter.selectionLimit) { + // override the original array length so that only the first items are considered further on + selectedIds.length = this.adapter.selectionLimit; + } const usedCols = context.columns.filter((d) => d.desc.selectedId !== -1 && d.desc.selectedId !== undefined); const lineupColIds = usedCols.map((d) => d.desc.selectedId); // compute the difference @@ -65,7 +70,7 @@ export class ABaseSelectionAdapter { if (diffAdded.length <= 0) { return null; } - //console.log('add columns', diffAdded); + // console.log('add columns', diffAdded); return context.selection.idtype.unmap(diffAdded).then((names) => this.addDynamicColumns(context, diffAdded, names)); } static patchDesc(desc, selectedId) { diff --git a/dist/lineup/selection/internal/ABaseSelectionAdapter.js.map b/dist/lineup/selection/internal/ABaseSelectionAdapter.js.map index 1ec944f83..a24187bbe 100644 --- a/dist/lineup/selection/internal/ABaseSelectionAdapter.js.map +++ b/dist/lineup/selection/internal/ABaseSelectionAdapter.js.map @@ -1 +1 @@ -{"version":3,"file":"ABaseSelectionAdapter.js","sourceRoot":"","sources":["../../../../src/lineup/selection/internal/ABaseSelectionAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAC,WAAW,EAAC,MAAM,aAAa,CAAC;AAGxC,MAAM,OAAgB,qBAAqB;IAA3C;QAwBU,wBAAmB,GAA0B,IAAI,CAAC;QAClD,wBAAmB,GAA0B,IAAI,CAAC;IA0D5D,CAAC;IAjFW,iBAAiB,CAAC,OAAiB,EAAE,IAAc,EAAE,GAAa;QAC1E,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;YACrG,uDAAuD;YACvD,MAAM,gBAAgB,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAC,CAAC,EAAE,CAAC,EAAC,CAAC,CAAC,CAAC;YACvE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U,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;QACpE,MAAM,WAAW,GAAG,WAAW,CAAC,UAAU,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;QAEtE,4BAA4B;QAC5B,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE;YAC1B,6CAA6C;YAC7C,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;SACjD;QACD,6BAA6B;QAC7B,IAAI,SAAS,CAAC,MAAM,IAAI,CAAC,EAAE;YACzB,OAAO,IAAI,CAAC;SACb;QACD,wCAAwC;QACxC,OAAO,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;IACtH,CAAC;IAID,MAAM,CAAC,SAAS,CAAC,IAA2B,EAAE,UAAkB;QAC9D,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;CACF"} \ No newline at end of file +{"version":3,"file":"ABaseSelectionAdapter.js","sourceRoot":"","sources":["../../../../src/lineup/selection/internal/ABaseSelectionAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAC,WAAW,EAAC,MAAM,aAAa,CAAC;AAKxC,MAAM,OAAgB,qBAAqB;IACzC,YAA+B,OAAyD;QAAzD,YAAO,GAAP,OAAO,CAAkD;QA0BhF,wBAAmB,GAA0B,IAAI,CAAC;QAClD,wBAAmB,GAA0B,IAAI,CAAC;IA1B1D,CAAC;IAGS,iBAAiB,CAAC,OAAiB,EAAE,IAAc,EAAE,GAAa;QAC1E,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,E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ultiSelectionAdapter.d.ts b/dist/lineup/selection/internal/MultiSelectionAdapter.d.ts index c40fdd722..51f3dc8ed 100644 --- a/dist/lineup/selection/internal/MultiSelectionAdapter.d.ts +++ b/dist/lineup/selection/internal/MultiSelectionAdapter.d.ts @@ -24,9 +24,14 @@ export interface IMultiSelectionAdapter { * @returns {Promise[][]>} data */ loadData(_id: number, id: string, descs: IAdditionalColumnDesc[]): Promise[]>[]; + /** + * Limit the columns incoming selections considered when adding + * a column in the dependent ranking + */ + selectionLimit?: number; } export declare class MultiSelectionAdapter extends ABaseSelectionAdapter implements ISelectionAdapter { - private readonly adapter; + protected readonly adapter: IMultiSelectionAdapter; constructor(adapter: IMultiSelectionAdapter); protected parameterChangedImpl(context: IContext): Promise; protected createColumnsFor(context: IContext, _id: number, id: string): PromiseLike<{ diff --git a/dist/lineup/selection/internal/MultiSelectionAdapter.js b/dist/lineup/selection/internal/MultiSelectionAdapter.js index b31ccde2e..9aeef2450 100644 --- a/dist/lineup/selection/internal/MultiSelectionAdapter.js +++ b/dist/lineup/selection/internal/MultiSelectionAdapter.js @@ -3,11 +3,15 @@ import { ABaseSelectionAdapter } from './ABaseSelectionAdapter'; import { ResolveNow } from '../../../base'; export class MultiSelectionAdapter extends ABaseSelectionAdapter { constructor(adapter) { - super(); + super(adapter); this.adapter = adapter; } parameterChangedImpl(context) { const selectedIds = context.selection.range.dim(0).asList(); + if (this.adapter.selectionLimit) { + // override the original array length so that only the first items are considered further on + selectedIds.length = this.adapter.selectionLimit; + } this.removePartialDynamicColumns(context, selectedIds); return context.selection.idtype.unmap(selectedIds).then((names) => this.addDynamicColumns(context, selectedIds, names)); } diff --git a/dist/lineup/selection/internal/MultiSelectionAdapter.js.map b/dist/lineup/selection/internal/MultiSelectionAdapter.js.map index bf3b37bd6..932f19487 100644 --- a/dist/lineup/selection/internal/MultiSelectionAdapter.js.map +++ b/dist/lineup/selection/internal/MultiSelectionAdapter.js.map @@ -1 +1 @@ -{"version":3,"file":"MultiSelection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CAAC,OAAiB,EAAE,EAAU;QAC3D,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAyB,GAAG,CAAC,IAAK,CAAC,UAAU,CAAC,CAAC;QAEvF,0DAA0D;QAC1D,MAAM,SAAS,GAAG,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QACtC,OAAO,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC;IACnE,CAAC;CACF"} \ No newline at end of file +{"version":3,"file":"MultiSelectionAdapter.js","sourceRoot":"","sources":["../../../../src/lineup/selection/internal/MultiSelectionAdapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,WAAW,EAAC,MAAM,aAAa,CAAC;AAExC,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAkCzC,MAAM,OAAO,qBAAsB,SAAQ,qBAAqB;IAC9D,YAA+B,OAA+B;QAC5D,KAAK,CAAC,OAAO,CAAC,CAAC;QADc,YAAO,GAAP,OAAO,CAAwB;IAE9D,CAAC;IAES,oBAAoB,CAAC,OAAiB;QAC9C,MAAM,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAE5D,IAAI,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE;YAC/B,4FAA4F;YAC5F,WAAW,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC;SAClD;QAED,IAAI,CAAC,2BAA2B,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QACvD,OAAO,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,E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BAAqB,GAAG,IAAI,GAAG,CAAS,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAyB,GAAG,CAAC,IAAK,CAAC,eAAe,CAAC,CAAC,CAAC;QAExH,2CAA2C;QAC3C,MAAM,iBAAiB,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,qBAAqB,EAAE,gBAAgB,CAAC,CAAC,CAAC;QAEpG,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YAC1D,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAyB,CAAC,CAAC,IAAK,CAAC,eAAe,KAAK,KAAK,CAAC,CAAC;QAC3F,CAAC,CAAC,CAAC,CAAC,CAAC;IACP,CAAC;IAEO,uBAAuB,CAAC,OAAiB,EAAE,EAAU;QAC3D,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAyB,GAAG,CAAC,IAAK,CAAC,UAAU,CAAC,CAAC;QAEvF,0DAA0D;QAC1D,MAAM,SAAS,GAAG,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QACtC,OAAO,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC;IACnE,CAAC;CACF"} \ No newline at end of file diff --git a/dist/lineup/selection/internal/SingleSelectionAdapter.d.ts b/dist/lineup/selection/internal/SingleSelectionAdapter.d.ts index 30e0762ce..88ba1b6db 100644 --- a/dist/lineup/selection/internal/SingleSelectionAdapter.d.ts +++ b/dist/lineup/selection/internal/SingleSelectionAdapter.d.ts @@ -17,9 +17,14 @@ export interface ISingleSelectionAdapter { * @returns {Promise[]>} data */ loadData(_id: number, id: string): Promise[]>; + /** + * Limit incoming selections considered when adding + * a column in the dependent ranking. + */ + selectionLimit?: number; } export declare class SingleSelectionAdapter extends ABaseSelectionAdapter implements ISelectionAdapter { - private readonly adapter; + protected readonly adapter: ISingleSelectionAdapter; constructor(adapter: ISingleSelectionAdapter); protected parameterChangedImpl(context: IContext): Promise; protected createColumnsFor(context: IContext, _id: number, id: string): PromiseLike<{ diff --git a/dist/lineup/selection/internal/SingleSelectionAdapter.js b/dist/lineup/selection/internal/SingleSelectionAdapter.js index db4e2ab7a..c6c2b32bb 100644 --- a/dist/lineup/selection/internal/SingleSelectionAdapter.js +++ b/dist/lineup/selection/internal/SingleSelectionAdapter.js @@ -2,12 +2,16 @@ import { ABaseSelectionAdapter } from './ABaseSelectionAdapter'; import { ResolveNow } from '../../../base'; export class SingleSelectionAdapter extends ABaseSelectionAdapter { constructor(adapter) { - super(); + super(adapter); this.adapter = adapter; } parameterChangedImpl(context) { // remove all and start again const selectedIds = context.selection.range.dim(0).asList(); + if (this.adapter.selectionLimit) { + // override the original array length so that only the first items are considered further on + selectedIds.length = this.adapter.selectionLimit; + } const usedCols = context.columns.filter((d) => d.desc.selectedId !== -1 && d.desc.selectedId !== undefined); const lineupColIds = usedCols.map((d) => d.desc.selectedId); // remove deselected columns diff --git a/dist/lineup/selection/internal/SingleSelectionAdapter.js.map b/dist/lineup/selection/internal/SingleSelectionAdapter.js.map index 8e8636277..9e5602f00 100644 --- a/dist/lineup/selection/internal/SingleSelectionAdapter.js.map +++ b/dist/lineup/selection/internal/SingleSelectionAdapter.js.map @@ -1 +1 @@ -{"version":3,"file":"SingleSelectionAdapter.js","sourceRoot":"","sources":["../../../../src/lineup/selection/internal/SingleSelectionAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AAI9D,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAoBzC,MAAM,OAAO,sBAAuB,SAAQ,qBAAqB;IAC/D,YAA6B,OAAgC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CAAC,IAAI,EAAE,GAAG,CAAC;gBAChD,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC;gBACpC,EAAE,EAAE,GAAG;aACR,CAAC,CAAC,CAAC;IACN,CAAC;CACF"} \ No newline at end of file +{"version":3,"file":"SingleSelectionAdapter.js","sourceRoot":"","sources":["../../../../src/lineup/selection/internal/SingleSelectionAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AAI9D,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AA0BzC,MAAM,OAAO,sBAAuB,SAAQ,qBAAqB;IAC/D,YAA+B,OAAgC;QAC7D,KAAK,CAAC,OAAO,CAAC,CAAC;QADc,YAAO,GAAP,OAAO,CAAyB;IAE/D,CAAC;IAES,oBAAoB,CAAC,OAAiB;QAC9C,6BAA6B;QAC7B,MAAM,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAE5D,IAAI,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE;YAC/B,4FAA4F;YAC5F,WAAW,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC;SAClD;QAED,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAyB,CAAC,CAAC,IAAK,CAAC,UAAU,KAAK,CAAC,CAAC,IAA4B,CAAC,CAAC,IAAK,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC;QAC9J,MAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAyB,CAAC,CAAC,IAAK,CAAC,UAAU,CAAC,CAAC;QAErF,4BAA4B;QAC5B,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;YAC3B,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;SAClD;QACD,6BAA6B;QAC7B,IAAI,WAAW,CAAC,MAAM,IAAI,CAAC,EAAE;YAC3B,OAAO,IAAI,CAAC;SACb;QACD,OAAO,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC;IAC1H,CAAC;IAES,gBAAgB,CAAC,OAAiB,EAAE,GAAW,EAAE,EAAU;QACnE,OAAO,UAAU,CAAC,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gBACrF,IAAI,EAAE,qBAAqB,CAAC,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC;gBAChD,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC;gBACpC,EAAE,EAAE,GAAG;aACR,CAAC,CAAC,CAAC;IACN,CAAC;CACF"} \ No newline at end of file diff --git a/src/lineup/selection/internal/ABaseSelectionAdapter.ts b/src/lineup/selection/internal/ABaseSelectionAdapter.ts index 799c17bc1..3dd9660f4 100644 --- a/src/lineup/selection/internal/ABaseSelectionAdapter.ts +++ b/src/lineup/selection/internal/ABaseSelectionAdapter.ts @@ -1,9 +1,14 @@ import {ResolveNow} from '../../../base'; import {IAdditionalColumnDesc} from '../../../base/interfaces'; import {LineupUtils} from '../../utils'; -import {ISelectionColumn, IContext} from '../ISelectionAdapter'; +import {ISelectionColumn, IContext, ISelectionAdapter} from '../ISelectionAdapter'; +import {IMultiSelectionAdapter} from './MultiSelectionAdapter'; +import {ISingleSelectionAdapter} from './SingleSelectionAdapter'; export abstract class ABaseSelectionAdapter { + constructor(protected readonly adapter: ISingleSelectionAdapter | IMultiSelectionAdapter) { + } + protected addDynamicColumns(context: IContext, _ids: number[], ids: string[]) { return Promise.all(_ids.map((_id, i) => this.createColumnsFor(context, _id, ids[i]))).then((columns) => { @@ -60,6 +65,12 @@ export abstract class ABaseSelectionAdapter { protected selectionChangedImpl(context: IContext) { const selectedIds = context.selection.range.dim(0).asList(); + + if (this.adapter.selectionLimit) { + // override the original array length so that only the first items are considered further on + selectedIds.length = this.adapter.selectionLimit; + } + const usedCols = context.columns.filter((d) => (d.desc).selectedId !== -1 && (d.desc).selectedId !== undefined); const lineupColIds = usedCols.map((d) => (d.desc).selectedId); @@ -76,7 +87,7 @@ export abstract class ABaseSelectionAdapter { if (diffAdded.length <= 0) { return null; } - //console.log('add columns', diffAdded); + // console.log('add columns', diffAdded); return context.selection.idtype.unmap(diffAdded).then((names) => this.addDynamicColumns(context, diffAdded, names)); } diff --git a/src/lineup/selection/internal/MultiSelectionAdapter.ts b/src/lineup/selection/internal/MultiSelectionAdapter.ts index b1329d147..e127e03f2 100644 --- a/src/lineup/selection/internal/MultiSelectionAdapter.ts +++ b/src/lineup/selection/internal/MultiSelectionAdapter.ts @@ -29,15 +29,27 @@ export interface IMultiSelectionAdapter { * @returns {Promise[][]>} data */ loadData(_id: number, id: string, descs: IAdditionalColumnDesc[]): Promise[]>[]; + + /** + * Limit the columns incoming selections considered when adding + * a column in the dependent ranking + */ + selectionLimit?: number; } export class MultiSelectionAdapter extends ABaseSelectionAdapter implements ISelectionAdapter { - constructor(private readonly adapter: IMultiSelectionAdapter) { - super(); + constructor(protected readonly adapter: IMultiSelectionAdapter) { + super(adapter); } protected parameterChangedImpl(context: IContext) { const selectedIds = context.selection.range.dim(0).asList(); + + if (this.adapter.selectionLimit) { + // override the original array length so that only the first items are considered further on + selectedIds.length = this.adapter.selectionLimit; + } + this.removePartialDynamicColumns(context, selectedIds); return context.selection.idtype.unmap(selectedIds).then((names) => this.addDynamicColumns(context, selectedIds, names)); } diff --git a/src/lineup/selection/internal/SingleSelectionAdapter.ts b/src/lineup/selection/internal/SingleSelectionAdapter.ts index 857d77ec0..4005f672b 100644 --- a/src/lineup/selection/internal/SingleSelectionAdapter.ts +++ b/src/lineup/selection/internal/SingleSelectionAdapter.ts @@ -20,16 +20,28 @@ export interface ISingleSelectionAdapter { * @returns {Promise[]>} data */ loadData(_id: number, id: string): Promise[]>; + + /** + * Limit incoming selections considered when adding + * a column in the dependent ranking. + */ + selectionLimit?: number; } export class SingleSelectionAdapter extends ABaseSelectionAdapter implements ISelectionAdapter { - constructor(private readonly adapter: ISingleSelectionAdapter) { - super(); + constructor(protected readonly adapter: ISingleSelectionAdapter) { + super(adapter); } protected parameterChangedImpl(context: IContext) { // remove all and start again const selectedIds = context.selection.range.dim(0).asList(); + + if (this.adapter.selectionLimit) { + // override the original array length so that only the first items are considered further on + selectedIds.length = this.adapter.selectionLimit; + } + const usedCols = context.columns.filter((d) => (d.desc).selectedId !== -1 && (d.desc).selectedId !== undefined); const lineupColIds = usedCols.map((d) => (d.desc).selectedId);