Skip to content

Commit 6be25c2

Browse files
committed
Merge branch 'rel-10.0' of https://github.com/abpframework/abp into rel-10.0
2 parents 1356d01 + 0c57de7 commit 6be25c2

File tree

5 files changed

+78
-14
lines changed

5 files changed

+78
-14
lines changed

npm/ng-packs/packages/components/extensible/src/lib/components/extensible-form/extensible-form-prop.component.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -170,20 +170,11 @@ export class ExtensibleFormPropComponent implements OnChanges, AfterViewInit {
170170
this.asterisk = this.service.calcAsterisks(this.validators);
171171
}
172172

173-
private focusElement() {
174-
try {
175-
this.fieldRef.nativeElement.focus();
176-
this.shouldFocus.set(false);
177-
} catch (error) {
178-
console.error('Error focusing field:', error);
179-
}
180-
}
181-
182173
ngAfterViewInit() {
183-
this.isViewReady.set(true);
184-
185-
if (this.isFirstGroup && this.first) {
186-
this.shouldFocus.set(true);
174+
if (this.isFirstGroup && this.first && this.fieldRef) {
175+
requestAnimationFrame(() => {
176+
this.fieldRef.nativeElement.focus();
177+
});
187178
}
188179
}
189180

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { formatDate } from '@angular/common';
2+
import { inject, Injectable, LOCALE_ID } from '@angular/core';
3+
import { NgbDatepickerI18n, NgbDateStruct } from '@ng-bootstrap/ng-bootstrap';
4+
import { ConfigStateService } from '@abp/ng.core';
5+
6+
@Injectable()
7+
export class DatepickerI18nAdapter extends NgbDatepickerI18n {
8+
private configState = inject(ConfigStateService, { optional: true });
9+
private defaultLocale = inject(LOCALE_ID);
10+
11+
private get locale(): string {
12+
return this.configState?.getDeep('localization.currentCulture.cultureName') || this.defaultLocale;
13+
}
14+
15+
getWeekdayLabel(weekday: number): string {
16+
const date = new Date(2017, 0, weekday + 1); // Monday = 1
17+
return formatDate(date, 'EEEEE', this.locale);
18+
}
19+
20+
getWeekLabel(): string {
21+
return '';
22+
}
23+
24+
getMonthShortName(month: number): string {
25+
const date = new Date(2017, month - 1, 1);
26+
return formatDate(date, 'MMM', this.locale);
27+
}
28+
29+
getMonthFullName(month: number): string {
30+
const date = new Date(2017, month - 1, 1);
31+
return formatDate(date, 'MMMM', this.locale);
32+
}
33+
34+
getDayAriaLabel(date: NgbDateStruct): string {
35+
const d = new Date(date.year, date.month - 1, date.day);
36+
return formatDate(d, 'fullDate', this.locale);
37+
}
38+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
export * from './date-time.adapter';
22
export * from './date.adapter';
3+
export * from './datepicker-i18n.adapter';
34
export * from './time.adapter';
5+
export * from './timepicker-i18n.adapter';
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { formatDate } from '@angular/common';
2+
import { inject, Injectable, LOCALE_ID } from '@angular/core';
3+
import { NgbTimepickerI18n } from '@ng-bootstrap/ng-bootstrap';
4+
import { ConfigStateService } from '@abp/ng.core';
5+
6+
@Injectable()
7+
export class TimepickerI18nAdapter extends NgbTimepickerI18n {
8+
private configState = inject(ConfigStateService, { optional: true });
9+
private defaultLocale = inject(LOCALE_ID);
10+
11+
private get locale(): string {
12+
return this.configState?.getDeep('localization.currentCulture.cultureName') || this.defaultLocale;
13+
}
14+
15+
getMorningPeriod(): string {
16+
const date = new Date(2000, 0, 1, 10, 0, 0);
17+
return formatDate(date, 'a', this.locale);
18+
}
19+
20+
getAfternoonPeriod(): string {
21+
const date = new Date(2000, 0, 1, 22, 0, 0);
22+
return formatDate(date, 'a', this.locale);
23+
}
24+
}

npm/ng-packs/packages/theme-shared/src/lib/providers/ng-bootstrap-config.provider.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
import { inject, provideAppInitializer } from '@angular/core';
2-
import { NgbInputDatepickerConfig, NgbTypeaheadConfig } from '@ng-bootstrap/ng-bootstrap';
2+
import { NgbDatepickerI18n, NgbInputDatepickerConfig, NgbTypeaheadConfig, NgbTimepickerI18n } from '@ng-bootstrap/ng-bootstrap';
3+
import { DatepickerI18nAdapter, TimepickerI18nAdapter } from '../adapters';
34

45
export const NG_BOOTSTRAP_CONFIG_PROVIDERS = [
6+
{
7+
provide: NgbDatepickerI18n,
8+
useClass: DatepickerI18nAdapter,
9+
},
10+
{
11+
provide: NgbTimepickerI18n,
12+
useClass: TimepickerI18nAdapter,
13+
},
514
provideAppInitializer(() => {
615
configureNgBootstrap();
716
}),

0 commit comments

Comments
 (0)