From e8a92ea5ef516407184523e3fed31954127bd89e Mon Sep 17 00:00:00 2001 From: Mahmoud Emad Date: Sun, 5 Nov 2023 13:02:24 +0200 Subject: [PATCH] Display all public holidays, created new modal for holiday details, added soe enhancements to the details modals. --- .../src/componants/calendar/Calender.svelte | 16 +- .../src/componants/register/Register.svelte | 29 +- .../componants/settings/UpdateProfile.svelte | 1 + .../ui/modals/CalendarBirthdayModel.svelte | 12 +- .../ui/modals/CalendarEventDataModal.svelte | 19 +- .../ui/modals/CalendarMeetingModel.svelte | 19 +- .../modals/CalendarPublicHolidayModel.svelte | 75 +++++ .../modals/CalendarVacationDataModal.svelte | 257 +++++++++--------- client/src/utils/enums.ts | 11 +- client/src/utils/registeringData.ts | 1 + client/src/utils/types.ts | 26 +- server/cshr/services/landing_page.py | 10 +- server/cshr/services/public_holidays.py | 7 +- server/cshr/utils/vacation_balance.json | 2 +- 14 files changed, 322 insertions(+), 163 deletions(-) create mode 100644 client/src/componants/ui/modals/CalendarPublicHolidayModel.svelte diff --git a/client/src/componants/calendar/Calender.svelte b/client/src/componants/calendar/Calender.svelte index 1affc3a96..432e0be87 100644 --- a/client/src/componants/calendar/Calender.svelte +++ b/client/src/componants/calendar/Calender.svelte @@ -1,5 +1,5 @@
@@ -200,7 +204,7 @@
diff --git a/client/src/componants/ui/modals/CalendarBirthdayModel.svelte b/client/src/componants/ui/modals/CalendarBirthdayModel.svelte index 82eaf88f7..7f4184021 100644 --- a/client/src/componants/ui/modals/CalendarBirthdayModel.svelte +++ b/client/src/componants/ui/modals/CalendarBirthdayModel.svelte @@ -17,9 +17,9 @@ -
+
@@ -81,9 +81,11 @@
+ document.getElementById("body-pd").style.overflow = "auto"; + showModal = false; + }}> + Close +
diff --git a/client/src/componants/ui/modals/CalendarEventDataModal.svelte b/client/src/componants/ui/modals/CalendarEventDataModal.svelte index dc05868c5..d420c18e8 100644 --- a/client/src/componants/ui/modals/CalendarEventDataModal.svelte +++ b/client/src/componants/ui/modals/CalendarEventDataModal.svelte @@ -1,4 +1,5 @@ -
+
@@ -124,6 +131,14 @@ {/if}
+
+ +
\ No newline at end of file diff --git a/client/src/componants/ui/modals/CalendarVacationDataModal.svelte b/client/src/componants/ui/modals/CalendarVacationDataModal.svelte index c5ee4c951..9b6f93fcc 100644 --- a/client/src/componants/ui/modals/CalendarVacationDataModal.svelte +++ b/client/src/componants/ui/modals/CalendarVacationDataModal.svelte @@ -3,7 +3,7 @@ import ProfileImage from '../../profile/ProfileImage.svelte'; import CalendarModal from './CalendarModal.svelte'; import { UserStore } from '../../../utils/stores'; - import { RequestStatus, UserTypeEnum } from "../../../utils/enums"; + import { CalenderEventEmojeTyoe, RequestStatus, UserTypeEnum } from "../../../utils/enums"; import Alert from "../Alert.svelte"; import Loading from '../Loading.svelte'; import Requests from '../../../apis/requests/Requests'; @@ -86,144 +86,159 @@ -
+
-
-
-
- {#each clickedItemOnModal.vacation as vacation} - -
{ - activateVacation(vacation) - } - }> - -
- {/each} +
+
+
+ {#each clickedItemOnModal.vacation as vacation} + +
{ + activateVacation(vacation) + } + }> +
-
- -
{currentVacationActive.applying_user.full_name}
-

