{{context.pager.rowNumber(idx)}}
</div>
<div *ngIf="context.rowFlairIsEnabled" class="eg-grid-cell eg-grid-flair-cell">
- <span class="material-icons">{{context.rowFlairCallback(row)}}</span>
+ <!-- using *ngIf allows us to assign the flair callback to a value,
+ obviating the need for multiple calls of the same function -->
+ <ng-container *ngIf="context.rowFlairCallback(row); let flair">
+ <ng-container *ngIf="flair.icon">
+ <!-- tooltip is disabled when no title is set -->
+ <span class="material-icons"
+ ngbTooltip="{{flair.title || ''}}" triggers="mouseenter:mouseleave">
+ {{flair.icon}}
+ </span>
+ </ng-container>
+ </ng-container>
</div>
<div class="eg-grid-cell eg-grid-body-cell" [ngStyle]="{flex:col.flex}"
(dblclick)="onRowDblClick(row)"
import {OrgService} from '@eg/core/org.service';
import {StoreService} from '@eg/core/store.service';
import {FormatService} from '@eg/share/util/format.service';
-import {GridContext, GridColumn, GridDataSource} from './grid';
+import {GridContext, GridColumn, GridDataSource, GridRowFlairEntry} from './grid';
/**
* Main grid entry point.
// Returns a material icon name to display in the flar column
// (if enabled) for the given row.
- @Input() rowFlairCallback: (row: any) => string;
+ @Input() rowFlairCallback: (row: any) => GridRowFlairEntry;
// Returns a space-separated list of CSS class names to apply to
// a given row
this.context.isMultiSortable = this.multiSortable === true;
this.context.disableMultiSelect = this.disableMultiSelect === true;
this.context.rowFlairIsEnabled = this.rowFlairIsEnabled === true;
+ this.context.rowFlairCallback = this.rowFlairCallback;
// TS doesn't seem to like: let foo = bar || () => '';
- this.context.rowFlairCallback =
- this.rowFlairCallback || function () { return ''; };
this.context.rowClassCallback =
this.rowClassCallback || function () { return ''; };
this.context.cellClassCallback =
}
}
-
+export interface GridRowFlairEntry {
+ icon: string; // name of material icon
+ title: string; // tooltip string
+}
export class GridContext {
lastSelectedIndex: any;
pageChanges: Subscription;
rowFlairIsEnabled: boolean;
- rowFlairCallback: (row: any) => string;
+ rowFlairCallback: (row: any) => GridRowFlairEntry;
rowClassCallback: (row: any) => string;
cellClassCallback: (row: any, col: GridColumn) => string;
import 'rxjs/add/observable/timer';
import {map} from 'rxjs/operators/map';
import {take} from 'rxjs/operators/take';
-import {GridDataSource, GridColumn} from '@eg/share/grid/grid';
+import {GridDataSource, GridColumn, GridRowFlairEntry} from '@eg/share/grid/grid';
import {IdlService, IdlObject} from '@eg/core/idl.service';
import {PcrudService} from '@eg/core/pcrud.service';
import {OrgService} from '@eg/core/org.service';
}
}
- btGridRowFlairCallback(row: any): string {
+ btGridRowFlairCallback(row: any): GridRowFlairEntry {
+ const flair = {icon: null, title: null};
if (row.id() === 2) {
- return 'priority_high';
+ flair.icon = 'priority_high';
+ flair.title = 'I Am ID 2';
} else if (row.id() === 3) {
- return 'not_interested';
+ flair.icon = 'not_interested';
}
+ return flair;
}
// apply to all 'name' columns regardless of row