Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions SPECIFICATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -609,9 +609,10 @@ employees — sick leave is the canonical example (`employee_requestable = false
edits or cancels it from the standard detail sidebar. There is **no delete**: a wrong
entry is cancelled (`CANCELLED`), so the row and its history stay intact for the audit
trail (§17). HR's cancel skips the withdrawal step and applies immediately (§5.5).
- **No "Approved" label shown.** Since approval isn't a concept for HR-recorded leave,
the UI hides the status chip and the approval **progress stepper** when such a request
is `APPROVED` (a cancelled one still shows its status). The leave-type chip (e.g.
- **"Recorded", not "Approved".** Since approval isn't a concept for HR-recorded leave,
the status chip reads **Recorded** and the approval **progress stepper** is hidden when
such a request is `APPROVED` (a cancelled one still shows its status). Every row of a
list carries a chip, so these rows look like the others. The leave-type chip (e.g.
"🤒 Sick leave") still identifies it.

---
Expand Down Expand Up @@ -1587,8 +1588,13 @@ NcContent(app-name="absence")
count adds the escalated requests, which HR decides on that page. HR sees
the *HR* section (grouped under an `NcAppNavigationCaption`). Every item uses an
`@mdi` icon. The **`NcAppNavigationNew` "New request"** button sits at the top as the
single prominent primary action.
- **Center `NcAppContent`** hosts the routed view.
single prominent primary action. A page header button that repeats a navigation action
(*New request* on My leave, *Record absence* on Absences) only shows while the
navigation is closed, so there is always exactly one.
- **Center `NcAppContent`** hosts the routed view. Every view uses the one page wrapper
(`src/styles/page.scss`): title and content share the same left edge, clear of the
navigation toggle; tables and timelines take the full width, forms, lists and cards
stop at a reading width.
- **Right `NcAppSidebar`** opens when a request is selected, with tabbed detail
(Details / Coverage / Comments / History) — the standard Nextcloud master-detail
pattern, used instead of a modal for *viewing* a request. Each comment shows when it
Expand Down Expand Up @@ -1676,7 +1682,8 @@ NcContent(app-name="absence")
- **Absences** (`#/hr/absences`, HR only) — the counterpart to *Record absence*: the
full list of recorded absences with filters for employee (user autocomplete), leave
type, status and year, paged with a "Load more" button. Rows are the same
`RequestListItem` as elsewhere and open the detail sidebar, whose **Edit** and
`RequestListItem` as elsewhere (with the person's days of that type still to book,
"N available", for a single year) and open the detail sidebar, whose **Edit** and
**Cancel** controls are what let HR correct a wrong vacation or sick day (§5.6).
People are named, never printed as user ids: requests are serialized with an
`employeeName` (display name, falling back to the uid for a deleted account),
Expand Down
6 changes: 0 additions & 6 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,4 @@ function onChanged(): void {
// The page shell and table styles every view builds on. Global on purpose —
// see the file header.
@use './styles/page.scss';

// Keep the page titles clear of the floating app-navigation toggle button,
// which overlays the top-left corner of the content area (applies to every view).
.app-absence .page__header {
padding-inline-start: calc(var(--default-clickable-area, 44px) + var(--app-navigation-padding, 4px) * 2);
}
</style>
22 changes: 10 additions & 12 deletions src/components/RequestListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<span aria-hidden="true">⚠️</span>
{{ othersOff.label }}
</span>
<StatusChip v-if="showStatus" :status="request.status" />
<StatusChip v-if="showStatus" :status="leaveTypesStore.displayStatus(request)" />
</template>
</NcListItem>
</div>
Expand All @@ -46,14 +46,14 @@ const props = withDefaults(defineProps<{
request: LeaveRequest
active?: boolean
showEmployee?: boolean
// The employee's remaining days for this leave type and year, when the caller
// has them to hand. Null for leave that counts against no allowance, and while
// the figures are still loading.
remaining?: number | null
// The days the employee can still book of this leave type and year (after
// pending requests), when the caller has them to hand. Null for leave that
// counts against no allowance, and while the figures are still loading.
available?: number | null
}>(), {
active: false,
showEmployee: false,
remaining: null,
available: null,
})

const emit = defineEmits<{
Expand All @@ -65,9 +65,7 @@ const leaveTypesStore = useLeaveTypesStore()
const type = computed(() => leaveTypesStore.leaveType(props.request.typeId))

// On a decision queue every row waits, so the status only tells a withdrawal apart
const showStatus = computed(() => props.request.decision
? props.request.status === 'WITHDRAWAL_PENDING'
: leaveTypesStore.statusVisible(props.request))
const showStatus = computed(() => !props.request.decision || props.request.status === 'WITHDRAWAL_PENDING')

const waiting = computed(() => {
const since = props.request.decision?.waitingSince
Expand Down Expand Up @@ -110,12 +108,12 @@ const subtitle = computed(() => {
if (after !== undefined && after !== null) {
return `${range} · ${days} · ${n('absence', '%n available after', '%n available after', Math.round(after * 10) / 10)}`
}
if (props.remaining === null) {
if (props.available === null) {
return `${range} · ${days}`
}
// Days taken alone does not answer the question the list is scanned for.
const left = n('absence', '%n day left', '%n days left', Math.round(props.remaining * 10) / 10)
return `${range} · ${days} · ${left}`
const available = n('absence', '%n available', '%n available', Math.round(props.available * 10) / 10)
return `${range} · ${days} · ${available}`
})

/**
Expand Down
9 changes: 5 additions & 4 deletions src/components/RequestSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
:name="type.label"
:subname="subLabel"
@close="$emit('close')">
<template v-if="showStatus" #description>
<StatusChip :status="detail.status" />
<template #description>
<StatusChip :status="leaveTypesStore.displayStatus(detail)" />
</template>

<NcAppSidebarTab id="details" :name="t('absence', 'Details')" :order="1">
Expand All @@ -22,7 +22,7 @@
<NcNoteCard v-if="shortNoticeLabel" type="warning">
{{ shortNoticeLabel }}
</NcNoteCard>
<RequestStepper v-if="showStatus" :status="detail.status" class="section__stepper" />
<RequestStepper v-if="!recorded" :status="detail.status" class="section__stepper" />
<dl class="facts">
<dt>{{ t('absence', 'Employee') }}</dt>
<dd class="facts__decided">
Expand Down Expand Up @@ -430,7 +430,8 @@ const shortNoticeLabel = computed(() => {
/** A confidential absence seen by someone outside HR: no category, no thread. */
const withheld = computed(() => detail.value?.typeId === null)

const showStatus = computed(() => detail.value ? leaveTypesStore.statusVisible(detail.value) : true)
/** Leave HR booked without an approval: there are no steps to show */
const recorded = computed(() => detail.value !== null && leaveTypesStore.displayStatus(detail.value) === 'RECORDED')

const isDecidable = computed(() => detail.value !== null && ['PENDING', 'ESCALATED', 'WITHDRAWAL_PENDING'].includes(detail.value.status))

Expand Down
4 changes: 2 additions & 2 deletions src/components/StatusChip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
</template>

<script setup lang="ts">
import type { RequestStatus } from '../types/index.ts'
import type { ChipStatus } from '../types/index.ts'

import { computed } from 'vue'
import { statusMeta } from '../utils/status.ts'

const props = defineProps<{
status: RequestStatus
status: ChipStatus
}>()

const meta = computed(() => statusMeta(props.status))
Expand Down
12 changes: 6 additions & 6 deletions src/stores/leaveTypes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ describe('leave types store', () => {

it('treats a withheld (confidential) type as HR-recorded', () => {
// The server nulls the type of confidential absences for non-HR viewers;
// those are always HR-recorded, so no approval chip should show either.
// those are always HR-recorded, so they read as recorded, not approved.
expect(store.isHrRecorded({ typeId: null })).toBe(true)
expect(store.statusVisible({ typeId: null, status: 'APPROVED' })).toBe(false)
expect(store.displayStatus({ typeId: null, status: 'APPROVED' })).toBe('RECORDED')
})

it('hides the "Approved" chip on HR-recorded leave (no approval concept)', () => {
expect(store.statusVisible({ typeId: 2, status: 'APPROVED' })).toBe(false)
expect(store.statusVisible({ typeId: 2, status: 'CANCELLED' })).toBe(true)
expect(store.statusVisible({ typeId: 1, status: 'APPROVED' })).toBe(true)
it('shows HR-recorded leave as recorded, since it has no approval', () => {
expect(store.displayStatus({ typeId: 2, status: 'APPROVED' })).toBe('RECORDED')
expect(store.displayStatus({ typeId: 2, status: 'CANCELLED' })).toBe('CANCELLED')
expect(store.displayStatus({ typeId: 1, status: 'APPROVED' })).toBe('APPROVED')
})
})
12 changes: 6 additions & 6 deletions src/stores/leaveTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import type { InitialState, LeaveRequest, LeaveType } from '../types/index.ts'
import type { ChipStatus, InitialState, LeaveRequest, LeaveType } from '../types/index.ts'

import { loadState } from '@nextcloud/initial-state'
import { t } from '@nextcloud/l10n'
Expand Down Expand Up @@ -56,13 +56,13 @@ export const useLeaveTypesStore = defineStore('leaveTypes', () => {
}

/**
* Whether to show a status chip. HR-recorded leave (sick) that is approved has no
* approval concept, so the "Approved" label is hidden as noise.
* The status a request's chip shows. HR-recorded leave (sick) has no approval,
* so once booked it reads "Recorded" rather than "Approved".
*
* @param request the request to look at
*/
function statusVisible(request: Typed & Pick<LeaveRequest, 'status'>): boolean {
return !(isHrRecorded(request) && request.status === 'APPROVED')
function displayStatus(request: Typed & Pick<LeaveRequest, 'status'>): ChipStatus {
return isHrRecorded(request) && request.status === 'APPROVED' ? 'RECORDED' : request.status
}

/**
Expand All @@ -72,5 +72,5 @@ export const useLeaveTypesStore = defineStore('leaveTypes', () => {
leaveTypes.value = await api.listLeaveTypes(false)
}

return { leaveTypes, enabledLeaveTypes, requestableLeaveTypes, leaveType, isHrRecorded, statusVisible, loadLeaveTypes }
return { leaveTypes, enabledLeaveTypes, requestableLeaveTypes, leaveType, isHrRecorded, displayStatus, loadLeaveTypes }
})
35 changes: 31 additions & 4 deletions src/styles/page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,46 @@
* `.app-absence .page`, so which one won would come down to stylesheet order.
*/

/*
* Every view starts at the same left edge, the title included. The app-navigation
* toggle floats over the top-left corner of the content, so the page keeps clear
* of it on that side. Pages of tables and timelines take the full width; pages of
* forms, lists and cards stop at a reading width.
*/
.app-absence {
--page-gutter: calc(var(--default-grid-baseline, 4px) * 5);
--page-toggle-clearance: calc(var(--default-clickable-area, 44px) + var(--app-navigation-padding, 4px) * 2);

.page {
max-width: 1100px;
margin: 0 auto;
padding: calc(var(--default-grid-baseline, 4px) * 5);
padding: var(--page-gutter);
padding-inline-start: var(--page-toggle-clearance);
display: flex;
flex-direction: column;
gap: calc(var(--default-grid-baseline, 4px) * 5);
}

/** Reading-width pages: forms, lists and cards rather than wide tables. */
.page--narrow {
max-width: 900px;
max-width: calc(860px + var(--page-toggle-clearance) + var(--page-gutter));
}

/**
* A header action that repeats one of the navigation. It only shows while the
* navigation is closed, so a page never offers the same action twice.
*/
.app-navigation:not(.app-navigation--closed) ~ .app-content .page__primary {
display: none;
}

/* On a phone the clearance would cost every row its width: only the title moves aside. */
@media (max-width: 512px) {
.page {
padding-inline-start: var(--page-gutter);
}

.page__header {
padding-inline-start: calc(var(--page-toggle-clearance) - var(--page-gutter));
}
}

/** More air between major sections (the personal dashboard views). */
Expand Down
3 changes: 3 additions & 0 deletions src/types/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import type { RequestCoverage } from './coverage.ts'

export type RequestStatus = 'PENDING' | 'ESCALATED' | 'APPROVED' | 'REJECTED' | 'CANCELLED' | 'WITHDRAWAL_PENDING'

/** What a status chip shows: the status, or RECORDED for leave HR booked without an approval. */
export type ChipStatus = RequestStatus | 'RECORDED'

/**
* Whose requests to list: the caller's own, those of the people who report to
* them ('reports' and 'approvals' are the same list), or everyone (HR only).
Expand Down
28 changes: 28 additions & 0 deletions src/utils/balances.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import type { EmployeeBalanceRow } from '../types/index.ts'

import { describe, expect, it } from 'vitest'
import { availableByEmployeeAndType } from './balances.ts'

/**
* @param values what the test is about
*/
function row(values: Partial<EmployeeBalanceRow>): EmployeeBalanceRow {
return { employeeUid: 'alice', typeId: 1, entitlement: 28, used: 15, pending: 4, remaining: 13, available: 9, ...values } as EmployeeBalanceRow
}

describe('availableByEmployeeAndType', () => {
it('keeps the available days, after pending requests, per person and type', () => {
expect(availableByEmployeeAndType([
row({}),
row({ employeeUid: 'bob', remaining: 19, available: 16 }),
])).toEqual({ 'alice|1': 9, 'bob|1': 16 })
})

it('leaves out a type that counts against nothing', () => {
expect(availableByEmployeeAndType([row({ typeId: 4, entitlement: null, remaining: null, available: null })])).toEqual({})
})
})
22 changes: 22 additions & 0 deletions src/utils/balances.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import type { EmployeeBalanceRow } from '../types/index.ts'

/**
* The days each person can still book, per leave type: entitlement minus used
* minus pending. Keyed `employeeUid|typeId`; types that count against nothing
* are left out.
*
* @param rows a balance report
*/
export function availableByEmployeeAndType(rows: EmployeeBalanceRow[]): Record<string, number> {
const index: Record<string, number> = {}
for (const row of rows) {
if (row.available !== null) {
index[`${row.employeeUid}|${row.typeId}`] = row.available
}
}
return index
}
2 changes: 1 addition & 1 deletion src/utils/status.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ vi.mock('@nextcloud/l10n', () => ({ t: (app: string, text: string) => text }))

describe('statusMeta', () => {
it('labels every known status', () => {
for (const status of ['PENDING', 'ESCALATED', 'APPROVED', 'REJECTED', 'CANCELLED', 'WITHDRAWAL_PENDING']) {
for (const status of ['PENDING', 'ESCALATED', 'APPROVED', 'REJECTED', 'CANCELLED', 'WITHDRAWAL_PENDING', 'RECORDED']) {
const meta = statusMeta(status)
expect(meta.label).toBeTruthy()
expect(meta.label).not.toBe(status)
Expand Down
6 changes: 4 additions & 2 deletions src/utils/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import type { RequestStatus } from '../types/index.ts'
import type { ChipStatus } from '../types/index.ts'

import { t } from '@nextcloud/l10n'

Expand All @@ -21,7 +21,7 @@ export interface StatusMeta {
*
* @param status the status, as the server names it
*/
export function statusMeta(status: RequestStatus | string): StatusMeta {
export function statusMeta(status: ChipStatus | string): StatusMeta {
switch (status) {
case 'PENDING':
return { label: t('absence', 'Pending'), text: 'var(--color-warning-text)', tint: 'var(--color-warning)', icon: '⏳' }
Expand All @@ -33,6 +33,8 @@ export function statusMeta(status: RequestStatus | string): StatusMeta {
return { label: t('absence', 'Declined'), text: 'var(--color-error-text)', tint: 'var(--color-error)', icon: '✋' }
case 'CANCELLED':
return { label: t('absence', 'Cancelled'), text: 'var(--color-text-maxcontrast)', tint: 'var(--color-text-maxcontrast)', icon: '🚫' }
case 'RECORDED':
return { label: t('absence', 'Recorded'), text: 'var(--color-text-maxcontrast)', tint: 'var(--color-text-maxcontrast)', icon: '🗂️' }
case 'WITHDRAWAL_PENDING':
return { label: t('absence', 'Withdrawal pending'), text: 'var(--color-warning-text)', tint: 'var(--color-warning)', icon: '↩️' }
default:
Expand Down
2 changes: 1 addition & 1 deletion src/views/MyLeave.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<h2 class="page__title">
{{ t('absence', 'My leave') }}
</h2>
<NcButton variant="primary" @click="openNew">
<NcButton class="page__primary" variant="primary" @click="openNew">
<template #icon>
<Plus :size="20" />
</template>
Expand Down
Loading
Loading