UNPKG

@progress/kendo-angular-gantt

Version:
128 lines (127 loc) 5.34 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, NgZone } from '@angular/core'; import { LocalizationService } from '@progress/kendo-angular-l10n'; import { EditService } from './edit.service'; import { plusIcon } from '@progress/kendo-svg-icons'; import { DropDownButtonComponent } from '@progress/kendo-angular-buttons'; import { EventsOutsideAngularDirective } from '@progress/kendo-angular-common'; import * as i0 from "@angular/core"; import * as i1 from "@progress/kendo-angular-l10n"; import * as i2 from "./edit.service"; /** * Displays the UI for adding new items to the Gantt. * Use this in a toolbar template to show a custom icon or a list of options. */ export class GanttAddTaskComponent { localizationService; editService; ngZone; /** * Sets the data for the DropDownButton. * Provide the data as an array-like list. */ data; /** * Sets the name of an existing icon in a Kendo UI theme. * @default 'plus' */ icon = 'plus'; /** * Sets an [`SVGIcon`](slug:api_icons_svgicon) to render inside the `GanttAddTaskComponent` using * an [`SVGIconComponent`](slug:api_icons_svgiconcomponent). */ svgIcon = plusIcon; constructor(localizationService, editService, ngZone) { this.localizationService = localizationService; this.editService = editService; this.ngZone = ngZone; !this.data && (this.data = [{ text: this.getText('addChildText'), type: 'addChild' }, { text: this.getText('addAboveText'), type: 'addAbove' }, { text: this.getText('addBelowText'), type: 'addBelow' }]); } /** * @hidden */ getText(message) { return this.localizationService.get(message); } /** * @hidden */ handleOpen(e) { if (!this.editService.getSelectedItem()) { e.preventDefault(); } } /** * @hidden */ handleMouseClick() { if (!this.editService.getSelectedItem()) { this.ngZone.run(() => { this.editService.addEvent.next({ selectedItem: null, actionType: 'addTask' }); }); } } /** * @hidden */ handleItemClick(e) { this.editService.addEvent.next({ actionType: e.type, selectedItem: null }); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: GanttAddTaskComponent, deps: [{ token: i1.LocalizationService }, { token: i2.EditService }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.14", type: GanttAddTaskComponent, isStandalone: true, selector: "kendo-gantt-add-task", inputs: { data: "data", icon: "icon", svgIcon: "svgIcon" }, ngImport: i0, template: ` <kendo-dropdownbutton [data]="data" [icon]="icon" [svgIcon]="svgIcon" [kendoEventsOutsideAngular]="{ click: handleMouseClick }" [scope]="this" (itemClick)="handleItemClick($event)" (open)="handleOpen($event)"> {{ getText('addTaskText') }} </kendo-dropdownbutton> `, isInline: true, dependencies: [{ kind: "component", type: DropDownButtonComponent, selector: "kendo-dropdownbutton", inputs: ["arrowIcon", "icon", "svgIcon", "iconClass", "imageUrl", "textField", "data", "size", "rounded", "fillMode", "themeColor", "buttonAttributes"], outputs: ["itemClick", "focus", "blur"], exportAs: ["kendoDropDownButton"] }, { kind: "directive", type: EventsOutsideAngularDirective, selector: "[kendoEventsOutsideAngular]", inputs: ["kendoEventsOutsideAngular", "scope"] }] }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: GanttAddTaskComponent, decorators: [{ type: Component, args: [{ selector: 'kendo-gantt-add-task', template: ` <kendo-dropdownbutton [data]="data" [icon]="icon" [svgIcon]="svgIcon" [kendoEventsOutsideAngular]="{ click: handleMouseClick }" [scope]="this" (itemClick)="handleItemClick($event)" (open)="handleOpen($event)"> {{ getText('addTaskText') }} </kendo-dropdownbutton> `, standalone: true, imports: [DropDownButtonComponent, EventsOutsideAngularDirective] }] }], ctorParameters: () => [{ type: i1.LocalizationService }, { type: i2.EditService }, { type: i0.NgZone }], propDecorators: { data: [{ type: Input }], icon: [{ type: Input }], svgIcon: [{ type: Input }] } });