@progress/kendo-angular-gantt
Version:
Kendo UI Angular Gantt
69 lines (68 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 { TimelineBaseViewService } from './timeline-base-view.service';
import { MappingService } from '../common/mapping.service';
import { setTime } from '../utils';
import * as i0 from "@angular/core";
import * as i1 from "@progress/kendo-angular-intl";
import * as i2 from "../common/mapping.service";
/**
* @hidden
*/
export class TimelineDayViewService extends TimelineBaseViewService {
constructor(intlService, mapper) {
super(intlService, mapper);
}
/**
* Gets a date an hour before the first task start with minutes, seconds, milliseconds cleared.
*/
getStartOffset(rangeStart) {
return setTime(rangeStart, rangeStart.getHours() - 1);
}
/**
* Gets a date an hour after the last task end with minutes, seconds, milliseconds cleared.
*/
getEndOffset(rangeEnd) {
return setTime(rangeEnd, rangeEnd.getHours() + 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 day and hours 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 daySlots = this.getDays(start, end, this.options.timelineHeadersDateFormat?.groupHeaderDateFormat);
const hourSlots = [];
for (let i = 0; i < daySlots.length; i++) {
const daySlot = daySlots[i];
const hours = this.getHours(daySlot.start, daySlot.end, this.options.timelineHeadersDateFormat?.columnHeaderDateFormat);
daySlot.span = hours.length;
hourSlots.push(...hours);
}
slots.push(daySlots, hourSlots);
return slots;
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: TimelineDayViewService, 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: TimelineDayViewService });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: TimelineDayViewService, decorators: [{
type: Injectable
}], ctorParameters: () => [{ type: i1.IntlService }, { type: i2.MappingService }] });