UNPKG

@progress/kendo-angular-grid

Version:

Kendo UI Grid for Angular - high performance data grid with paging, filtering, virtualization, CRUD, and more.

65 lines (64 loc) 3.49 kB
/**----------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the project root for more information *-------------------------------------------------------------------------------------------*/ import { ChangeDetectorRef, Directive, NgZone } from '@angular/core'; import { EditService } from './edit.service'; import { ToolBarButtonComponent } from '@progress/kendo-angular-toolbar'; import { SelectionService } from '../selection/selection.service'; import { ContextService } from '../common/provider.service'; import { ToolbarEditingToolBase } from './toolbar-editing-tool-base.directive'; import { ToolbarToolName } from '../navigation/toolbar-tool-name'; import * as i0 from "@angular/core"; import * as i1 from "./edit.service"; import * as i2 from "@progress/kendo-angular-toolbar"; import * as i3 from "../selection/selection.service"; import * as i4 from "../common/provider.service"; /** * Represents the `cancel` command in the Grid. * Apply this directive to any `kendo-toolbar-button` element inside a ToolbarComponent in the Grid. * * When you click the toolbar button with this directive, the [`cancel`]({% slug api_grid_gridcomponent %}#toc-cancel) event triggers. * * @example * ```html * <kendo-grid> * <kendo-toolbar> * <kendo-toolbar-button text="Cancel" kendoGridCancelTool></kendo-toolbar-button> * </kendo-toolbar> * </kendo-grid> * ``` * @remarks * Applied to: {@link ToolBarButtonComponent}. */ export class CancelCommandToolbarDirective extends ToolbarEditingToolBase { editService; constructor(editService, host, selection, ctx, zone, cdr) { super(host, ToolbarToolName.cancel, ctx, zone, cdr, editService, selection); this.editService = editService; } /** * @hidden */ onClick(e) { e.preventDefault(); if (this.editService.hasNewItem) { this.editService.endEdit(); } else if (this.isSelectionPresent && this.editService.isEdited(this.lastSelectionIndex)) { this.editService.endEdit(this.lastSelectionIndex); } else { this.editService.editedIndices.forEach(i => this.editService.endEdit(i.index)); } } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: CancelCommandToolbarDirective, deps: [{ token: i1.EditService }, { token: i2.ToolBarButtonComponent }, { token: i3.SelectionService }, { token: i4.ContextService }, { token: i0.NgZone }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: CancelCommandToolbarDirective, isStandalone: true, selector: "[kendoGridCancelTool]", usesInheritance: true, ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: CancelCommandToolbarDirective, decorators: [{ type: Directive, args: [{ selector: '[kendoGridCancelTool]', standalone: true }] }], ctorParameters: function () { return [{ type: i1.EditService }, { type: i2.ToolBarButtonComponent }, { type: i3.SelectionService }, { type: i4.ContextService }, { type: i0.NgZone }, { type: i0.ChangeDetectorRef }]; } });