From d7dd260016cfd403fec2e158950e0d3c6b740bd8 Mon Sep 17 00:00:00 2001 From: Denis Maslennikov <41147528+disant1@users.noreply.github.com> Date: Fri, 23 Dec 2022 00:48:46 +0700 Subject: [PATCH] TSK-485: Calendar Year/Month summary (#2465) Signed-off-by: Denis Maslennikov --- plugins/hr-assets/lang/en.json | 1 + plugins/hr-assets/lang/ru.json | 1 + .../src/components/ScheduleView.svelte | 4 +- .../src/components/schedule/MonthView.svelte | 48 +++++++++++++++++-- .../schedule/ReportPresenter.svelte | 3 +- .../src/components/schedule/YearView.svelte | 31 ++++++++++-- plugins/hr-resources/src/plugin.ts | 1 + 7 files changed, 81 insertions(+), 8 deletions(-) diff --git a/plugins/hr-assets/lang/en.json b/plugins/hr-assets/lang/en.json index 08657e4700..fd43c5d5ac 100644 --- a/plugins/hr-assets/lang/en.json +++ b/plugins/hr-assets/lang/en.json @@ -22,6 +22,7 @@ "RequestType": "Type", "CreateRequest": "Create {type}", "Today": "Today", + "Summary": "Total", "NoEmployeesInDepartment": "There are no employees in the selected department", "Vacation": "Vacation", "Sick": "Sick", diff --git a/plugins/hr-assets/lang/ru.json b/plugins/hr-assets/lang/ru.json index 45dace171a..9f4eb81fed 100644 --- a/plugins/hr-assets/lang/ru.json +++ b/plugins/hr-assets/lang/ru.json @@ -22,6 +22,7 @@ "RequestType": "Тип", "CreateRequest": "Создать {type}", "Today": "Сегодня", + "Summary": "Итого", "NoEmployeesInDepartment": "Нет сотрудников в выбранном департаменте", "Vacation": "Отпуск", "Sick": "Больничный", diff --git a/plugins/hr-resources/src/components/ScheduleView.svelte b/plugins/hr-resources/src/components/ScheduleView.svelte index 652dad8aee..bffca4d86c 100644 --- a/plugins/hr-resources/src/components/ScheduleView.svelte +++ b/plugins/hr-resources/src/components/ScheduleView.svelte @@ -92,7 +92,9 @@ for (const request of res) { const requests = employeeRequests.get(request.attachedTo) ?? [] requests.push(request) - employeeRequests.set(request.attachedTo, requests) + if (request.attachedTo) { + employeeRequests.set(request.attachedTo, requests) + } } employeeRequests = employeeRequests } diff --git a/plugins/hr-resources/src/components/schedule/MonthView.svelte b/plugins/hr-resources/src/components/schedule/MonthView.svelte index 304708f727..ac4fedaeaa 100644 --- a/plugins/hr-resources/src/components/schedule/MonthView.svelte +++ b/plugins/hr-resources/src/components/schedule/MonthView.svelte @@ -52,8 +52,13 @@ const todayDate = new Date() - function getRequests (employee: Ref, date: Date): Request[] { - const requests = employeeRequests.get(employee) + function getRequests (date: Date, employee?: Ref): Request[] { + let requests = undefined + if (employee) { + requests = employeeRequests.get(employee) + } else { + requests = Array.from(employeeRequests.values()).flat() + } if (requests === undefined) return [] const res: Request[] = [] const time = date.getTime() @@ -176,7 +181,7 @@ {#each values as value, i} {@const date = getDay(startDate, value)} - {@const requests = getRequests(employee._id, date)} + {@const requests = getRequests(date, employee._id)} {@const editable = isEditable(employee)} {@const tooltipValue = getTooltip(requests)} {@const ww = findReports(employee, date, timeReports)} @@ -208,6 +213,40 @@ {/each} {/each} + + +