diff --git a/openapi.yaml b/openapi.yaml index 80eb906..76bf8ea 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -8799,6 +8799,13 @@ paths: by hand. `automatic`: every Contact now in the Project gets it (in the background), and so does every Contact who later joins or is created in it. `none`: stop offering it; Contacts who already have it keep it. Requires an Organisation editor, or a Project Manager of the Project. + + For an `automatic` Checklist, `on_leave` says what happens when a Contact leaves the Project, + moves to a closed status in it (Alumni or Declined) or is archived: `keep` (the default) or + `remove_if_incomplete`, which takes it off them unless every action is done. A Checklist + removed that way keeps the Contact's progress, and comes back when they rejoin. Send `mode`, + `on_leave` or both; `on_leave` on its own changes only that, and needs the Checklist to be + `automatic` in the Project. operationId: setChecklistProject security: [{tokenAuth: []}] parameters: @@ -8816,11 +8823,23 @@ paths: required: true content: application/json: + schema: + type: object + properties: + mode: + type: string + enum: [none, manual, automatic] + on_leave: + type: string + enum: [keep, remove_if_incomplete] example: mode: "automatic" + on_leave: "remove_if_incomplete" responses: "200": - description: "`{project_id, assignment_mode}`" + description: "`{project_id, assignment_mode, on_leave}`" + "422": + $ref: '#/components/responses/UnprocessableEntity' "401": $ref: '#/components/responses/Unauthorized' "403": @@ -9086,7 +9105,8 @@ paths: lets the user add by hand is allowed; see `GET /beneficiaries/{beneficiary_id}/checklists/available`. It is added through a Project, the one whose records count for actions set to "Only count records in this project": the only Project that allows it, or `project_id` when more than one - does (required then). + does (required then). Adding one that was removed from the Contact earlier restores the + actions they had done. operationId: addContactChecklist security: [{tokenAuth: []}] parameters: @@ -9112,6 +9132,48 @@ paths: "422": $ref: '#/components/responses/UnprocessableEntity' + /beneficiaries/{beneficiary_id}/checklists/{checklist_id}: + delete: + tags: [Checklists] + summary: Remove a Checklist from a Contact + description: | + "Remove from this contact" in the ⋯ menu of a Checklist on the Contact's profile, for one added + by mistake or no longer relevant. It no longer shows on the Contact, in the Checklist's progress + or on Focus, and the removal is recorded on the Contact's History. The Contact's progress is + kept: adding the Checklist again (`POST /beneficiaries/{beneficiary_id}/checklists`) restores the + actions they had done, and a Project that adds the Checklist automatically won't add it back. + Allowed for Organisation Admins, and for colleagues who could add the Checklist to the Contact by + hand. + operationId: removeContactChecklist + security: [{tokenAuth: []}] + parameters: + - name: beneficiary_id + in: path + required: true + schema: + type: integer + - name: checklist_id + in: path + required: true + schema: + type: integer + responses: + "200": + description: "`{checklist_id, beneficiary_id, removed_at, removed_by_user_id}`" + content: + application/json: + example: + checklist_id: 42 + beneficiary_id: 1001 + removed_at: "2026-11-05T10:00:00Z" + removed_by_user_id: 7 + "401": + $ref: '#/components/responses/Unauthorized' + "403": + description: "`{errors}`: the user is neither an Organisation Admin nor able to add this Checklist to the Contact" + "404": + $ref: '#/components/responses/NotFound' + /beneficiaries/{beneficiary_id}/checklists/{checklist_id}/actions/{action_id}/owner: patch: tags: [Checklists] diff --git a/server.js b/server.js index 3a7b8ed..916806a 100644 --- a/server.js +++ b/server.js @@ -2720,10 +2720,12 @@ function buildDocsPage() { ${endpointCard("PATCH", "/checklists/{id}/projects/{project_id}", "Set how a Project offers a Checklist", true, [ { name: "id", in: "path", type: "integer", required: true, desc: "Checklist ID" }, { name: "project_id", in: "path", type: "integer", required: true, desc: "Project ID" }, - { name: "mode", type: "string", required: true, desc: "none, manual or automatic" } + { name: "mode", type: "string", required: false, desc: "none, manual or automatic; required unless only on_leave is sent" }, + { name: "on_leave", type: "string", required: false, desc: "For an automatic Checklist, what happens when a Contact leaves the Project, moves to a closed status in it (Alumni or Declined) or is archived: keep (default) or remove_if_incomplete. A removed Checklist keeps the Contact's progress and comes back when they rejoin" } ], [ - { code: "200", cls: "response-2xx", desc: "{project_id, assignment_mode}" }, - { code: "404", cls: "response-4xx", desc: "A Project the user can't edit" } + { code: "200", cls: "response-2xx", desc: "{project_id, assignment_mode, on_leave}" }, + { code: "404", cls: "response-4xx", desc: "A Project the user can't edit" }, + { code: "422", cls: "response-4xx", desc: "An unknown mode, or on_leave for a Checklist that isn't automatic in the Project" } ])} ${endpointCard("GET", "/checklists/{id}/progress", "Get a Checklist's progress", true, [ { name: "id", in: "path", type: "integer", required: true, desc: "Checklist ID" }, @@ -2829,6 +2831,14 @@ function buildDocsPage() { { code: "201", cls: "response-2xx", desc: "{checklist_id, beneficiary_id, added_by_user_id, project_id, created_at}" }, { code: "422", cls: "response-4xx", desc: "That Checklist can't be added to this Contact, or no project_id when it can be added through several Projects" } ])} + ${endpointCard("DELETE", "/beneficiaries/{beneficiary_id}/checklists/{checklist_id}", "Remove a Checklist from a Contact", true, [ + { name: "beneficiary_id", in: "path", type: "integer", required: true, desc: "Contact ID" }, + { name: "checklist_id", in: "path", type: "integer", required: true, desc: "Checklist ID" } + ], [ + { code: "200", cls: "response-2xx", desc: "{checklist_id, beneficiary_id, removed_at, removed_by_user_id}. The Contact's progress is kept: adding the Checklist again restores it" }, + { code: "403", cls: "response-4xx", desc: "Only an Organisation Admin, or a colleague who can add this Checklist to the Contact, can remove it" }, + { code: "404", cls: "response-4xx", desc: "A Contact the user can't see, or a Checklist the Contact doesn't have" } + ])}