@skysoftware-co/bayan-hr-widgets-ui 2.0.25 → 2.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ng-package.json +9 -0
- package/package.json +3 -15
- package/src/assets/i18n/ar.json +166 -0
- package/src/assets/i18n/en.json +166 -0
- package/src/assets/i18n/fr.json +166 -0
- package/src/lib/my-calendar-widget/my-calendar-widget.component.html +25 -0
- package/src/lib/my-calendar-widget/my-calendar-widget.component.ts +220 -0
- package/src/lib/my-main-details-widget/my-main-details-widget.component.html +157 -0
- package/src/lib/my-main-details-widget/my-main-details-widget.component.ts +179 -0
- package/src/lib/my-next-week-vacation-insights-widget/components/next-week-vacation-insights-popup/next-week-vacation-insights-popup.component.html +131 -0
- package/src/lib/my-next-week-vacation-insights-widget/components/next-week-vacation-insights-popup/next-week-vacation-insights-popup.component.ts +119 -0
- package/src/lib/my-next-week-vacation-insights-widget/my-next-week-vacation-insights-widget.component.html +35 -0
- package/src/lib/my-next-week-vacation-insights-widget/my-next-week-vacation-insights-widget.component.ts +110 -0
- package/src/lib/my-profile/address-widget/my-profile-address-widget.component.html +57 -0
- package/src/lib/my-profile/address-widget/my-profile-address-widget.component.ts +70 -0
- package/src/lib/my-profile/bank-info-widget/my-profile-bank-info-widget.component.html +101 -0
- package/src/lib/my-profile/bank-info-widget/my-profile-bank-info-widget.component.ts +89 -0
- package/src/lib/my-profile/contact-widget/my-profile-contact-widget.component.html +89 -0
- package/src/lib/my-profile/contact-widget/my-profile-contact-widget.component.ts +78 -0
- package/src/lib/my-profile/contract-widget/my-profile-contract-widget.component.html +63 -0
- package/src/lib/my-profile/contract-widget/my-profile-contract-widget.component.ts +73 -0
- package/src/lib/my-profile/degrees-widget/my-profile-degrees-widget-component.html +86 -0
- package/src/lib/my-profile/degrees-widget/my-profile-degrees-widget-component.ts +98 -0
- package/src/lib/my-profile/dependents-documents-widget/my-profile-dependents-documents-widget.html +83 -0
- package/src/lib/my-profile/dependents-documents-widget/my-profile-dependents-documents-widget.ts +126 -0
- package/src/lib/my-profile/documents-widgets/components/document-card/document-card.component.html +53 -0
- package/src/lib/my-profile/documents-widgets/components/document-card/document-card.component.ts +50 -0
- package/src/lib/my-profile/documents-widgets/components/document-row/document-row.component.html +48 -0
- package/src/lib/my-profile/documents-widgets/components/document-row/document-row.component.ts +44 -0
- package/src/lib/my-profile/documents-widgets/components/document-tablet-card/document-tablet-card.component.html +46 -0
- package/src/lib/my-profile/documents-widgets/components/document-tablet-card/document-tablet-card.component.ts +47 -0
- package/src/lib/my-profile/employee-dependents-widget/my-profile-employee-dependents-component.html +50 -0
- package/src/lib/my-profile/employee-dependents-widget/my-profile-employee-dependents-component.ts +63 -0
- package/src/lib/my-profile/entitlements-others-widget/my-profile-entitlements-others-widget.component.html +26 -0
- package/src/lib/my-profile/entitlements-others-widget/my-profile-entitlements-others-widget.component.ts +66 -0
- package/src/lib/my-profile/experiences-widget/my-profile-experiences-widget-component.html +93 -0
- package/src/lib/my-profile/experiences-widget/my-profile-experiences-widget-component.ts +102 -0
- package/src/lib/my-profile/indemnity-widget/my-profile-indemnity-widget.component.html +49 -0
- package/src/lib/my-profile/indemnity-widget/my-profile-indemnity-widget.component.ts +79 -0
- package/src/lib/my-profile/job-info-widget/my-profile-job-info-widget.component.html +71 -0
- package/src/lib/my-profile/job-info-widget/my-profile-job-info-widget.component.ts +73 -0
- package/src/lib/my-profile/languages-widget/my-profile-languages-widget.component.html +23 -0
- package/src/lib/my-profile/languages-widget/my-profile-languages-widget.component.ts +70 -0
- package/src/lib/my-profile/medical-insurance-widget/components/medical-insurance-card/medical-insurance-card.component.html +18 -0
- package/src/lib/my-profile/medical-insurance-widget/components/medical-insurance-card/medical-insurance-card.component.ts +29 -0
- package/src/lib/my-profile/medical-insurance-widget/my-profile-medical-insurance-widget.component.html +52 -0
- package/src/lib/my-profile/medical-insurance-widget/my-profile-medical-insurance-widget.component.ts +103 -0
- package/src/lib/my-profile/official-documents-widget/my-profile-official-documents-widget.html +82 -0
- package/src/lib/my-profile/official-documents-widget/my-profile-official-documents-widget.ts +119 -0
- package/src/lib/my-profile/other-nationalities-widget/my-profile-other-nationalities-widget.component.html +23 -0
- package/src/lib/my-profile/other-nationalities-widget/my-profile-other-nationalities-widget.component.ts +70 -0
- package/src/lib/my-profile/personal-info-main-widget/my-profile-personal-info-main-widget.component.html +115 -0
- package/src/lib/my-profile/personal-info-main-widget/my-profile-personal-info-main-widget.component.ts +75 -0
- package/src/lib/my-profile/salary-widget/my-profile-salary-widget.component.html +37 -0
- package/src/lib/my-profile/salary-widget/my-profile-salary-widget.component.ts +85 -0
- package/src/lib/my-profile/service-charge-widget/my-profile-service-charge-widget.component.html +16 -0
- package/src/lib/my-profile/service-charge-widget/my-profile-service-charge-widget.component.ts +101 -0
- package/src/lib/my-profile/ticket-widget/components/ticket-card/ticket-card.component.html +23 -0
- package/src/lib/my-profile/ticket-widget/components/ticket-card/ticket-card.component.ts +26 -0
- package/src/lib/my-profile/ticket-widget/my-profile-ticket-widget.component.html +68 -0
- package/src/lib/my-profile/ticket-widget/my-profile-ticket-widget.component.ts +93 -0
- package/src/lib/my-profile/vacations-widget/my-profile-vacations-widget.component.html +34 -0
- package/src/lib/my-profile/vacations-widget/my-profile-vacations-widget.component.ts +66 -0
- package/src/lib/my-team-subordinates-popup-widget/components/employee-main-info-card/employee-information-card.component.ts +65 -0
- package/src/lib/my-team-subordinates-popup-widget/components/employee-main-info-card/employee-main-info-card.component.html +57 -0
- package/src/lib/my-team-subordinates-popup-widget/components/my-team-subordinates-popup/my-team-popup.component.html +108 -0
- package/src/lib/my-team-subordinates-popup-widget/components/my-team-subordinates-popup/my-team-popup.component.ts +332 -0
- package/src/lib/my-upcoming-events-widget/components/event-item/event-item.component.html +53 -0
- package/src/lib/my-upcoming-events-widget/components/event-item/event-item.component.ts +42 -0
- package/src/lib/my-upcoming-events-widget/components/event-tab-bar/event-tab-bar.component.html +21 -0
- package/src/lib/my-upcoming-events-widget/components/event-tab-bar/event-tab-bar.component.ts +44 -0
- package/src/lib/my-upcoming-events-widget/components/events-popup/events-popup.component.html +67 -0
- package/src/lib/my-upcoming-events-widget/components/events-popup/events-popup.component.ts +74 -0
- package/src/lib/my-upcoming-events-widget/my-upcoming-events-widget.component.html +74 -0
- package/src/lib/my-upcoming-events-widget/my-upcoming-events-widget.component.ts +199 -0
- package/src/lib/services/hr-self-widgets.service.ts +624 -0
- package/src/lib/shared/components/card-header/card-header.component.html +4 -0
- package/src/lib/shared/components/card-header/card-header.component.ts +18 -0
- package/src/lib/shared/components/hr-employee-calendar/hr-employee-calendar.component.html +47 -0
- package/src/lib/shared/components/hr-employee-calendar/hr-employee-calendar.component.ts +193 -0
- package/src/lib/shared/components/info-field/info-field.component.html +2 -0
- package/src/lib/shared/components/info-field/info-field.component.ts +20 -0
- package/src/lib/shared/components/widget-card/widget-card-component.html +3 -0
- package/src/lib/shared/components/widget-card/widget-card-component.ts +17 -0
- package/src/lib/shared/pipes/translate.pipe.ts +34 -0
- package/src/lib/shared/services/bank-information-cache.service.ts +29 -0
- package/src/lib/shared/services/common-methods.service.ts +33 -0
- package/src/lib/shared/services/constants.service.ts +12 -0
- package/src/lib/shared/services/entitlements-cache.service.ts +94 -0
- package/src/lib/shared/services/job-information-cache.service.ts +72 -0
- package/src/lib/shared/services/my-team-popup.service.ts +34 -0
- package/src/lib/shared/services/personal-information-cache.service.ts +77 -0
- package/src/lib/shared/services/profile-documents-cache-service.ts +44 -0
- package/src/lib/shared/services/profile-employee-dependents-cach.ts +37 -0
- package/src/lib/shared/services/qualifications-cache.service.ts +45 -0
- package/src/lib/shared/services/translate.service.ts +35 -0
- package/src/lib/shared/types/common.ts +359 -0
- package/src/public-api.ts +35 -0
- package/tsconfig.lib.json +11 -0
- package/tsconfig.lib.prod.json +9 -0
- package/tsconfig.spec.json +8 -0
- package/fesm2022/skysoftware-co-bayan-hr-widgets-ui.mjs +0 -4812
- package/fesm2022/skysoftware-co-bayan-hr-widgets-ui.mjs.map +0 -1
- package/types/skysoftware-co-bayan-hr-widgets-ui.d.ts +0 -1308
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
<!-- Card View -->
|
|
2
|
+
<div [class]="cardClass()">
|
|
3
|
+
<hr-card-header [icon]="calendarStar" [title]="'UpcomingEvents' | translate"></hr-card-header>
|
|
4
|
+
|
|
5
|
+
@if (birthdays().length > 0 || holidays().length > 0) {
|
|
6
|
+
<hr-event-tab-bar
|
|
7
|
+
[selectedType]="selectedEventType()"
|
|
8
|
+
[selectedLanguage]="selectedLanguage()"
|
|
9
|
+
[tabSelectedClass]="tabSelectedClass()"
|
|
10
|
+
[tabNotSelectedClass]="tabNotSelectedClass()"
|
|
11
|
+
[tabTextSelectedClass]="tabTextSelectedClass()"
|
|
12
|
+
[tabTextNotSelectedClass]="tabTextNotSelectedClass()"
|
|
13
|
+
[containerClass]="tabContainerClass()"
|
|
14
|
+
[tabItemClass]="tabItemClass()"
|
|
15
|
+
[tabTextClass]="tabTextClass()"
|
|
16
|
+
[tabIconClass]="tabIconClass()"
|
|
17
|
+
(tabSelected)="onTabClick($event)"
|
|
18
|
+
></hr-event-tab-bar>
|
|
19
|
+
|
|
20
|
+
<hr-event-item
|
|
21
|
+
[events]="filteredEvents()"
|
|
22
|
+
[showDates]="false"
|
|
23
|
+
[showProperty]="showProperty()"
|
|
24
|
+
[selectedLanguage]="selectedLanguage()"
|
|
25
|
+
[selectedEventType]="selectedEventType()"
|
|
26
|
+
[weekendWarningDescription]="weekendWarning()"
|
|
27
|
+
[eventIconClass]="eventIconClass()"
|
|
28
|
+
[eventNameBoldClass]="eventNameBoldClass()"
|
|
29
|
+
[eventDescriptionClass]="eventDescriptionClass()"
|
|
30
|
+
[propertyBadgeClass]="propertyBadgeClass()"
|
|
31
|
+
[noEventsTextClass]="noEventsTextClass()"
|
|
32
|
+
[warningTextClass]="warningTextClass()"
|
|
33
|
+
[dateFormat]="dateFormat()"
|
|
34
|
+
></hr-event-item>
|
|
35
|
+
|
|
36
|
+
<div [class]="viewAllContainerClass()">
|
|
37
|
+
<a [class]="viewAllLinkClass()" (click)="showPopup()">{{ 'ViewAll' | translate }}</a>
|
|
38
|
+
</div>
|
|
39
|
+
} @else {
|
|
40
|
+
<div [class]="noEventsTextClass()">{{ 'NoEvents' | translate }}</div>
|
|
41
|
+
}
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
<!-- Popup -->
|
|
45
|
+
<hr-upcoming-events-popup
|
|
46
|
+
[visible]="popupVisible()"
|
|
47
|
+
[events]="popupEvents()"
|
|
48
|
+
[hasBirthdays]="birthdays().length > 0"
|
|
49
|
+
[hasHolidays]="holidays().length > 0"
|
|
50
|
+
[isLoading]="false"
|
|
51
|
+
[selectedLanguage]="selectedLanguage()"
|
|
52
|
+
[showProperty]="showProperty()"
|
|
53
|
+
[weekendWarningDescription]="weekendWarning()"
|
|
54
|
+
[popupTitle]="'UpcomingEvents' | translate"
|
|
55
|
+
[selectedEventType]="selectedPopupEventType()"
|
|
56
|
+
[tabSelectedClass]="tabSelectedClass()"
|
|
57
|
+
[tabNotSelectedClass]="tabNotSelectedClass()"
|
|
58
|
+
[tabTextSelectedClass]="tabTextSelectedClass()"
|
|
59
|
+
[tabTextNotSelectedClass]="tabTextNotSelectedClass()"
|
|
60
|
+
[tabContainerClass]="tabContainerClass()"
|
|
61
|
+
[tabItemClass]="tabItemClass()"
|
|
62
|
+
[tabTextClass]="tabTextClass()"
|
|
63
|
+
[tabIconClass]="tabIconClass()"
|
|
64
|
+
[eventIconClass]="eventIconClass()"
|
|
65
|
+
[eventNameBoldClass]="eventNameBoldClass()"
|
|
66
|
+
[eventDescriptionClass]="eventDescriptionClass()"
|
|
67
|
+
[propertyBadgeClass]="propertyBadgeClass()"
|
|
68
|
+
[noEventsTextClass]="noEventsTextClass()"
|
|
69
|
+
[warningTextClass]="warningTextClass()"
|
|
70
|
+
[dateFormat]="dateFormat()"
|
|
71
|
+
(visibleChange)="onPopupVisibleChange($event)"
|
|
72
|
+
(tabSelected)="onPopupTabClick($event)"
|
|
73
|
+
(closed)="onPopupClose()"
|
|
74
|
+
></hr-upcoming-events-popup>
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, effect, inject, input, output, signal } from '@angular/core';
|
|
2
|
+
import { HRSelfWidgetsService } from '../services/hr-self-widgets.service';
|
|
3
|
+
import { faCalendarStar } from '@fortawesome/pro-light-svg-icons';
|
|
4
|
+
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
|
|
5
|
+
import { HRCardHeaderComponent } from '../shared/components/card-header/card-header.component';
|
|
6
|
+
import { HREventItemComponent } from './components/event-item/event-item.component';
|
|
7
|
+
import { HREventTabBarComponent } from './components/event-tab-bar/event-tab-bar.component';
|
|
8
|
+
import { HREventsPopupComponent } from './components/events-popup/events-popup.component';
|
|
9
|
+
import {
|
|
10
|
+
EventOption,
|
|
11
|
+
RelativeDay,
|
|
12
|
+
Birthday,
|
|
13
|
+
PublicHoliday,
|
|
14
|
+
UpcomingEventsV2,
|
|
15
|
+
EventTypeEnum,
|
|
16
|
+
FilteredUpcomingEvent,
|
|
17
|
+
} from '../shared/types/common';
|
|
18
|
+
import { HRTranslatePipe } from '../shared/pipes/translate.pipe';
|
|
19
|
+
|
|
20
|
+
@Component({
|
|
21
|
+
selector: 'hr-my-upcoming-events-widget',
|
|
22
|
+
standalone: true,
|
|
23
|
+
imports: [
|
|
24
|
+
FontAwesomeModule,
|
|
25
|
+
HRCardHeaderComponent,
|
|
26
|
+
HREventItemComponent,
|
|
27
|
+
HREventTabBarComponent,
|
|
28
|
+
HREventsPopupComponent,
|
|
29
|
+
HRTranslatePipe,
|
|
30
|
+
],
|
|
31
|
+
templateUrl: './my-upcoming-events-widget.component.html',
|
|
32
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
33
|
+
})
|
|
34
|
+
export class MyUpcomingEventsWidgetComponent {
|
|
35
|
+
readonly baseUrl = input<string>('');
|
|
36
|
+
readonly weekendWarningDescription = input<string>('WeekendDayNotDefined');
|
|
37
|
+
readonly selectedLanguage = input<string>('en');
|
|
38
|
+
readonly showProperty = input<boolean>(true);
|
|
39
|
+
|
|
40
|
+
readonly cardClass = input<string>('bg-light-gray border-0 card p-3 card-shadow rounded rounded-4 mt-3');
|
|
41
|
+
readonly noEventsTextClass = input<string>('text-center my-3 text-light-gray');
|
|
42
|
+
readonly viewAllLinkClass = input<string>('fs-14 mt-2');
|
|
43
|
+
readonly viewAllContainerClass = input<string>('d-flex justify-content-end cursor-pointer');
|
|
44
|
+
readonly warningTextClass = input<string>('text-center my-2 text-light-gray');
|
|
45
|
+
readonly tabSelectedClass = input<string>('selected-event-option');
|
|
46
|
+
readonly tabNotSelectedClass = input<string>('not-selected-event-option');
|
|
47
|
+
readonly tabTextSelectedClass = input<string>('text-white');
|
|
48
|
+
readonly tabTextNotSelectedClass = input<string>('text-primary');
|
|
49
|
+
readonly tabContainerClass = input<string>('d-flex gap-2 mb-3');
|
|
50
|
+
readonly tabItemClass = input<string>(
|
|
51
|
+
'col-1 align-items-center rounded rounded-3 cursor-pointer text-center d-flex justify-content-center py-2 px-3',
|
|
52
|
+
);
|
|
53
|
+
readonly tabTextClass = input<string>('fs-16');
|
|
54
|
+
readonly tabIconClass = input<string>('fs-6');
|
|
55
|
+
readonly eventIconClass = input<string>('fs-6 text-primary pe-2');
|
|
56
|
+
readonly eventNameBoldClass = input<string>('fw-medium');
|
|
57
|
+
readonly eventDescriptionClass = input<string>('text-primary fw-medium');
|
|
58
|
+
readonly propertyBadgeClass = input<string>('property-badge cursor-pointer me-1');
|
|
59
|
+
readonly dateFormat = input<string>('dd/MM/yyyy');
|
|
60
|
+
|
|
61
|
+
readonly isLoadingChanged = output<boolean>();
|
|
62
|
+
readonly viewAllClicked = output<void>();
|
|
63
|
+
|
|
64
|
+
readonly externalViewAll = input<boolean>(false);
|
|
65
|
+
|
|
66
|
+
readonly selectedEventType = signal<EventTypeEnum | null>(null);
|
|
67
|
+
readonly selectedPopupEventType = signal<EventTypeEnum | null>(null);
|
|
68
|
+
|
|
69
|
+
readonly calendarStar = faCalendarStar;
|
|
70
|
+
|
|
71
|
+
readonly filteredEvents = signal<FilteredUpcomingEvent[]>([]);
|
|
72
|
+
readonly birthdays = signal<Birthday[]>([]);
|
|
73
|
+
readonly holidays = signal<PublicHoliday[]>([]);
|
|
74
|
+
|
|
75
|
+
readonly popupEvents = signal<FilteredUpcomingEvent[]>([]);
|
|
76
|
+
readonly popupVisible = signal(false);
|
|
77
|
+
|
|
78
|
+
readonly weekendWarning = signal<string | null>(null);
|
|
79
|
+
|
|
80
|
+
private readonly selfWidgetsService = inject(HRSelfWidgetsService);
|
|
81
|
+
|
|
82
|
+
private readonly loadEventsEffect = effect(() => {
|
|
83
|
+
this.loadEvents(EventOption.All);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
onTabClick(eventType: EventTypeEnum | null) {
|
|
87
|
+
this.selectedEventType.set(eventType);
|
|
88
|
+
this.filteredEvents.set(this.buildEvents(this.cardData(), eventType, 2));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
onPopupTabClick(eventType: EventTypeEnum | null) {
|
|
92
|
+
this.selectedPopupEventType.set(eventType);
|
|
93
|
+
this.popupEvents.set(this.buildEvents(this.cardData(), eventType));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
showPopup() {
|
|
97
|
+
if (this.externalViewAll()) {
|
|
98
|
+
this.viewAllClicked.emit();
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
this.popupEvents.set(this.buildEvents(this.cardData(), this.selectedPopupEventType()));
|
|
102
|
+
this.popupVisible.set(true);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
onPopupClose() {
|
|
106
|
+
this.popupVisible.set(false);
|
|
107
|
+
this.selectedPopupEventType.set(null);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
onPopupVisibleChange(visible: boolean) {
|
|
111
|
+
this.popupVisible.set(visible);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// --- Private ---
|
|
115
|
+
|
|
116
|
+
private readonly cardData = signal<UpcomingEventsV2 | null>(null);
|
|
117
|
+
|
|
118
|
+
private getUpcomingEvents(eventOption: EventOption) {
|
|
119
|
+
return this.selfWidgetsService.getUpcomingEvents(this.baseUrl(), eventOption);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
private loadEvents(eventOption: EventOption) {
|
|
123
|
+
this.isLoadingChanged.emit(true);
|
|
124
|
+
this.getUpcomingEvents(eventOption).subscribe({
|
|
125
|
+
next: (response: any) => {
|
|
126
|
+
this.cardData.set(response.ResponseData);
|
|
127
|
+
const currentData = this.cardData();
|
|
128
|
+
this.birthdays.set(currentData?.Birthdays || []);
|
|
129
|
+
this.holidays.set(currentData?.PublicHolidays || []);
|
|
130
|
+
this.weekendWarning.set(currentData?.IsWeekendConfigured === false ? this.weekendWarningDescription() : null);
|
|
131
|
+
this.filteredEvents.set(this.buildEvents(currentData, null, 2));
|
|
132
|
+
this.isLoadingChanged.emit(false);
|
|
133
|
+
},
|
|
134
|
+
error: () => {
|
|
135
|
+
this.isLoadingChanged.emit(false);
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
private buildEvents(
|
|
141
|
+
source: UpcomingEventsV2 | null,
|
|
142
|
+
eventType: EventTypeEnum | null,
|
|
143
|
+
limit?: number,
|
|
144
|
+
): FilteredUpcomingEvent[] {
|
|
145
|
+
const birthdays = source?.Birthdays || [];
|
|
146
|
+
const holidays = source?.PublicHolidays || [];
|
|
147
|
+
|
|
148
|
+
let filtered: FilteredUpcomingEvent[];
|
|
149
|
+
|
|
150
|
+
if (eventType === EventTypeEnum.Birthdays) {
|
|
151
|
+
filtered = birthdays
|
|
152
|
+
.map(b => this.mapBirthday(b))
|
|
153
|
+
.sort((a, b) => new Date(a.EventDate).getTime() - new Date(b.EventDate).getTime());
|
|
154
|
+
} else if (eventType === EventTypeEnum.PublicHolidays) {
|
|
155
|
+
filtered = holidays
|
|
156
|
+
.map(h => this.mapHoliday(h))
|
|
157
|
+
.sort((a, b) => new Date(a.EventDate).getTime() - new Date(b.EventDate).getTime());
|
|
158
|
+
} else {
|
|
159
|
+
if (limit) {
|
|
160
|
+
filtered = [...birthdays.map(b => this.mapBirthday(b)), ...holidays.map(h => this.mapHoliday(h))]
|
|
161
|
+
.sort((a, b) => new Date(a.EventDate).getTime() - new Date(b.EventDate).getTime())
|
|
162
|
+
.slice(0, 2);
|
|
163
|
+
} else {
|
|
164
|
+
filtered = [...birthdays.map(b => this.mapBirthday(b)), ...holidays.map(h => this.mapHoliday(h))];
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (limit) {
|
|
169
|
+
filtered = filtered.slice(0, limit);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return filtered.sort((a, b) => new Date(a.EventDate).getTime() - new Date(b.EventDate).getTime());
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
private mapBirthday(b: Birthday): FilteredUpcomingEvent {
|
|
176
|
+
const birthdate = new Date(b.Birthdate);
|
|
177
|
+
const eventDate = new Date(new Date().getFullYear(), birthdate.getMonth(), birthdate.getDate());
|
|
178
|
+
return {
|
|
179
|
+
EventDate: eventDate,
|
|
180
|
+
Name: b.EmployeeShortName,
|
|
181
|
+
EventType: EventTypeEnum.Birthdays,
|
|
182
|
+
Description: b.RelativeDay.toString(),
|
|
183
|
+
IsIn2Days: RelativeDay[b.RelativeDay as unknown as keyof typeof RelativeDay] === RelativeDay.TwoDays,
|
|
184
|
+
PropertyName: b.EmployeePropertyName,
|
|
185
|
+
PropertySymbol: b.EmployeePropertySymbol,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
private mapHoliday(h: PublicHoliday): FilteredUpcomingEvent {
|
|
190
|
+
return {
|
|
191
|
+
EventDate: new Date(h.StartDate),
|
|
192
|
+
StartDate: new Date(h.StartDate),
|
|
193
|
+
EndDate: new Date(h.EndDate),
|
|
194
|
+
Name: h.Description,
|
|
195
|
+
EventType: EventTypeEnum.PublicHolidays,
|
|
196
|
+
Description: h.WeekContext.toString(),
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
}
|