Skip to content

Commit

Permalink
add compare versions
Browse files Browse the repository at this point in the history
  • Loading branch information
sgratzl committed Oct 4, 2018
1 parent 0a8f2a9 commit 8dff51b
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/model/Ranking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ export default class Ranking extends AEventDispatcher implements IColumnParent {
return a.i - b.i; //to have a deterministic order
};

readonly toCompareValue = (row: IDataRow) => {
if (this.sortCriteria.length === 0) {
return row.i;
}
let vs : (number | string | null)[] = [];
vs = vs.concat(...this.sortCriteria.map((d) => d.col.toCompareValue(row)));
vs.push(row.i);
return vs;
};

readonly groupComparator = (a: IGroupData, b: IGroupData) => {
if (this.groupSortCriteria.length === 0) {
return a.name.toLowerCase().localeCompare(b.name.toLowerCase());
Expand All @@ -135,6 +145,16 @@ export default class Ranking extends AEventDispatcher implements IColumnParent {
return a.name.localeCompare(b.name);
};

readonly toGroupCompareValue = (group: IGroupData) => {
if (this.groupSortCriteria.length === 0) {
return group.name.toLowerCase();
}
let vs : (number | string | null)[] = [];
vs = vs.concat(...this.groupSortCriteria.map((d) => d.col.toCompareGroupValue(group)));
vs.push(group.name.toLowerCase());
return vs;
};

readonly grouper = (row: IDataRow): IGroup => {
const g = this.groupColumns;
switch (g.length) {
Expand Down

0 comments on commit 8dff51b

Please sign in to comment.