UNPKG

@progress/kendo-angular-pivotgrid

Version:
105 lines (104 loc) 5.18 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, Input, Renderer2 } from '@angular/core'; import { ChipMenuItemBase } from './chip-menu-item-base'; import { ConfiguratorService } from '../configurator.service'; import { PIVOT_CONFIGURATOR_ACTION } from '@progress/kendo-pivotgrid-common'; import { PivotLocalizationService } from '../../localization/pivot-localization.service'; import { sortAscSmallIcon, sortDescSmallIcon } from '@progress/kendo-svg-icons'; import { ChipMenuItemComponent } from './chip-menu-item.component'; import * as i0 from "@angular/core"; import * as i1 from "../../localization/pivot-localization.service"; import * as i2 from "../configurator.service"; /** * @hidden * * Represents a chip-menu item for sorting PivotGrid fields. * Allows the user to sort the PivotGrid. */ export class ChipMenuSortComponent extends ChipMenuItemBase { localization; renderer; configuratorService; chip; sortAscSVGIcon = sortAscSmallIcon; sortDescSVGIcon = sortDescSmallIcon; constructor(localization, renderer, configuratorService) { super(); this.localization = localization; this.renderer = renderer; this.configuratorService = configuratorService; } get sortedAsc() { const descriptor = this.descriptor; return descriptor && (!descriptor.dir || descriptor.dir === 'asc'); } get sortedDesc() { const descriptor = this.descriptor; return descriptor && descriptor.dir === 'desc'; } /** * Returns the localized message for a given token */ messageFor(localizationToken) { return this.localization.get(localizationToken); } toggleSort(dir) { const field = this.chip.name.toString(); const descriptor = this.descriptor; const sort = this.configuratorService.state.sort.filter(s => s.field !== field); if (!descriptor || descriptor.dir !== dir) { sort.push({ field, dir }); } this.configuratorService.parseConfiguratorState({ type: PIVOT_CONFIGURATOR_ACTION.setSort, payload: sort }); this.close(); } get descriptor() { return [].concat(this.configuratorService.state.sort || []).find(s => s.field === this.chip.name.toString()); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ChipMenuSortComponent, deps: [{ token: i1.PivotLocalizationService }, { token: i0.Renderer2 }, { token: i2.ConfiguratorService }], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: ChipMenuSortComponent, isStandalone: true, selector: "kendo-pivot-chipmenu-sort", inputs: { chip: "chip" }, usesInheritance: true, ngImport: i0, template: ` <kendo-pivot-chipmenu-item [text]="messageFor('fieldMenuSortAscendingItemLabel')" icon="sort-asc-small" [svgIcon]="sortAscSVGIcon" (itemClick)="toggleSort('asc')" [selected]="sortedAsc"> </kendo-pivot-chipmenu-item> <kendo-pivot-chipmenu-item [text]="messageFor('fieldMenuSortDescendingItemLabel')" icon="sort-desc-small" [svgIcon]="sortDescSVGIcon" (itemClick)="toggleSort('desc')" [selected]="sortedDesc"> </kendo-pivot-chipmenu-item> `, isInline: true, dependencies: [{ kind: "component", type: ChipMenuItemComponent, selector: "kendo-pivot-chipmenu-item", inputs: ["icon", "svgIcon", "text", "selected", "expanded", "disabled"], outputs: ["itemClick", "expand", "collapse"] }] }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ChipMenuSortComponent, decorators: [{ type: Component, args: [{ selector: 'kendo-pivot-chipmenu-sort', template: ` <kendo-pivot-chipmenu-item [text]="messageFor('fieldMenuSortAscendingItemLabel')" icon="sort-asc-small" [svgIcon]="sortAscSVGIcon" (itemClick)="toggleSort('asc')" [selected]="sortedAsc"> </kendo-pivot-chipmenu-item> <kendo-pivot-chipmenu-item [text]="messageFor('fieldMenuSortDescendingItemLabel')" icon="sort-desc-small" [svgIcon]="sortDescSVGIcon" (itemClick)="toggleSort('desc')" [selected]="sortedDesc"> </kendo-pivot-chipmenu-item> `, standalone: true, imports: [ChipMenuItemComponent] }] }], ctorParameters: function () { return [{ type: i1.PivotLocalizationService }, { type: i0.Renderer2 }, { type: i2.ConfiguratorService }]; }, propDecorators: { chip: [{ type: Input }] } });