diff --git a/SPECIFICATION.md b/SPECIFICATION.md
index 79775d16..1ffdc7f8 100644
--- a/SPECIFICATION.md
+++ b/SPECIFICATION.md
@@ -590,7 +590,8 @@ The app knows when the decider is away — it manages their leave too:
own entitlement."), nor their own vacation days in the employees JSON (§6.5).
A bulk change and handing on a changed default (§6.1) leave the actor's own
entitlement out and answer `ownSkipped: true`. occ has no actor and changes
- every entitlement.
+ every entitlement. Their own profile and their own row of the employees list
+ offer no entitlement editor and say "Somebody else from HR changes your own days."
### 5.6 HR-recorded leave (e.g. sick leave)
diff --git a/src/utils/access.spec.ts b/src/utils/access.spec.ts
index d91f251c..ffbb031d 100644
--- a/src/utils/access.spec.ts
+++ b/src/utils/access.spec.ts
@@ -3,7 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { describe, expect, it } from 'vitest'
-import { canOpenRoute } from './access.ts'
+import { canEditEntitlementOf, canOpenRoute } from './access.ts'
describe('canOpenRoute', () => {
it('opens ordinary pages to everyone', () => {
@@ -22,3 +22,18 @@ describe('canOpenRoute', () => {
expect(canOpenRoute({ hr: true }, admin)).toBe(false)
})
})
+
+describe('canEditEntitlementOf', () => {
+ it('lets HR change somebody else\'s days', () => {
+ expect(canEditEntitlementOf({ uid: 'alice', isHr: true }, 'bob')).toBe(true)
+ })
+
+ it('leaves the days of an HR member to somebody else from HR', () => {
+ expect(canEditEntitlementOf({ uid: 'alice', isHr: true }, 'alice')).toBe(false)
+ })
+
+ it('never lets anybody else change days', () => {
+ expect(canEditEntitlementOf({ uid: 'alice', isHr: false }, 'bob')).toBe(false)
+ expect(canEditEntitlementOf({ uid: null }, 'bob')).toBe(false)
+ })
+})
diff --git a/src/utils/access.ts b/src/utils/access.ts
index aa107119..c935db5f 100644
--- a/src/utils/access.ts
+++ b/src/utils/access.ts
@@ -29,3 +29,14 @@ export function canOpenRoute(meta: RouteAccess, session: AccessRoles): boolean {
}
return !!session.isHr || (!!meta.admin && !!session.isAdmin)
}
+
+/**
+ * Whether this session may change someone's entitlement: HR may, except their
+ * own, which somebody else from HR changes (§5.5).
+ *
+ * @param session the current session
+ * @param uid whose entitlement it is
+ */
+export function canEditEntitlementOf(session: AccessRoles, uid: string): boolean {
+ return !!session.isHr && session.uid !== uid
+}
diff --git a/src/views/ProfileView.vue b/src/views/ProfileView.vue
index 3dfc8215..52bb572b 100644
--- a/src/views/ProfileView.vue
+++ b/src/views/ProfileView.vue
@@ -77,15 +77,20 @@
+ {{ t('absence', 'Somebody else from HR changes your own days.') }}
+
{{ n('absence', 'Next leave: {range}, {count} working day', 'Next leave: {range}, {count} working days', profile.nextLeave.workingDays, { range: formatRange(profile.nextLeave.startDate, profile.nextLeave.endDate), count: profile.nextLeave.workingDays }) }}
@@ -184,6 +189,7 @@ 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 { canEditEntitlementOf } from '../utils/access.ts' import { patternSince } from '../utils/contract.ts' import { formatDate, formatRange, toIso } from '../utils/dates.ts' import { displayNameOf } from '../utils/displayName.ts' diff --git a/src/views/hr/HrEmployees.vue b/src/views/hr/HrEmployees.vue index 6ace9ddc..734c57bd 100644 --- a/src/views/hr/HrEmployees.vue +++ b/src/views/hr/HrEmployees.vue @@ -187,15 +187,23 @@