@progress/kendo-angular-grid
Version:
Kendo UI Grid for Angular - high performance data grid with paging, filtering, virtualization, CRUD, and more.
75 lines (74 loc) • 3.04 kB
JavaScript
/**-----------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the project root for more information
*-------------------------------------------------------------------------------------------*/
import { Directive } from '@angular/core';
import { ToolBarButtonComponent } from '@progress/kendo-angular-toolbar';
import { Subscription } from 'rxjs';
import { undoIcon } from '@progress/kendo-svg-icons';
import { UndoRedoService } from './undo-redo.service';
import * as i0 from "@angular/core";
import * as i1 from "./undo-redo.service";
import * as i2 from "@progress/kendo-angular-toolbar";
/**
* Represents the command that triggers the undo action in the Grid.
* Apply this directive to any `kendo-toolbar-button` inside a ToolbarComponent in the Grid.
*
* When users click the toolbar button with this directive, the
* [`undo`]({% slug api_grid_undoredodirective %}#toc-undo) event is triggered.
*
* @example
* ```html
* <kendo-grid>
* <kendo-toolbar>
* <kendo-toolbar-button kendoGridUndoTool></kendo-toolbar-button>
* </kendo-toolbar>
* </kendo-grid>
* ```
*/
export class UndoCommandToolbarDirective {
undoRedoService;
host;
subs = new Subscription();
/**
* @hidden
*/
constructor(undoRedoService, host) {
this.undoRedoService = undoRedoService;
this.host = host;
}
/**
* @hidden
*/
ngOnInit() {
this.subs = this.host.click.subscribe((e) => this.onClick(e));
this.host.className = 'k-grid-undo-command';
this.host.svgIcon = undoIcon;
this.host.icon = 'undo';
this.host.text = 'Undo';
this.host.disabled = true;
this.subs.add(this.undoRedoService.stackEndReached.subscribe((stackEnd) => (this.host.disabled = stackEnd === 'start')));
}
/**
* @hidden
*/
ngOnDestroy() {
this.subs.unsubscribe();
}
/**
* @hidden
*/
onClick(e) {
e.preventDefault();
this.undoRedoService.onUndo.next(undefined);
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: UndoCommandToolbarDirective, deps: [{ token: i1.UndoRedoService }, { token: i2.ToolBarButtonComponent }], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.14", type: UndoCommandToolbarDirective, isStandalone: true, selector: "[kendoGridUndoTool]", ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: UndoCommandToolbarDirective, decorators: [{
type: Directive,
args: [{
selector: '[kendoGridUndoTool]',
standalone: true,
}]
}], ctorParameters: () => [{ type: i1.UndoRedoService }, { type: i2.ToolBarButtonComponent }] });