Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ngOnInit(): void {
const controller = PblNgridPluginController.find(this.extApi.grid);
this.plugin = controller.getPlugin(PLUGIN_KEY); // TODO: THROW IF NO PLUGIN...
this.plugin.addDetailRow(this);
const tradeEvents = controller.getPlugin('targetEvents');
tradeEvents.cellClick
.pipe(UnRx(this))
.subscribe( event => {
if (event.type === 'data' && event.row === this.context.$implicit) {
const { excludeToggleFrom } = this.plugin;
if (!excludeToggleFrom || !excludeToggleFrom.some( c => event.column.id === c )) {
this.toggle();
}
}
});
tradeEvents.rowClick
.pipe(UnRx(this))
shouldRender(context: PblNgridDataHeaderExtensionContext): boolean {
// We dont check for `context.col.reorder` because even if a specific column does not "reorder" we still need to render the cdk-drag
// so the cdk-drop-list will be aware of this item, so if another item does reorder it will be able to move while taking this element into consideration.
// I.E: It doesn't reorder but it's part of the playground.
//
// However, when the plugin does not exists for this table we don't need to render...
const pluginCtrl = PblNgridPluginController.find(context.grid);
return pluginCtrl.hasPlugin(PLUGIN_KEY);
}
}
constructor(private _overlay: Overlay,
private _dir: Directionality,
public readonly grid: PblNgridComponent) {
const controller = PblNgridPluginController.find(grid);
this.injector = controller.injector;
this.vcRef = controller.injector.get(ViewContainerRef);
this._scrollStrategy = () => _overlay.scrollStrategies.reposition();
}
static create(grid: PblNgridComponent, injector: Injector): PblNgridClipboardPlugin {
const pluginCtrl = PblNgridPluginController.find(grid);
return new PblNgridClipboardPlugin(grid, injector, pluginCtrl);
}
export function toggleDetailRow(grid: PblNgridComponent, row: T, forceState?: boolean): boolean | void {
const controller = PblNgridPluginController.find(grid);
if (controller) {
const plugin = controller.getPlugin(PLUGIN_KEY);
if (plugin) {
return plugin.toggleDetailRow(row, forceState);
}
}
}
static create(table: PblNgridComponent, injector: Injector): PblNgridTargetEventsPlugin {
const pluginCtrl = PblNgridPluginController.find(table);
return new PblNgridTargetEventsPlugin(table, injector, pluginCtrl);
}
static create(table: PblNgridComponent, injector: Injector): PblNgridStatePlugin {
const pluginCtrl = PblNgridPluginController.find(table);
return new PblNgridStatePlugin(table, injector, pluginCtrl);
}
@Input('pblNgridColumnDrag') set context(value: Pick, 'col' | 'grid'> & Partial, 'row' | 'value'>>) {
this._context = value;
this.column = value && value.col;
const pluginCtrl = this.pluginCtrl = value && PblNgridPluginController.find(value.grid);
const plugin = pluginCtrl && pluginCtrl.getPlugin(PLUGIN_KEY);
this.cdkDropList = plugin || undefined;
this.disabled = this.column && this.column.reorder ? false : true;
}
@Input('pblNgridRowDrag') set context(value: Pick, 'col' | 'grid'> & Partial, 'row' | 'value'>>) {
this._context = value;
const pluginCtrl = this.pluginCtrl = value && PblNgridPluginController.find(value.grid);
const plugin = pluginCtrl && pluginCtrl.getPlugin(PLUGIN_KEY);
this.cdkDropList = plugin || undefined;
}
static create(table: PblNgridComponent, injector: Injector): PblNgridCellTooltipDirective {
return new PblNgridCellTooltipDirective(table, injector, PblNgridPluginController.find(table));
}