Skip to content

Commit

Permalink
work on copies + fix group sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
sgratzl committed Mar 13, 2019
1 parent af4ff2a commit 6cc9993
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/model/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,14 @@ export function unifyParents<T extends IOrderedGroup>(groups: T[]) {
}
// first time seeing this parent
if (!currentParent || currentParent.parent !== node.parent || currentParent.name !== node.name) {
currentParent = node;
currentParent = Object.assign({}, node); // copy
const firstChild = path[level + 1];
// reset parent
if (firstChild) {
node.subGroups = [firstChild];
currentParent.subGroups = [firstChild];
firstChild.parent = currentParent;
} else {
node.subGroups = [];
currentParent.subGroups = [];
}
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/provider/ADataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ abstract class ADataProvider extends AEventDispatcher implements IDataProvider {
this.fireBusy(true);
const reason = dirtyReason || [EDirtyReason.UNKNOWN];
Promise.resolve(this.sort(ranking, reason)).then(({groups, index2pos}) => {
unifyParents(groups);
groups = unifyParents(groups);
this.initAggregateState(ranking, groups);
ranking.setGroups(groups, index2pos, reason);
this.fireBusy(false);
Expand Down
4 changes: 2 additions & 2 deletions src/provider/LocalDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,9 @@ export default class LocalDataProvider extends ACommonDataProvider {
if (groupLookup) {
const groupIndices = groups.map((_, i) => i);
sortComplex(groupIndices, groupLookup.sortOrders);
groups = groupIndices.map((i) => groups[i]);
return groupIndices.map((i) => groups[i]);
}
return groups;
return groups.sort((a, b) => a.name.localeCompare(b.name));
}

private index2pos(groups: IOrderedGroup[], maxDataIndex: number) {
Expand Down

0 comments on commit 6cc9993

Please sign in to comment.