@progress/kendo-angular-gantt
Version:
Kendo UI Angular Gantt
67 lines (66 loc) • 3.22 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 { Injectable } from '@angular/core';
import { IntlService } from '@progress/kendo-angular-intl';
import { addDays, addWeeks, firstDayInWeek, getDate } 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 TimelineMonthViewService extends TimelineBaseViewService {
constructor(intlService, mapper) {
super(intlService, mapper);
}
/**
* Gets a week before the first week in which a task starts.
*/
getStartOffset(rangeStart) {
const weekStart = this.intlService.firstDay();
const firstDay = firstDayInWeek(getDate(rangeStart), weekStart);
return addWeeks(getDate(firstDay), -1);
}
/**
* Gets a week after the last week in which a task ends.
*/
getEndOffset(rangeEnd) {
const weekStart = this.intlService.firstDay();
const lastDay = addDays(firstDayInWeek(getDate(rangeEnd), weekStart), 6);
return addWeeks(getDate(lastDay), 1);
}
/**
*
* @param tasks - The tasks which are going to be rendered in the table
* @returns {number}
*/
getTableWidth(tasks) {
const timeSlots = this.getSlots(tasks)[1];
const slotWidth = this.options.slotWidth;
return Math.round(timeSlots.length * slotWidth);
}
/**
*
* @param tasks - The tasks which are going to be rendered in the table
* @returns {Array<Object>} - A collection containing the months and weeks 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 months = this.getMonths(start, end, true, this.options.timelineHeadersDateFormat?.groupHeaderDateFormat);
const weeks = this.getWeeks(start, end, this.options.timelineHeadersDateFormat?.columnHeaderDateFormat);
slots.push(months, weeks);
return slots;
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: TimelineMonthViewService, 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: TimelineMonthViewService });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: TimelineMonthViewService, decorators: [{
type: Injectable
}], ctorParameters: () => [{ type: i1.IntlService }, { type: i2.MappingService }] });