diff --git a/SPECIFICATION.md b/SPECIFICATION.md index 1ffcd736..5b9e4ede 100644 --- a/SPECIFICATION.md +++ b/SPECIFICATION.md @@ -1739,9 +1739,13 @@ NcContent(app-name="absence") (filter form + CSV buttons), plus entitlement / leave-type / holiday management. - **Profile** (`#/profile`, `#/profile/:uid`) — the first entry of the navigation. The person's vacation balance and next leave (HR edits the vacation days there with the entitlement - editor of the Employees list, §13), their region code (editable by the person, with the - change dialog of §7.2), the number of public holidays this year and the next ones, the - contract (§6.4: read-only, editable by HR), sick days this year (HR only when sick + editor of the Employees list, §13): on one's own profile the ring and a link to *My + leave* for the details, on someone else's the ring with its ledger. Their region code + (editable by the person: *Save* first shows the change dialog of §7.2), the number of + public holidays this year and the next ones with a link to the list, the + contract (§6.4: read-only, editable by HR; the "Since" line of today's working pattern is + left out when it began on the start date, and the note says who sees it, "you, your + manager and HR" on one's own profile), sick days this year (HR only when sick leave is a confidential type, §5.7), and the history of changes (the person and HR only). The person, their manager and HR may open it (`GET /api/profiles/{uid}`), the same rule as balances. An account that does not diff --git a/src/components/RegionCodeField.vue b/src/components/RegionCodeField.vue index f0455e42..4ee16976 100644 --- a/src/components/RegionCodeField.vue +++ b/src/components/RegionCodeField.vue @@ -12,10 +12,10 @@ :modelValue="code" :label="t('absence', 'My region code')" :error="code !== '' && !codeValid" - :helperText="code !== '' && !codeValid ? t('absence', 'Use a country like DE or a region like DE-BY') : ''" + :helperText="code !== '' && !codeValid ? t('absence', 'Use a country like DE or a region like DE-BY') : t('absence', 'Sets your public holidays')" @update:modelValue="code = String($event)" /> - {{ t('absence', 'Change') }} + {{ t('absence', 'Save') }}

diff --git a/src/utils/contract.spec.ts b/src/utils/contract.spec.ts index 3c55128b..61418853 100644 --- a/src/utils/contract.spec.ts +++ b/src/utils/contract.spec.ts @@ -3,7 +3,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ import { describe, expect, it } from 'vitest' -import { contractDiff, describePeriod, weekdaysOn } from './contract.ts' +import { contractDiff, describePeriod, patternSince, weekdaysOn } from './contract.ts' const fullTime = { from: '2024-03-01', weekdays: [1, 2, 3, 4, 5], percent: 100 } const fourDays = { from: '2026-07-01', weekdays: [1, 2, 3, 4], percent: 80 } @@ -43,3 +43,17 @@ describe('contractDiff', () => { expect(contractDiff([], [fullTime])).toEqual({ removed: [], added: [fullTime], kept: [] }) }) }) + +describe('patternSince', () => { + it('dates a pattern that began after the start', () => { + expect(patternSince(fourDays.from, fullTime.from)).toBe('2026-07-01') + }) + + it('leaves the date out when the pattern began on the start date', () => { + expect(patternSince(fullTime.from, '2024-03-01')).toBeNull() + }) + + it('dates the pattern when there is no start date', () => { + expect(patternSince(fullTime.from, null)).toBe('2024-03-01') + }) +}) diff --git a/src/utils/contract.ts b/src/utils/contract.ts index 8434fad1..529acc3a 100644 --- a/src/utils/contract.ts +++ b/src/utils/contract.ts @@ -54,3 +54,14 @@ export function contractDiff(before: T[], after: T[]): const added = after.filter((period) => !before.some((other) => same(period, other))) return { removed, added, kept: removed.length ? [] : before.slice(-1) } } + +/** + * The date since which today's working pattern runs, for a read-only contract. + * + * @param from the start of the period in force today + * @param start the start date of the contract, null when HR entered none + * @return null when the pattern began on the start date, which has a line of its own + */ +export function patternSince(from: string, start: string | null): string | null { + return from === start ? null : from +} diff --git a/src/views/ProfileView.vue b/src/views/ProfileView.vue index d265d2eb..3dfc8215 100644 --- a/src/views/ProfileView.vue +++ b/src/views/ProfileView.vue @@ -68,7 +68,15 @@

{{ t('absence', 'Vacation {year}', { year: profile.holidays.year }) }}

- +
+ + + {{ t('absence', 'Details in My leave') }} + +
+ {{ t('absence', 'Next: {days}', { days: profile.holidays.upcoming.map((day) => `${day.label}, ${formatDate(day.date)}`).join(' · ') }, undefined, { escape: false, sanitize: false }) }}

- + {{ t('absence', 'See the list') }} - +
@@ -116,8 +124,8 @@ · {{ t('absence', '{percent}%', { percent: current.percent }) }}

-

- {{ t('absence', 'Since {date}', { date: formatDate(current.from) }) }} +

+ {{ t('absence', 'Since {date}', { date: formatDate(since) }) }}

@@ -130,7 +138,7 @@

- {{ t('absence', 'Set by HR. Visible to this person, their manager and HR.') }} + {{ profile.self ? t('absence', 'Set by HR. Visible to you, your manager and HR.') : t('absence', 'Set by HR. Visible to this person, their manager and HR.') }}

@@ -169,12 +177,14 @@ import NcButton from '@nextcloud/vue/components/NcButton' import NcEmptyContent from '@nextcloud/vue/components/NcEmptyContent' import Pencil from 'vue-material-design-icons/Pencil.vue' import BalanceCard from '../components/BalanceCard.vue' +import BalanceRing from '../components/BalanceRing.vue' import ContractEditor from '../components/ContractEditor.vue' import EntitlementDialog from '../components/EntitlementDialog.vue' import RegionCodeField from '../components/RegionCodeField.vue' import SkeletonList from '../components/SkeletonList.vue' import api from '../services/api.ts' import { useSessionStore } from '../stores/session.ts' +import { patternSince } from '../utils/contract.ts' import { formatDate, formatRange, toIso } from '../utils/dates.ts' import { displayNameOf } from '../utils/displayName.ts' import { isForbidden, serverMessage } from '../utils/errors.ts' @@ -219,6 +229,9 @@ const current = computed(() => { return [...profile.value.contract.periods].reverse().find((period) => period.from <= today) ?? null }) +/** When today's working pattern began, null when that is the start date */ +const since = computed(() => (current.value && profile.value ? patternSince(current.value.from, profile.value.contract.start) : null)) + watch(profileUid, () => { // The row belongs to the previous person: saving it would write to this one editingDays.value = null @@ -370,6 +383,18 @@ function onContractSaved(): void { margin: 12px 0 4px; } + &__balance { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: calc(4 * var(--default-grid-baseline)); + } + + &__link { + color: var(--color-primary-element); + font-weight: 600; + } + &__edit { margin-top: 8px; }