Skip to content

Commit

Permalink
better render reason + fix group sort
Browse files Browse the repository at this point in the history
  • Loading branch information
sgratzl committed Dec 12, 2018
1 parent 2c553e3 commit 0b65594
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/model/BooleanColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export default class BooleanColumn extends ValueColumn<boolean> implements ICate
if (this.currentFilter === filter) {
return;
}
this.fire([BooleanColumn.EVENT_FILTER_CHANGED, Column.EVENT_DIRTY_VALUES, Column.EVENT_DIRTY_CACHES, Column.EVENT_DIRTY], this.currentFilter, this.currentFilter = filter);
this.fire([BooleanColumn.EVENT_FILTER_CHANGED, Column.EVENT_DIRTY_VALUES, Column.EVENT_DIRTY], this.currentFilter, this.currentFilter = filter);
}

toCompareValue(row: IDataRow) {
Expand Down
2 changes: 1 addition & 1 deletion src/model/CategoricalColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export default class CategoricalColumn extends ValueColumn<string> implements IC
if (isEqualCategoricalFilter(this.currentFilter, filter)) {
return;
}
this.fire([CategoricalColumn.EVENT_FILTER_CHANGED, Column.EVENT_DIRTY_VALUES, Column.EVENT_DIRTY_CACHES, Column.EVENT_DIRTY], this.currentFilter, this.currentFilter = filter);
this.fire([CategoricalColumn.EVENT_FILTER_CHANGED, Column.EVENT_DIRTY_VALUES, Column.EVENT_DIRTY], this.currentFilter, this.currentFilter = filter);
}

toCompareValue(row: IDataRow, valueCache?: any) {
Expand Down
2 changes: 1 addition & 1 deletion src/model/DateColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export default class DateColumn extends ValueColumn<Date> implements IDateColumn
this.currentFilter.min = isUnknown(value.min) ? -Infinity : value.min;
this.currentFilter.max = isUnknown(value.max) ? Infinity : value.max;
this.currentFilter.filterMissing = value.filterMissing;
this.fire([DateColumn.EVENT_FILTER_CHANGED, Column.EVENT_DIRTY_VALUES, Column.EVENT_DIRTY_CACHES, Column.EVENT_DIRTY], bak, this.getFilter());
this.fire([DateColumn.EVENT_FILTER_CHANGED, Column.EVENT_DIRTY_VALUES, Column.EVENT_DIRTY], bak, this.getFilter());
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/model/NumberColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ export default class NumberColumn extends ValueColumn<number> implements INumber
if (this.colorMapping.eq(mapping)) {
return;
}
this.fire([NumberColumn.EVENT_COLOR_MAPPING_CHANGED, Column.EVENT_DIRTY_VALUES, Column.EVENT_DIRTY_CACHES, Column.EVENT_DIRTY_HEADER, Column.EVENT_DIRTY], this.colorMapping.clone(), this.colorMapping = mapping);
this.fire([NumberColumn.EVENT_COLOR_MAPPING_CHANGED, Column.EVENT_DIRTY_VALUES, Column.EVENT_DIRTY_HEADER, Column.EVENT_DIRTY], this.colorMapping.clone(), this.colorMapping = mapping);
}

isFiltered() {
Expand All @@ -294,7 +294,7 @@ export default class NumberColumn extends ValueColumn<number> implements INumber
this.currentFilter.min = isUnknown(value.min) ? -Infinity : value.min;
this.currentFilter.max = isUnknown(value.max) ? Infinity : value.max;
this.currentFilter.filterMissing = value.filterMissing;
this.fire([NumberColumn.EVENT_FILTER_CHANGED, Column.EVENT_DIRTY_VALUES, Column.EVENT_DIRTY_CACHES, Column.EVENT_DIRTY], bak, this.getFilter());
this.fire([NumberColumn.EVENT_FILTER_CHANGED, Column.EVENT_DIRTY_VALUES, Column.EVENT_DIRTY], bak, this.getFilter());
}

