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', 'Edit vacation 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 @@ - + + - {{ t('absence', 'Edit entitlement: {type}', { type: balance.typeLabel }, undefined, { escape: false, sanitize: false }) }} - + {{ t('absence', 'Somebody else from HR changes your own days.') }} + @@ -246,6 +254,7 @@ import { generateUrl } from '@nextcloud/router' import { computed, onMounted, ref, shallowRef, watch } from 'vue' import NcActionButton from '@nextcloud/vue/components/NcActionButton' import NcActions from '@nextcloud/vue/components/NcActions' +import NcActionText from '@nextcloud/vue/components/NcActionText' import NcAvatar from '@nextcloud/vue/components/NcAvatar' import NcButton from '@nextcloud/vue/components/NcButton' import NcChip from '@nextcloud/vue/components/NcChip' @@ -256,6 +265,7 @@ import AccountGroup from 'vue-material-design-icons/AccountGroup.vue' import BellRingOutline from 'vue-material-design-icons/BellRingOutline.vue' import CodeBraces from 'vue-material-design-icons/CodeBraces.vue' import Download from 'vue-material-design-icons/Download.vue' +import InformationOutline from 'vue-material-design-icons/InformationOutline.vue' import Magnify from 'vue-material-design-icons/Magnify.vue' import Pencil from 'vue-material-design-icons/Pencil.vue' import EmployeesJsonDialog from '../../components/EmployeesJsonDialog.vue' @@ -263,6 +273,8 @@ import EntitlementDialog from '../../components/EntitlementDialog.vue' import RegionReminderDialog from '../../components/RegionReminderDialog.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 { balanceTone } from '../../utils/balance.ts' import { formatDate } from '../../utils/dates.ts' import { serverMessage } from '../../utils/errors.ts' @@ -306,6 +318,7 @@ const filter = ref('all') const limit = ref(PAGE) const year = ref(currentYear) const years = [currentYear - 1, currentYear, currentYear + 1] +const sessionStore = useSessionStore() const editing = ref(null) const editingJson = ref(false) const reminding = ref(false)