UNPKG

@progress/kendo-angular-gantt

Version:
58 lines (57 loc) 2.82 kB
/**----------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the project root for more information *-------------------------------------------------------------------------------------------*/ import { Injectable } from "@angular/core"; import { IntlService } from "@progress/kendo-angular-intl"; import { addMonths, firstDayOfMonth, getDate, lastDayOfMonth } from "@progress/kendo-date-math"; import { MappingService } from "../common/mapping.service"; import { TimelineBaseViewService } from "./timeline-base-view.service"; import * as i0 from "@angular/core"; import * as i1 from "@progress/kendo-angular-intl"; import * as i2 from "../common/mapping.service"; /** * @hidden */ export class TimeLineYearViewService extends TimelineBaseViewService { constructor(intlService, mapper) { super(intlService, mapper); } getTableWidth(tasks) { const timeSlots = this.getSlots(tasks)[1]; const slotWidth = this.options.slotWidth; return Math.round(timeSlots.length * slotWidth); } getStartOffset(rangeStart) { const monthStart = firstDayOfMonth(rangeStart); return addMonths(getDate(monthStart), -1); } /** * */ getEndOffset(rangeEnd) { const monthEnd = lastDayOfMonth(rangeEnd); return addMonths(getDate(monthEnd), 1); } /** * * @param tasks - The tasks which are going to be rendered in the table * @returns {Array<Object>} - A collection containing the years and months slots * * Used to render the number of columns and the header */ getSlots(tasks) { // will return the header rows slots const slots = []; const { start, end } = this.getRange(tasks); const years = this.getYears(start, end, this.options.timelineHeadersDateFormat?.groupHeaderDateFormat); const months = this.getMonths(start, end, false, this.options.timelineHeadersDateFormat?.columnHeaderDateFormat); slots.push(years, months); return slots; } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: TimeLineYearViewService, deps: [{ token: i1.IntlService }, { token: i2.MappingService }], target: i0.ɵɵFactoryTarget.Injectable }); static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: TimeLineYearViewService }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: TimeLineYearViewService, decorators: [{ type: Injectable }], ctorParameters: () => [{ type: i1.IntlService }, { type: i2.MappingService }] });