- {currentVacationActive.applying_user.job_title} - - {currentVacationActive.applying_user.team} -
- - {currentVacationActive.applying_user.email} - -

+ {/each} +
+
+ +
{currentVacationActive.applying_user.full_name}
+

+ {currentVacationActive.applying_user.job_title} + + {currentVacationActive.applying_user.team} +
+ + {currentVacationActive.applying_user.email} + +

-
-
-
- - - - - - From - -
-
- {`${currentVacationActive.from_date}`} -
+
+
+
+ + + + + + From +
- -
-
- To -
-
- {`${currentVacationActive.end_date}`} -
+
+ {`${currentVacationActive.from_date}`} +
+
+ +
+
+ To +
+
+ {`${currentVacationActive.end_date}`} +
+
+
+
+ + + + + Reason + +
+
+ {currentVacationActive.reason}
-
+
+ +
+
+ Status +
+
+ {currentVacationActive.status} +
+
+ {#if currentVacationActive.approval_user && currentVacationActive.approval_user.full_name} +
- - + + + - Reason + Approved by
- {currentVacationActive.reason} -
-
- -
-
- Status -
-
- {currentVacationActive.status} + + @{currentVacationActive.approval_user.full_name} +
- {#if currentVacationActive.approval_user && currentVacationActive.approval_user.full_name} -
-
- - - - - - Approved by - -
-
- - @{currentVacationActive.approval_user.full_name} - -
-
- {/if} -
-
- {#if showAlert} - - {/if} - - {#if $UserStore.user_type == UserTypeEnum.admin && currentVacationActive.status == RequestStatus.pinding} -
- - -
{/if} +
+ {#if showAlert} + + {/if} + + {#if $UserStore.user_type == UserTypeEnum.admin && currentVacationActive.status == RequestStatus.pinding} +
+ + +
+ {/if} +
+
+
+
diff --git a/client/src/utils/enums.ts b/client/src/utils/enums.ts index 5248b33f8..976182e83 100644 --- a/client/src/utils/enums.ts +++ b/client/src/utils/enums.ts @@ -1,8 +1,9 @@ -export enum CalenderEventTyoe { - vacation = "vacation", - event = "event", - birthday = "birthday", - meeting = "meeting" +export enum CalenderEventType { + vacation = "vacation", + event = "event", + birthday = "birthday", + meeting = "meeting", + publicHoliday = "public_holiday" } export enum CalenderEventEmojeTyoe { diff --git a/client/src/utils/registeringData.ts b/client/src/utils/registeringData.ts index c65883d01..4e9ade2b9 100644 --- a/client/src/utils/registeringData.ts +++ b/client/src/utils/registeringData.ts @@ -1,5 +1,6 @@ export default { + id: 0, first_name: "", last_name: "", telegram_link: "", diff --git a/client/src/utils/types.ts b/client/src/utils/types.ts index f56a14a61..13007adf1 100644 --- a/client/src/utils/types.ts +++ b/client/src/utils/types.ts @@ -226,7 +226,7 @@ export type registeringData = { last_name: string; telegram_link: string; email: string; - birthday: Date; + birthday: Date | string; mobile_number: string; address: string; password: string; @@ -236,7 +236,7 @@ export type registeringData = { user_type: string; social_insurance_number: string; reporting_to: number[]; - image: HTMLImageElement; + image: string; gender: string; job_title: string; }; @@ -272,6 +272,13 @@ export type userDataType = { gender: string; job_title: string; }; + +export type holidaysDataType = { + id: number; + location: OfficeType; + holiday_date: string; +}; + export type birthDateItemType = { id: number; title: string; @@ -290,7 +297,7 @@ export type meetingItemType = { meeting_link: string; invited_users: userDataType[]; host_user: userDataType; - date: any; + date: BackendParsedDate; parsedDate: dateType; className: string; eventName: eventNameType; @@ -307,6 +314,14 @@ export type stackedImageType = { team?: string; }; +export type BackendParsedDate = { + year: number; + month: number; + day: number; + hour: number; + minute: number; +} + export type eventItemType = { id: number; name: string; @@ -316,8 +331,8 @@ export type eventItemType = { location: string; from_time: string; end_time: string; - from_date: {year: number, month: number, day: number, hour: number, minute: number}; - end_date: {year: number, month: number, day: number, hour: number, minute: number}; + from_date: BackendParsedDate; + end_date: BackendParsedDate; }; export type vacationItemType = { @@ -370,6 +385,7 @@ export type calendarItemsType = { meeting?: meetingItemType[], event?: eventItemType[], users?: userDataType[], + holidays?: holidaysDataType[], } export type CalenderRequestFormResponseType = { diff --git a/server/cshr/services/landing_page.py b/server/cshr/services/landing_page.py index 0474525ab..49a2d0c6c 100644 --- a/server/cshr/services/landing_page.py +++ b/server/cshr/services/landing_page.py @@ -53,7 +53,7 @@ def landing_page_calendar_functionality(user: User, month: str, year: str): users_birthdates: List[User] = filter_users_by_berithday_month(month).order_by( "-created_at" ) - public_holidays: PublicHoliday = filter_public_holidays_by_month_and_year(user, year, month).order_by( + public_holidays: PublicHoliday = filter_public_holidays_by_month_and_year(year, month).order_by( "-created_at" ) @@ -81,7 +81,13 @@ def landing_page_calendar_functionality(user: User, month: str, year: str): obj["title"] = LandingPageTypeEnum.PUBLIC_HOLIDAY.value obj["className"] = LandingPageClassNameEnum.PUBLIC_HOLIDAY.value obj["eventName"] = LandingPageTypeEnum.PUBLIC_HOLIDAY.value - obj["holidays"] = PublicHolidaySerializer(public_holidays, many=True,).data + obj["holidays"] = PublicHolidaySerializer( + public_holidays.filter( + holiday_date__day=object.holiday_date.day, + holiday_date__month=object.holiday_date.month, + ), + many=True, + ).data obj["date"] = object.holiday_date obj["len"] = 1 elif isinstance(object, Meetings): diff --git a/server/cshr/services/public_holidays.py b/server/cshr/services/public_holidays.py index be3c1d503..1c9b7aa07 100644 --- a/server/cshr/services/public_holidays.py +++ b/server/cshr/services/public_holidays.py @@ -5,12 +5,11 @@ from server.cshr.models.vacations import PublicHoliday -def filter_public_holidays_by_month_and_year(user: User, year: str, month: str): +def filter_public_holidays_by_month_and_year(year: str, month: str): """ - Filter holidays based on user location and the year and month to be displayed on the calander. + Filter holidays based on the year and month to be displayed on the calander. """ - location: Office = user.location - return PublicHoliday.objects.filter(location=location, holiday_date__year=year, holiday_date__month=month) + return PublicHoliday.objects.filter(holiday_date__year=year, holiday_date__month=month) def get_user_holidays(user: User, years: List[int], months: List[int]): """ diff --git a/server/cshr/utils/vacation_balance.json b/server/cshr/utils/vacation_balance.json index 661f9bedf..fcd965cdf 100644 --- a/server/cshr/utils/vacation_balance.json +++ b/server/cshr/utils/vacation_balance.json @@ -1 +1 @@ -{"annual_leaves": 12, "sick_leaves": 100, "compensation": 100, "unpaid": 100, "emergency_leaves": 12, "leave_excuses": 12, "public_holidays": ["2023-11-2"], "year": 2023} \ No newline at end of file +{"annual_leaves": 69, "sick_leaves": 100, "compensation": 100, "unpaid": 100, "emergency_leaves": 13, "leave_excuses": 6, "public_holidays": [], "year": 2023} \ No newline at end of file