From d243d31e363730c5186da60348e35e0100dcfcc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6?= <14975046+skjnldsv@users.noreply.github.com> Date: Tue, 17 Nov 2026 15:09:11 +0100 Subject: [PATCH] feat(settings): links to the sections of the settings page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The settings page is one long scroll with no way to jump to a section. A list of links under the title now leads to each section. A link scrolls to its section and focuses the section heading, without changing the URL, so the app's hash route stays as it is. Each link points to #/hr/settings?section=, and opening that URL scrolls to the section once the settings are loaded. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: John Molakvoæ <14975046+skjnldsv@users.noreply.github.com> --- SPECIFICATION.md | 6 +- src/utils/settingsSections.spec.ts | 21 +++++ src/utils/settingsSections.ts | 18 +++++ src/views/hr/HrSettings.vue | 125 ++++++++++++++++++++++++----- 4 files changed, 150 insertions(+), 20 deletions(-) create mode 100644 src/utils/settingsSections.spec.ts create mode 100644 src/utils/settingsSections.ts diff --git a/SPECIFICATION.md b/SPECIFICATION.md index 1ffcd736..897071ef 100644 --- a/SPECIFICATION.md +++ b/SPECIFICATION.md @@ -1265,7 +1265,11 @@ confirmation below. Neither setting can be emptied, and the session carries `configured`. The settings live on a **Settings** page inside the app (`#/hr/settings`), reached -from the app navigation footer. There is no Administration settings section. HR +from the app navigation footer. Under its title, a list of links leads to each +section of the table below: a link scrolls to its section and moves the keyboard +focus to the section heading without changing the URL, and +`#/hr/settings?section=` opens the page on that section. There is no +Administration settings section. HR members and Nextcloud admins can open it: admins need it without being in HR, because a fresh install has nobody in HR and someone has to pick the HR group. Everyone else gets 403 from its endpoints (`GET`/`PUT /api/settings`, diff --git a/src/utils/settingsSections.spec.ts b/src/utils/settingsSections.spec.ts new file mode 100644 index 00000000..5eef0db5 --- /dev/null +++ b/src/utils/settingsSections.spec.ts @@ -0,0 +1,21 @@ +/** + * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +import { describe, expect, it } from 'vitest' +import { sectionFromQuery } from './settingsSections.ts' + +describe('sectionFromQuery', () => { + it('reads a known section', () => { + expect(sectionFromQuery('vacation')).toBe('vacation') + expect(sectionFromQuery('leave-types')).toBe('leave-types') + }) + + it('ignores what is not a section', () => { + expect(sectionFromQuery(undefined)).toBeNull() + expect(sectionFromQuery('')).toBeNull() + expect(sectionFromQuery('nope')).toBeNull() + expect(sectionFromQuery('toString')).toBeNull() + expect(sectionFromQuery(['vacation'])).toBeNull() + }) +}) diff --git a/src/utils/settingsSections.ts b/src/utils/settingsSections.ts new file mode 100644 index 00000000..e43e3417 --- /dev/null +++ b/src/utils/settingsSections.ts @@ -0,0 +1,18 @@ +/** + * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +/** The sections of the settings page, in page order. */ +export const SETTINGS_SECTIONS = ['who', 'vacation', 'approvals', 'calendar', 'holidays', 'handbooks', 'leave-types'] as const + +export type SettingsSection = typeof SETTINGS_SECTIONS[number] + +/** + * The section a `section` query value names, null when it names none. + * + * @param value the query value: a string, or a list when repeated + */ +export function sectionFromQuery(value: unknown): SettingsSection | null { + return SETTINGS_SECTIONS.find((section) => section === value) ?? null +} diff --git a/src/views/hr/HrSettings.vue b/src/views/hr/HrSettings.vue index 920dcc30..7dccedd2 100644 --- a/src/views/hr/HrSettings.vue +++ b/src/views/hr/HrSettings.vue @@ -21,12 +21,22 @@