Skip to content

Commit

Permalink
busy cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
sgratzl committed Dec 1, 2018
1 parent ae40661 commit 6d6433c
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 18 deletions.
28 changes: 23 additions & 5 deletions src/provider/ADataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,15 @@ export declare function jumpToNearest(dataIndices: number[]): void;
* @asMemberOf ADataProvider
* @event
*/
export declare function aggregate(ranking: Ranking, group: IGroup|IGroup[], value: boolean, showTopN: number): void;
export declare function aggregate(ranking: Ranking, group: IGroup | IGroup[], value: boolean, showTopN: number): void;


/**
* @asMemberOf ADataProvider
* @event
*/
export declare function busy(busy: boolean): void;


/**
* a basic data provider holding the data and rankings
Expand All @@ -94,6 +102,7 @@ abstract class ADataProvider extends AEventDispatcher implements IDataProvider {
static readonly EVENT_CLEAR_DESC = 'clearDesc';
static readonly EVENT_JUMP_TO_NEAREST = 'jumpToNearest';
static readonly EVENT_GROUP_AGGREGATION_CHANGED = AggregateGroupColumn.EVENT_AGGREGATE;
static readonly EVENT_BUSY = 'busy';

/**
* all rankings
Expand Down Expand Up @@ -126,7 +135,7 @@ abstract class ADataProvider extends AEventDispatcher implements IDataProvider {
/**
* lookup map of a column type to its column implementation
*/
readonly columnTypes: { [columnType: string]: typeof Column };
readonly columnTypes: {[columnType: string]: typeof Column};

protected readonly multiSelections: boolean;

Expand All @@ -146,7 +155,7 @@ abstract class ADataProvider extends AEventDispatcher implements IDataProvider {
*/
protected createEventList() {
return super.createEventList().concat([
ADataProvider.EVENT_DATA_CHANGED,
ADataProvider.EVENT_DATA_CHANGED, ADataProvider.EVENT_BUSY,
ADataProvider.EVENT_ADD_COLUMN, ADataProvider.EVENT_REMOVE_COLUMN,
ADataProvider.EVENT_ADD_RANKING, ADataProvider.EVENT_REMOVE_RANKING,
ADataProvider.EVENT_DIRTY, ADataProvider.EVENT_DIRTY_HEADER, ADataProvider.EVENT_DIRTY_VALUES, ADataProvider.EVENT_DIRTY_CACHES,
Expand All @@ -155,6 +164,7 @@ abstract class ADataProvider extends AEventDispatcher implements IDataProvider {
ADataProvider.EVENT_JUMP_TO_NEAREST, ADataProvider.EVENT_GROUP_AGGREGATION_CHANGED]);
}

on(type: typeof ADataProvider.EVENT_BUSY, listener: typeof busy | null): this;
on(type: typeof ADataProvider.EVENT_DATA_CHANGED, listener: typeof dataChanged | null): this;
on(type: typeof ADataProvider.EVENT_ADD_COLUMN, listener: typeof addColumn | null): this;
on(type: typeof ADataProvider.EVENT_REMOVE_COLUMN, listener: typeof removeColumn | null): this;
Expand Down Expand Up @@ -195,7 +205,12 @@ abstract class ADataProvider extends AEventDispatcher implements IDataProvider {
return r;
}

protected fireBusy(busy: boolean) {
this.fire(ADataProvider.EVENT_BUSY, busy);
}

takeSnapshot(col: Column): Ranking {
this.fireBusy(true);
const r = this.cloneRanking();
const ranking = col.findMyRanker();
// by convention copy all support types and the first string column
Expand Down Expand Up @@ -226,6 +241,7 @@ abstract class ADataProvider extends AEventDispatcher implements IDataProvider {
}
});
this.insertRanking(r);
this.fireBusy(false);
return r;
}

