Skip to content

Commit 1a17bc8

Browse files
fix: move setDefaultOptions to GanttConfigService #TINFR-2397
1 parent 0c4eb09 commit 1a17bc8

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

packages/gantt/src/gantt.config.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { inject, Inject, InjectionToken } from '@angular/core';
2-
import { Locale } from 'date-fns';
2+
import { Locale, setDefaultOptions } from 'date-fns';
33
import { GanttLinkLineType, GanttLinkOptions, GanttLinkType } from './class/link';
44
import { Injectable } from '@angular/core';
55
import { GANTT_I18N_LOCALE_TOKEN, GanttI18nLocaleConfig, GanttI18nLocale } from './i18n/i18n';
@@ -92,6 +92,11 @@ export class GanttConfigService {
9292
if (this.config.dateOptions?.timeZone) {
9393
setDefaultTimeZone(this.config.dateOptions.timeZone);
9494
}
95+
96+
setDefaultOptions({
97+
locale: this.getDateLocale(),
98+
weekStartsOn: this.config?.dateOptions?.weekStartsOn
99+
});
95100
}
96101

97102
setLocale(locale: string) {

packages/gantt/src/gantt.module.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { DragDropModule } from '@angular/cdk/drag-drop';
22
import { CdkVirtualScrollViewport, ScrollingModule } from '@angular/cdk/scrolling';
33
import { CommonModule } from '@angular/common';
4-
import { inject, NgModule } from '@angular/core';
5-
import { setDefaultOptions } from 'date-fns';
4+
import { NgModule } from '@angular/core';
65
import { NgxGanttBarComponent } from './components/bar/bar.component';
76
import { NgxGanttBaselineComponent } from './components/baseline/baseline.component';
87
import { GanttCalendarGridComponent } from './components/calendar/grid/calendar-grid.component';
@@ -17,7 +16,7 @@ import { GanttTableBodyComponent } from './components/table/body/gantt-table-bod
1716
import { GanttTableHeaderComponent } from './components/table/header/gantt-table-header.component';
1817
import { NgxGanttToolbarComponent } from './components/toolbar/toolbar.component';
1918
import { NgxGanttComponent } from './gantt.component';
20-
import { GANTT_GLOBAL_CONFIG, GanttConfigService, GanttGlobalConfig, defaultConfig } from './gantt.config';
19+
import { GANTT_GLOBAL_CONFIG, defaultConfig } from './gantt.config';
2120
import { IsGanttBarItemPipe, IsGanttCustomItemPipe, IsGanttGroupPipe, IsGanttRangeItemPipe } from './gantt.pipe';
2221
import { NgxGanttRootComponent } from './root.component';
2322
import { NgxGanttTableColumnComponent } from './table/gantt-column.component';
@@ -77,12 +76,5 @@ import { i18nLocaleProvides } from './i18n';
7776
]
7877
})
7978
export class NgxGanttModule {
80-
constructor() {
81-
const configService = inject(GanttConfigService);
82-
83-
setDefaultOptions({
84-
locale: configService.getDateLocale(),
85-
weekStartsOn: configService.config?.dateOptions?.weekStartsOn
86-
});
87-
}
79+
constructor() {}
8880
}

0 commit comments

Comments
 (0)