From 2a94055046e31e59f18ee01554771543b2914238 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 14:56:47 +0100 Subject: [PATCH] fix(hr): employees list flags only real gaps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A person without a manager was flagged as missing data with a warning chip and counted by the "Missing data" filter, although the person at the top and HR legitimately have none. Missing data is now the region code, the working pattern and the start date; no manager reads as muted text. The Since column shows the full date on every row instead of mixing years and dates, and the subtitle names the employees group by its display name, which the list endpoint now returns as employeesGroupName. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: John Molakvoæ <14975046+skjnldsv@users.noreply.github.com> --- SPECIFICATION.md | 11 ++++--- lib/Service/EmployeeListService.php | 17 +++++++---- src/types/employees.ts | 6 ++-- src/views/hr/HrEmployees.vue | 42 +++++++++++++------------- tests/Integration/EmployeeListTest.php | 31 +++++++++++++++++-- 5 files changed, 71 insertions(+), 36 deletions(-) diff --git a/SPECIFICATION.md b/SPECIFICATION.md index 1ffcd736..2dfaf6ad 100644 --- a/SPECIFICATION.md +++ b/SPECIFICATION.md @@ -1325,11 +1325,14 @@ The HR area (visible only to HR-group members) provides: 1. **Employees list** (`#/hr/employees`, `GET /api/employees?year`, HR-only): everyone the directory counts as an employee (§2.2), one row each, with their region code (§7.2), working days and contract percentage of the period in force - today (§6.4), start date (the year, or the day when it falls in the selected - year) and end date, manager (§2.1), and for the selected year the annual days + today (§6.4), start date and end date (both as the locale's date, the same + format on every row), manager (§2.1), and for the selected year the annual days (§6.4), taken and available, and sick days. Missing data is flagged rather than left - blank: *No region code*, *No manager* (their requests go straight to HR) and *No - contract data*. Filters: all, missing data (any of the three), part-time (fewer + blank: *No region code*, *No contract data* (no working pattern) and *No start + date*. Having no manager is not missing data: the person at the top and often HR + have none, and their requests go straight to HR, so the cell reads *No manager* in + muted text. The subtitle names the employees group by its display name. Filters: + all, missing data (any of the three), part-time (fewer than five weekdays or under 100 %), and starting or leaving in the year; a search by name or user id; rows shown 50 at a time. Each row opens the person's profile, and its menu edits each counting entitlement with its history (§6.1). *Edit as diff --git a/lib/Service/EmployeeListService.php b/lib/Service/EmployeeListService.php index d53f0d86..ec64f435 100644 --- a/lib/Service/EmployeeListService.php +++ b/lib/Service/EmployeeListService.php @@ -10,11 +10,13 @@ namespace OCA\Absence\Service; use OCP\App\IAppManager; +use OCP\IGroupManager; use OCP\IUserManager; /** * The HR employees list (§13): everyone with their region code, contract, - * manager, annual days and sick days for a year, and what is missing. Loaded + * manager, annual days and sick days for a year, and what HR still has to + * fill in: the region code, the working pattern and the start date. Loaded * in a fixed number of queries, however many people there are. * * @psalm-import-type Contract from EmployeeService @@ -22,8 +24,8 @@ */ class EmployeeListService { public const MISSING_REGION = 'region'; - public const MISSING_MANAGER = 'manager'; public const MISSING_CONTRACT = 'contract'; + public const MISSING_START = 'start'; private const ANNUAL = 'annual'; private const FULL_WEEK = 5; @@ -37,6 +39,7 @@ public function __construct( private ConfigService $config, private ReportService $reports, private IUserManager $userManager, + private IGroupManager $groupManager, private IAppManager $appManager, private ClockService $clock, private HolidayService $holidays, @@ -44,13 +47,15 @@ public function __construct( } /** - * @return array{year: int, employeesGroup: string, contacts: bool, rows: list>} + * @return array{year: int, employeesGroup: string, employeesGroupName: string, contacts: bool, rows: list>} */ public function list(?int $year): array { $year ??= $this->clock->userYear(); + $group = $this->config->getEmployeesGroup(); return [ 'year' => $year, - 'employeesGroup' => $this->config->getEmployeesGroup(), + 'employeesGroup' => $group, + 'employeesGroupName' => $group === '' ? '' : ($this->groupManager->get($group)?->getDisplayName() ?? $group), 'contacts' => $this->appManager->isEnabledForUser('contacts'), 'rows' => $this->rows($this->directory->listAll(), $year), ]; @@ -86,8 +91,8 @@ public function rows(array $uids, int $year): array { $current = self::currentPeriod($contract, $today); $missing = array_keys(array_filter([ self::MISSING_REGION => $this->holidays->needsRegion($region), - self::MISSING_MANAGER => $managerUid === null, - self::MISSING_CONTRACT => $contract['start'] === null && $contract['end'] === null && $contract['periods'] === [], + self::MISSING_CONTRACT => $contract['periods'] === [], + self::MISSING_START => $contract['start'] === null, ])); $rows[] = [ 'uid' => $uid, diff --git a/src/types/employees.ts b/src/types/employees.ts index 77923d6d..75510137 100644 --- a/src/types/employees.ts +++ b/src/types/employees.ts @@ -127,8 +127,8 @@ export interface Profile { history: ProfileChange[] | null } -/** What HR still has to complete for an employee. */ -export type EmployeeMissing = 'region' | 'manager' | 'contract' +/** What HR still has to complete for an employee: a person without a manager lacks nothing, their requests go to HR. */ +export type EmployeeMissing = 'region' | 'contract' | 'start' /** One row of HR's employees list, from EmployeeListService::rows(). */ export interface EmployeeRow { @@ -159,6 +159,8 @@ export interface EmployeeList { year: number /** Gid of the employees group, '' when none is configured. */ employeesGroup: string + /** Display name of the employees group, '' when none is configured. */ + employeesGroupName: string /** Whether the Contacts app is enabled for the viewer. */ contacts: boolean rows: EmployeeRow[] diff --git a/src/views/hr/HrEmployees.vue b/src/views/hr/HrEmployees.vue index a48fb848..6ace9ddc 100644 --- a/src/views/hr/HrEmployees.vue +++ b/src/views/hr/HrEmployees.vue @@ -14,8 +14,8 @@ {{ t('absence', 'Employees') }}

- {{ employeesGroup - ? t('absence', 'Members of the group {group}, {year}', { group: employeesGroup, year }, undefined, { escape: false, sanitize: false }) + {{ employeesGroupName + ? t('absence', 'Members of the group {group}, {year}', { group: employeesGroupName, year }, undefined, { escape: false, sanitize: false }) : t('absence', 'Everyone except guest accounts, {year}', { year }) }}

@@ -150,7 +150,14 @@ - {{ since(row.contract.start) }} + + {{ t('absence', 'until {date}', { date: formatDate(row.contract.end) }) }} @@ -159,11 +166,12 @@ - + class="employees__none" + :title="t('absence', 'No manager, requests go to HR')"> + {{ t('absence', 'No manager') }} + {{ fmt(row.annual?.entitlement) }} @@ -291,7 +299,7 @@ const currentYear = new Date().getFullYear() const loading = ref(true) const rows = shallowRef([]) -const employeesGroup = ref('') +const employeesGroupName = ref('') const contacts = ref(false) const search = ref('') const filter = ref('all') @@ -354,18 +362,6 @@ function fmt(v: number | null | undefined): string { return v === null || v === undefined ? '' : formatNumber(v) } -/** - * The year someone started, or the day when it is in the selected year. - * - * @param start YYYY-MM-DD - */ -function since(start: string | null): string { - if (!start) { - return '' - } - return Number(start.slice(0, 4)) === year.value ? formatDate(start) : start.slice(0, 4) -} - /** * Loads the employees of the selected year. */ @@ -378,7 +374,7 @@ async function reload(): Promise { return } rows.value = list.rows - employeesGroup.value = list.employeesGroup + employeesGroupName.value = list.employeesGroupName contacts.value = list.contacts } catch (e) { if (isLatest()) { @@ -439,6 +435,10 @@ async function onSaved(): Promise { gap: 10px; } + &__none { + color: var(--color-text-maxcontrast); + } + &__muted, &__note { color: var(--color-text-maxcontrast); diff --git a/tests/Integration/EmployeeListTest.php b/tests/Integration/EmployeeListTest.php index a5d45d85..c7a83308 100644 --- a/tests/Integration/EmployeeListTest.php +++ b/tests/Integration/EmployeeListTest.php @@ -111,14 +111,22 @@ public function testRowsSayWhatIsMissingAndWhoWorksPartTime(): void { self::assertFalse($this->row(self::PART_TIME, self::YEAR + 1)['startsOrLeaves']); $bare = $this->row(self::BARE); - self::assertSame([EmployeeListService::MISSING_REGION, EmployeeListService::MISSING_MANAGER, EmployeeListService::MISSING_CONTRACT], $bare['missing']); + self::assertSame([EmployeeListService::MISSING_REGION, EmployeeListService::MISSING_CONTRACT, EmployeeListService::MISSING_START], $bare['missing']); self::assertFalse($bare['partTime']); - self::assertNull($bare['manager']); + self::assertNull($bare['manager'], 'no manager is not missing data'); + + // A start date without working days still lacks the contract, and the other way round + $this->fresh(EmployeeService::class)->saveContract(self::BARE, '2020-01-01', null, [], self::HR); + self::assertSame([EmployeeListService::MISSING_REGION, EmployeeListService::MISSING_CONTRACT], $this->row(self::BARE)['missing']); + $this->fresh(EmployeeService::class)->saveContract(self::BARE, null, null, [ + ['from' => '2020-01-01', 'weekdays' => [1, 2, 3, 4, 5], 'percent' => 100], + ], self::HR); + self::assertSame([EmployeeListService::MISSING_REGION, EmployeeListService::MISSING_START], $this->row(self::BARE)['missing']); // Five days at full time from the start, ending next year $this->contract(self::BARE, [1, 2, 3, 4, 5], 100); $bare = $this->row(self::BARE); - self::assertNotContains(EmployeeListService::MISSING_CONTRACT, $bare['missing']); + self::assertSame([EmployeeListService::MISSING_REGION], $bare['missing']); self::assertFalse($bare['partTime']); self::assertFalse($bare['startsOrLeaves']); self::assertTrue($this->row(self::BARE, self::YEAR + 1)['startsOrLeaves']); @@ -131,6 +139,23 @@ public function testRowsSayWhatIsMissingAndWhoWorksPartTime(): void { self::assertFalse($this->row(self::BARE)['partTime'], 'five days, no percentage'); } + public function testTheListNamesTheEmployeesGroupByItsDisplayName(): void { + $groups = Server::get(IGroupManager::class); + $group = $groups->createGroup('itest-emplist-staff'); + $group->setDisplayName('Itest Staff'); + $group->addUser(Server::get(IUserManager::class)->get(self::PART_TIME)); + $appConfig = Server::get(IAppConfig::class); + $appConfig->setValueString(ConfigService::APP_ID, ConfigLexicon::KEY_EMPLOYEES_GROUP, 'itest-emplist-staff'); + try { + $list = $this->fresh(EmployeeListService::class)->list(self::YEAR); + self::assertSame('itest-emplist-staff', $list['employeesGroup']); + self::assertSame('Itest Staff', $list['employeesGroupName']); + } finally { + $appConfig->deleteKey(ConfigService::APP_ID, ConfigLexicon::KEY_EMPLOYEES_GROUP); + $group->delete(); + } + } + public function testACountryWithRegionalHolidaysNeedsItsRegion(): void { $holidays = Server::get(HolidayService::class); $holiday = $holidays->create('2027-01-06', 'ZZ-T1', 'itest Region day');