UNPKG

@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.

113 lines (112 loc) 4.99 kB
/**----------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the project root for more information *-------------------------------------------------------------------------------------------*/ import { Component, ChangeDetectorRef } from '@angular/core'; import { LocalizationService } from "@progress/kendo-angular-l10n"; import { ColumnInfoService } from '../common/column-info.service'; import { ColumnMenuItemBase } from './column-menu-item-base'; import { lockIcon, unlockIcon } from '@progress/kendo-svg-icons'; import { ColumnMenuItemComponent } from './column-menu-item.component'; import * as i0 from "@angular/core"; import * as i1 from "@progress/kendo-angular-l10n"; import * as i2 from "../common/column-info.service"; /** * Represents the column-menu item that lets you lock or unlock columns. * * Render this component inside a [`ColumnMenuTemplate`]({% slug api_treelist_columnmenutemplatedirective %}) directive. * * To register the component as a known column menu item, set the [`ColumnMenuService`]({% slug api_treelist_columnmenuservice %}) * that the template passes to the `service` input of the `kendo-treelist-columnmenu-lock` component. * * @example * ```html * <kendo-treelist ...> * <kendo-treelist-column field="ProductName"> * <ng-template kendoTreeListColumnMenuTemplate> * <kendo-treelist-columnmenu-lock></kendo-treelist-columnmenu-lock> * </ng-template> * </kendo-treelist-column> * </kendo-treelist> * ``` */ export class ColumnMenuLockComponent extends ColumnMenuItemBase { localization; columnInfoService; changeDetector; unlockIcon = unlockIcon; lockIcon = lockIcon; constructor(localization, columnInfoService, changeDetector) { super(); this.localization = localization; this.columnInfoService = columnInfoService; this.changeDetector = changeDetector; } get text() { return this.localization.get(this.locked ? 'unlock' : 'lock'); } get icon() { return this.locked ? 'unlock' : 'lock'; } get svgIcon() { return this.locked ? this.unlockIcon : this.lockIcon; } get disabled() { return !this.locked && this.columnInfoService.unlockedRootCount < 2; } /** * @hidden */ toggleColumn() { this.toggleHierarchy(!this.locked); this.close(); this.changeDetector.markForCheck(); } toggleHierarchy(locked) { let root = this.service.column; while (root.parent) { root = root.parent; } const columns = [root]; const allChanged = []; while (columns.length) { const column = columns.shift(); column.locked = locked; allChanged.push(column); if (column.hasChildren) { columns.push(...column.childrenArray); } } this.columnInfoService.changeLocked(allChanged); } get locked() { return this.service.column.locked; } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ColumnMenuLockComponent, deps: [{ token: i1.LocalizationService }, { token: i2.ColumnInfoService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: ColumnMenuLockComponent, isStandalone: true, selector: "kendo-treelist-columnmenu-lock", usesInheritance: true, ngImport: i0, template: ` <kendo-treelist-columnmenu-item [text]="text" [icon]="icon" [svgIcon]="svgIcon" (itemClick)="toggleColumn()" [disabled]="disabled"> </kendo-treelist-columnmenu-item> `, isInline: true, dependencies: [{ kind: "component", type: ColumnMenuItemComponent, selector: "kendo-treelist-columnmenu-item", inputs: ["icon", "svgIcon", "text", "selected", "disabled", "expanded", "service"], outputs: ["itemClick", "expand", "collapse"] }] }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ColumnMenuLockComponent, decorators: [{ type: Component, args: [{ selector: 'kendo-treelist-columnmenu-lock', template: ` <kendo-treelist-columnmenu-item [text]="text" [icon]="icon" [svgIcon]="svgIcon" (itemClick)="toggleColumn()" [disabled]="disabled"> </kendo-treelist-columnmenu-item> `, standalone: true, imports: [ColumnMenuItemComponent] }] }], ctorParameters: function () { return [{ type: i1.LocalizationService }, { type: i2.ColumnInfoService }, { type: i0.ChangeDetectorRef }]; } });