@progress/kendo-angular-treelist
Version:
Kendo UI TreeList for Angular - Display hierarchical data in an Angular tree grid view that supports sorting, filtering, paging, and much more.
88 lines (87 loc) • 5.28 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 { Component, ElementRef, Renderer2, NgZone, HostBinding, Input } from '@angular/core';
import { NgIf, NgClass } from '@angular/common';
import { LocalizationService } from '@progress/kendo-angular-l10n';
import { IconWrapperComponent } from '@progress/kendo-angular-icons';
import { EditService } from './edit.service';
import { BaseCommandDirective } from './base-command.directive';
import * as i0 from "@angular/core";
import * as i1 from "./edit.service";
import * as i2 from "@progress/kendo-angular-l10n";
/**
* Represents the `cancel` command of the TreeList. Apply this directive to any `button` element inside a [`CommandColumnComponent`]({% slug api_treelist_commandcolumncomponent %}).
*
* When the user clicks a button with this directive, the [`cancel`]({% slug api_treelist_treelistcomponent %}#toc-cancel) event is triggered ([see example](slug:custom_editors_editing_treelist)).
*
* The button with `kendoTreeListCancelCommand` is automatically hidden when the row is not in edit mode. The directive takes the `cellContext` from the cell template as input.
*
* @example
* ```html
* <kendo-treelist ...>
* <kendo-treelist-command-column title="command">
* <ng-template kendoTreeListCellTemplate let-cellContext="cellContext">
* <button [kendoTreeListCancelCommand]="cellContext">Cancel changes</button>
* </ng-template>
* </kendo-treelist-command-column>
* </kendo-treelist>
* ```
*/
export class CancelCommandDirective extends BaseCommandDirective {
/**
* Provides the `cellContext` to the template.
*/
cellContext;
commandClass = true;
readVisible = false;
constructor(editService, element, renderer, localization, ngZone) {
super(editService, element, renderer, localization, ngZone);
}
onClick() {
if (this.cellContext) {
const viewItem = this.cellContext.viewItem;
this.editService.endEdit(viewItem.data, viewItem.isNew);
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: CancelCommandDirective, deps: [{ token: i1.EditService }, { token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i2.LocalizationService }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: CancelCommandDirective, isStandalone: true, selector: "[kendoTreeListCancelCommand]", inputs: { cellContext: ["kendoTreeListCancelCommand", "cellContext"] }, host: { properties: { "class.k-grid-cancel-command": "this.commandClass" } }, usesInheritance: true, ngImport: i0, template: `
<kendo-icon-wrapper
*ngIf="icon || svgIcon"
innerCssClass="k-button-icon"
[name]="icon"
[svgIcon]="svgIcon"></kendo-icon-wrapper>
<span *ngIf="imageUrl" class="k-button-icon k-icon">
<img [src]="imageUrl" class="k-image" role="presentation" />
</span>
<span *ngIf="iconClass" class="k-button-icon" [ngClass]="iconClass"></span>
<span class="k-button-text"><ng-content></ng-content></span>
`, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: IconWrapperComponent, selector: "kendo-icon-wrapper", inputs: ["name", "svgIcon", "innerCssClass", "customFontClass", "size"], exportAs: ["kendoIconWrapper"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: CancelCommandDirective, decorators: [{
type: Component,
args: [{
selector: '[kendoTreeListCancelCommand]',
template: `
<kendo-icon-wrapper
*ngIf="icon || svgIcon"
innerCssClass="k-button-icon"
[name]="icon"
[svgIcon]="svgIcon"></kendo-icon-wrapper>
<span *ngIf="imageUrl" class="k-button-icon k-icon">
<img [src]="imageUrl" class="k-image" role="presentation" />
</span>
<span *ngIf="iconClass" class="k-button-icon" [ngClass]="iconClass"></span>
<span class="k-button-text"><ng-content></ng-content></span>
`,
standalone: true,
imports: [NgIf, IconWrapperComponent, NgClass]
}]
}], ctorParameters: function () { return [{ type: i1.EditService }, { type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i2.LocalizationService }, { type: i0.NgZone }]; }, propDecorators: { cellContext: [{
type: Input,
args: ['kendoTreeListCancelCommand']
}], commandClass: [{
type: HostBinding,
args: ['class.k-grid-cancel-command']
}] } });