@progress/kendo-angular-grid
Version:
Kendo UI Grid for Angular - high performance data grid with paging, filtering, virtualization, CRUD, and more.
66 lines (65 loc) • 3.46 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 { 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 `save` command in the Grid. Apply this directive to any `kendo-toolbar-button`
* element inside a ToolbarComponent used in the Grid.
*
* When you click the toolbar button with this directive, the
* [`save`]({% slug api_grid_gridcomponent %}#toc-save) event fires.
*
* @example
* ```html
* <kendo-grid>
* <kendo-toolbar>
* <kendo-toolbar-button text="Save" kendoGridSaveTool></kendo-toolbar-button>
* </kendo-toolbar>
* </kendo-grid>
* ```
* @remarks
* Applied to: {@link ToolBarButtonComponent}.
*/
export class SaveCommandToolbarDirective extends ToolbarEditingToolBase {
editService;
constructor(editService, host, selection, ctx, zone, cdr) {
super(host, ToolbarToolName.save, ctx, zone, cdr, editService, selection);
this.editService = editService;
}
/**
* @hidden
*/
onClick(e) {
e.preventDefault();
if (this.editService.hasNewItem) {
this.editService.save();
}
else if (this.isSelectionPresent && this.editService.isEdited(this.lastSelectionIndex)) {
this.editService.save(this.lastSelectionIndex);
}
else {
this.editService.editedIndices.forEach(i => this.editService.save(i.index));
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SaveCommandToolbarDirective, 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: SaveCommandToolbarDirective, isStandalone: true, selector: "[kendoGridSaveTool]", usesInheritance: true, ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SaveCommandToolbarDirective, decorators: [{
type: Directive,
args: [{
selector: '[kendoGridSaveTool]',
standalone: true
}]
}], ctorParameters: function () { return [{ type: i1.EditService }, { type: i2.ToolBarButtonComponent }, { type: i3.SelectionService }, { type: i4.ContextService }, { type: i0.NgZone }, { type: i0.ChangeDetectorRef }]; } });