Repository navigation
feat: assign an Assessment to a crew — a crew read route and the crew picker - #627
Merged
Merged
Conversation
… picker The assign and preview routes already took crewIds, but nothing listed a Site's crews, so neither the create form nor the assign dialog could offer one. GET /api/people/sites/:siteId/crews returns a Site's active crews (inactive only with includeInactive=true), searchable by code or name and capped like the Org Unit search. It is gated by Site scope and PPL_ORG_UNITS_DISPLAY, and each crew carries an employeeCount. That count and assign share one RESOLVED_EMPLOYEES_SQL, now in sql.js, so the number shown is the number of Attempts the crew alone would create. Inside its transaction, assign now refuses an unknown crew id, or a crew that reaches nobody, naming the crew by code and name. Both screens gain an "Add a crew" search between the Org Unit and Employee searches. Its chips show the crew's name and member count, preview and submit send crewIds, and the empty-group rule counts crews. Strings are in both ARBs. Part of #588 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A Team Leader can now assign an Assessment to a crew, both on the create form and in the assign dialog. Before this, the API accepted
crewIdsbut nothing could list crews. The client said so outright: "Crews have no client surface yet".Server (People)
GET /api/people/sites/:siteId/crews?search=&includeInactive=returns{ crews: [{ id, siteId, code, name, isActive, employeeCount }], truncated }, ordered by name. It is gated by Site scope plus the existingPPL_ORG_UNITS_DISPLAY. No new permission code and no migration.employeeCountuses the same resolver asassign(RESOLVED_EMPLOYEES_SQL, now insql.jsand shared, not copied). That resolver takes the crew from the current assignment, elsedefault_crew_id, active Employees only. So the number on the chip is the number of Attempts the crew alone would create.assignnow returns 400 for an unknown crew id. It also returns 400 for a named crew that reaches nobody, with a message that names it (crew X (Name) reaches nobody — no active Employee is on it), even when the rest of the group does reach people.Client
assessment_create_screen.dartandassessment_assign_dialog.dart. Each chip shows the crew name and its Employee count. Preview and submit sendcrewIds.Crewmodel andPeopleApi.searchCrews. ARB keys are added in bothapp_en.arbandapp_vi.arb(Tổ ca).Decisions
/crews, because crews carrysite_idand the picker already searches within the Assessment's Site.orgUnitName: thecrewstable has no Org Unit column.Out of scope
Crew create, rename and retire. Nothing in the app manages crews today. Rows exist only through seeds and data loads. That needs its own card and its own decision.
Tests
backend/test/integration/people-crews.test.jscovers the list with the member count (one member via an open assignment, one viadefault_crew_idonly, an inactive Employee excluded), search,includeInactive, 403 without the code, 404 for an unknown Site, a zero-member crew refused byassignwith its code named and no Attempts written, and a preview of crew + Org Unit + Employee that counts each person once and matches the Attempts thatassigncreates.assessment_detail_test.dart, "a Crew picked in the assign dialog shows its member count, is previewed, and is sent on confirm".assessment_create_test.dartcovers picking a crew, the chip count, the previewcrewIds, and the assign body carrying the crew id.Checks (run on head)
npm run lint:module boundaries: ok,syntax: checked 245 filesnpm test: 58/58 passnpm run test:integrationon a freshly migrated scratch DB: 1405 tests, 1399 pass, 0 fail, 6 skipped. Four are the expectedrls.test.jsanon/authenticated skips. Two are the plant data load skipping because no employee master file exists in a local checkout../scripts/flutter-ci.sh(pinned 3.44.0):No issues found!,module seams ok,All tests passed!(2149). No golden file changed.bash scripts/design_gate.sh: 15 of 17 mismatches are AA noise. The other 2 are flagged for review:home_wide_enandhome_wide_vi, which differ only in card-border antialiasing on the Home screen. This PR does not touch that screen. The gate rendered with the host's non-pinned Flutter, and the pinned image passes those same goldens.Part of #588