/**
Expand Down
16 changes: 8 additions & 8 deletions src/model/Ranking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ export interface ISortCriteria {
}

export enum EDirtyReason {
UNKNOWN,
FILTER_CHANGED,
SORT_CRITERIA_CHANGED,
SORT_CRITERIA_DIRTY,
GROUP_CRITERIA_CHANGED,
GROUP_CRITERIA_DIRTY,
GROUP_SORT_CRITERIA_CHANGED,
GROUP_SORT_CRITERIA_DIRTY
UNKNOWN = 'unknown',
FILTER_CHANGED = 'filter',
SORT_CRITERIA_CHANGED = 'sort_changed',
SORT_CRITERIA_DIRTY = 'sort_dirty',
GROUP_CRITERIA_CHANGED = 'group_changed',
GROUP_CRITERIA_DIRTY = 'group_dirty',
GROUP_SORT_CRITERIA_CHANGED = 'group_sort_changed',
GROUP_SORT_CRITERIA_DIRTY = 'group_sort_dirty'
}


Expand Down
2 changes: 1 addition & 1 deletion src/model/StringColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export default class StringColumn extends ValueColumn<string> {
if (this.currentFilter === filter) {
return;
}
this.fire([StringColumn.EVENT_FILTER_CHANGED, Column.EVENT_DIRTY_VALUES, Column.EVENT_DIRTY_CACHES, Column.EVENT_DIRTY], this.currentFilter, this.currentFilter = filter);
this.fire([StringColumn.EVENT_FILTER_CHANGED, Column.EVENT_DIRTY_VALUES, Column.EVENT_DIRTY], this.currentFilter, this.currentFilter = filter);
}

getGroupCriteria() {
Expand Down
5 changes: 3 additions & 2 deletions src/provider/ADataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,9 @@ abstract class ADataProvider extends AEventDispatcher implements IDataProvider {
this.rankings.splice(index, 0, r);
this.forward(r, ...ADataProvider.FORWARD_RANKING_EVENTS);
//delayed reordering per ranking
r.on(`${Ranking.EVENT_DIRTY_ORDER}.provider`, debounce((reason?: EDirtyReason[]) => {
this.triggerReorder(r, reason);
const that = this;
r.on(`${Ranking.EVENT_DIRTY_ORDER}.provider`, debounce(function(this: IEventContext) {
that.triggerReorder(r, toDirtyReason(this));
}, 100, mergeDirtyOrderContext));
this.fire([ADataProvider.EVENT_ADD_RANKING, ADataProvider.EVENT_DIRTY_HEADER, ADataProvider.EVENT_DIRTY_VALUES, ADataProvider.EVENT_DIRTY], r, index);
this.triggerReorder(r);
Expand Down
2 changes: 1 addition & 1 deletion src/provider/LocalDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ export default class LocalDataProvider extends ACommonDataProvider {
const sortTask = this.sortWorker.sort(g.rows, singleGroup, lookups);

// compute sort group value as task
const groupSortTask = groupLookup ? this.tasks.groupCompare(ranking, group, this.view(g.rows)).then((r) => r) : <ICompareValue[]>[];
const groupSortTask = groupLookup ? this.tasks.groupCompare(ranking, group, g.rows).then((r) => r) : <ICompareValue[]>[];

// trigger task for groups to compute for this group

Expand Down
10 changes: 5 additions & 5 deletions src/provider/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export interface IRenderTaskExectutor extends IRenderTasks {
dirtyColumn(col: Column, type: 'data' | 'summary' | 'group'): void;
dirtyRanking(ranking: Ranking, type: 'data' | 'summary' | 'group'): void;

groupCompare(ranking: Ranking, group: IGroup, rows: ISequence<IDataRow>): IRenderTask<ICompareValue[]>;
groupCompare(ranking: Ranking, group: IGroup, rows: IndicesArray): IRenderTask<ICompareValue[]>;

preCompute(ranking: Ranking, groups: {rows: IndicesArray, group: IGroup}[]): void;
preComputeCol(col: Column): void;
Expand Down Expand Up @@ -246,8 +246,8 @@ export class DirectRenderTasks extends ARenderTasks implements IRenderTaskExectu
}
}

groupCompare(ranking: Ranking, group: IGroup, rows: ISequence<IDataRow>) {
return taskNow(ranking.toGroupCompareValue(rows, group));
groupCompare(ranking: Ranking, group: IGroup, rows: IndicesArray) {
return taskNow(ranking.toGroupCompareValue(this.byOrder(rows), group));
}

groupRows<T>(_col: Column, group: IOrderedGroup, _key: string, compute: (rows: ISequence<IDataRow>) => T) {
Expand Down Expand Up @@ -539,8 +539,8 @@ export class ScheduleRenderTasks extends ARenderTasks implements IRenderTaskExec
}
}

groupCompare(ranking: Ranking, group: IGroup, rows: ISequence<IDataRow>) {
return taskLater(this.tasks.push(`r${ranking.id}:${group.name}`, () => ranking.toGroupCompareValue(rows, group)));
groupCompare(ranking: Ranking, group: IGroup, rows: IndicesArray) {
return taskLater(this.tasks.push(`r${ranking.id}:${group.name}`, () => ranking.toGroupCompareValue(this.byOrder(rows), group)));
}

groupRows<T>(col: Column, group: IOrderedGroup, key: string, compute: (rows: ISequence<IDataRow>) => T) {
Expand Down

0 comments on commit 0b65594

Please sign in to comment.