Expand All @@ -236,17 +252,19 @@ abstract class ADataProvider extends AEventDispatcher implements IDataProvider {
Ranking.EVENT_ORDER_CHANGED, Ranking.EVENT_DIRTY_VALUES));
const that = this;
//delayed reordering per ranking
r.on(`${Ranking.EVENT_DIRTY_ORDER}.provider`, debounce(function (this: { source: Ranking }) {
r.on(`${Ranking.EVENT_DIRTY_ORDER}.provider`, debounce(function (this: {source: Ranking}) {
that.triggerReorder(this.source);
}, 100));
this.fire([ADataProvider.EVENT_ADD_RANKING, ADataProvider.EVENT_DIRTY_HEADER, ADataProvider.EVENT_DIRTY_VALUES, ADataProvider.EVENT_DIRTY], r, index);
this.triggerReorder(r);
}

protected triggerReorder(ranking: Ranking) {
this.fireBusy(true);
Promise.resolve(this.sort(ranking)).then((order) => {
unifyParents(order);
ranking.setGroups(order);
this.fireBusy(false);
});
}

Expand Down Expand Up @@ -451,7 +469,7 @@ abstract class ADataProvider extends AEventDispatcher implements IDataProvider {
*/
find(idOrFilter: string | ((col: Column) => boolean)): Column | null {
//convert to function
const filter = typeof(idOrFilter) === 'string' ? (col: Column) => col.id === idOrFilter : idOrFilter;
const filter = typeof (idOrFilter) === 'string' ? (col: Column) => col.id === idOrFilter : idOrFilter;

for (const ranking of this.rankings) {
const r = ranking.find(filter);
Expand Down
22 changes: 13 additions & 9 deletions src/styles/_common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
pointer-events: none !important;
}

> * {
>* {
pointer-events: none !important;
}
}
Expand All @@ -29,11 +29,11 @@
}

.#{$lu_css_prefix}-checkbox {
> input {
>input {
display: inline;
}

> label {
>label {
display: inline-flex;
}
}
Expand All @@ -49,27 +49,27 @@
line-height: 0;
display: flex;

input:checked + label {
input:checked+label {
outline: 2px solid black;
}

> input {
>input {
display: none;
}

> label {
>label {
flex: 1 1 0;
}
}

.#{$lu_css_prefix}-color-gradient {
display: flex;

input:checked + label {
input:checked+label {
outline: 2px solid black;
}

> label {
>label {
margin: 0.1em;
flex: 1 1 auto;
}
Expand Down Expand Up @@ -98,7 +98,11 @@
background-size: $lu_missing_dash_width $lu_missing_dash_height;
background-repeat: no-repeat;

> * {
>* {
display: none;
}
}

.#{$lu_css_prefix}-busy {
cursor: wait !important;
}
12 changes: 8 additions & 4 deletions src/ui/EngineRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default class EngineRenderer extends AEventDispatcher {
},
summaryRenderer: (col: Column, interactive: boolean, imposer?: IImposer) => {
const r = chooseSummaryRenderer(col, this.options.renderers);
return r.createSummary!(col, this.ctx, interactive, interactive ? statsOf(col, true): null, imposer);
return r.createSummary!(col, this.ctx, interactive, interactive ? statsOf(col, true) : null, imposer);
},
createRenderer(col: Column, imposer?: IImposer) {
const single = this.renderer(col, imposer);
Expand Down Expand Up @@ -129,7 +129,7 @@ export default class EngineRenderer extends AEventDispatcher {
if (!this.options.flags.advancedRankingFeatures) {
toDisable.push('ranking');
}
if (!this.options.flags.advancedModelFeatures) {
if (!this.options.flags.advancedModelFeatures) {
toDisable.push('model');
}
if (!this.options.flags.advancedUIFeatures) {
Expand All @@ -139,7 +139,7 @@ export default class EngineRenderer extends AEventDispatcher {
this.style.addRule('lineup_feature_disable', `
${toDisable.map((d) => `.${cssClass('feature')}-${d}.${cssClass('feature-advanced')}`).join(', ')}`, {
display: 'none !important'
});
});
}
}

Expand Down Expand Up @@ -197,6 +197,7 @@ export default class EngineRenderer extends AEventDispatcher {
this.data.on(`${ADataProvider.EVENT_REMOVE_RANKING}.body`, null);
this.data.on(`${ADataProvider.EVENT_GROUP_AGGREGATION_CHANGED}.body`, null);
this.data.on(`${ADataProvider.EVENT_JUMP_TO_NEAREST}.body`, null);
this.data.on(`${ADataProvider.EVENT_BUSY}.body`, null);

this.rankings.forEach((r) => this.table.remove(r));
this.rankings.splice(0, this.rankings.length);
Expand All @@ -219,6 +220,9 @@ export default class EngineRenderer extends AEventDispatcher {
this.setHighlightToNearest(indices, true);
});
data.on(`${ADataProvider.EVENT_DATA_CHANGED}.body`, () => this.updateUnfilterdHists());
data.on(`${ADataProvider.EVENT_BUSY}.body`, (busy) => this.node.classList.toggle(cssClass('busy'), busy));

(<any>this.ctx).provider = data;

this.data.getRankings().forEach((r) => this.addRanking(r));
}
Expand Down Expand Up @@ -462,7 +466,7 @@ export default class EngineRenderer extends AEventDispatcher {

enableHighlightListening(enable: boolean) {
for (const ranking of this.rankings) {
ranking.enableHighlightListening(enable);
ranking.enableHighlightListening(enable);
}
this.enabledHighlightListening = enable;
}
Expand Down

0 comments on commit 6d6433c

Please sign in to comment.