Skip to content

3.4: Work Item Notes & Subtasks API #90

@steilerDev

Description

@steilerDev

As a homeowner, I want to add notes and checklist subtasks to work items so that I can track detailed progress and record important information for each construction task.

Parent Epic: #3
Priority: Must Have

Acceptance Criteria

Notes

  • 1. POST /api/work-items/:workItemId/notes creates a new note on a work item and returns 201. Required field: content (text, non-empty). The createdBy field is automatically set to the authenticated user. Returns 404 NOT_FOUND if the work item does not exist.
  • 2. GET /api/work-items/:workItemId/notes returns all notes for a work item (200 OK), sorted by created_at descending (newest first). Each note includes id, content, createdBy (user summary: { id, displayName }), createdAt, updatedAt.
  • 3. PATCH /api/work-items/:workItemId/notes/:noteId updates a note's content (200 OK). Only the note's author or an admin can edit a note. Returns 403 FORBIDDEN if a non-admin user tries to edit another user's note. Returns 404 NOT_FOUND if the note or work item does not exist.
  • 4. DELETE /api/work-items/:workItemId/notes/:noteId deletes a note (204 No Content). Only the note's author or an admin can delete a note. Returns 403 FORBIDDEN if unauthorized. Returns 404 NOT_FOUND if the note or work item does not exist.

Subtasks

  • 5. POST /api/work-items/:workItemId/subtasks creates a new subtask and returns 201. Required field: title (text, non-empty). Optional field: sortOrder (integer). If sortOrder is not provided, the subtask is appended to the end (max sort_order + 1). Returns 404 NOT_FOUND if the work item does not exist.
  • 6. GET /api/work-items/:workItemId/subtasks returns all subtasks for a work item (200 OK), sorted by sort_order ascending.
  • 7. PATCH /api/work-items/:workItemId/subtasks/:subtaskId updates a subtask's title, completion status (isCompleted), and/or sort order (200 OK). Returns 404 NOT_FOUND if the subtask or work item does not exist.
  • 8. DELETE /api/work-items/:workItemId/subtasks/:subtaskId deletes a subtask (204 No Content). Returns 404 NOT_FOUND if the subtask or work item does not exist.
  • 9. PATCH /api/work-items/:workItemId/subtasks/reorder accepts an ordered array of subtask IDs and updates the sort_order of each subtask to match the array order (200 OK). Returns 400 VALIDATION_ERROR if any subtask ID does not belong to the specified work item.

Cross-cutting

  • 10. All endpoints require authentication (401 UNAUTHORIZED without valid session). Both admin and member roles can manage notes and subtasks.
  • 11. Validation errors return 400 VALIDATION_ERROR for: empty content/title, non-integer sort_order.

Notes

  • Depends on Story 3.2 (work items must be creatable before notes/subtasks can be added).
  • Notes are attributed to the user who created them — this enables an activity-log style display.
  • Subtask reorder (AC EPIC-09: Dashboard & Project Health Center #9) allows drag-and-drop reordering on the frontend without having to update each subtask individually.
  • The createdBy FK uses SET NULL on delete so that notes remain even if the creating user is removed.
  • Depends on: 3.2: Work Items CRUD API #88 (Story 3.2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions