feat: add category selection (Low/Medium/High) to tasks#11
Conversation
Agent-Logs-Url: https://github.com/CleveritDemo/copilot-agentic-workshop/sessions/b5fe920d-8b52-457b-a8bc-51fd09f1fdee Co-authored-by: saulCleverit <121240069+saulCleverit@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds first-class task category support (Low/Medium/High) across the Node/Express API and the Vanilla JS frontend so users can classify tasks at creation time and see a color-coded badge in the list.
Changes:
- Backend: validate and persist
categoryon create/update. - Frontend: add category
<select>to the task form and send category in POST requests. - UI: render category badges and add corresponding CSS (including dark theme overrides).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| backend/controllers/tasksController.js | Adds category validation and persistence in create/update endpoints. |
| frontend/index.html | Adds category dropdown to the task creation form. |
| frontend/script.js | Sends selected category and renders category badges using DOM APIs. |
| frontend/style.css | Styles the category dropdown and adds category badge styles for light/dark themes. |
| const API_URL = 'http://localhost:3000/api/tasks'; | ||
| const CATEGORIES = ['Low', 'Medium', 'High']; | ||
| const DEFAULT_CATEGORY = 'Medium'; |
There was a problem hiding this comment.
CATEGORIES is declared but never used. This adds dead code and can cause lint/build failures in stricter setups; either remove it or use it to generate/validate category values in the UI (e.g., populate the <select> or validate categorySelect.value before sending).
| border-radius: 12px; | ||
| text-transform: uppercase; | ||
| letter-spacing: 0.5px; | ||
| margin: 0 0.5em; |
There was a problem hiding this comment.
The new category badge is a <span> inside <li>, but the existing global rule li span { flex: 1; } will also apply to .category-badge, causing it to grow/stretch and potentially break the layout. Consider overriding in .category-badge (e.g., ensure it does not flex-grow) or tightening the li span selector to target only the title span.
| margin: 0 0.5em; | |
| margin: 0 0.5em; | |
| flex: 0 0 auto; |
| <select id="categorySelect"> | ||
| <option value="Low">Low</option> | ||
| <option value="Medium" selected>Medium</option> | ||
| <option value="High">High</option> | ||
| </select> |
There was a problem hiding this comment.
The new <select id="categorySelect"> has no accessible name (no <label> and no aria-label/aria-labelledby). Add an explicit label or an ARIA label so screen readers can announce what this control does.
Summary
Adds predefined category support to tasks, allowing users to classify each task as Low, Medium, or High at creation time. Each category is color-coded for quick visual identification.
Changes
Backend (
backend/controllers/tasksController.js)VALID_CATEGORIESconstant (['Low', 'Medium', 'High'])createTask: readscategoryfrom request body (defaults to'Medium'), validates it, and persists it in the task objectupdateTask: validates the new category value before applying it, returning a400error for invalid valuesFrontend (
frontend/index.html)<select id="categorySelect">dropdown with options Low / Medium (default) / High to the task creation formFrontend (
frontend/script.js)CATEGORIESandDEFAULT_CATEGORYconstants to avoid magic stringsaddTaskToDOM: renders a color-coded<span class="category-badge category-{low|medium|high}">badge next to each task title using safe DOM API (noinnerHTMLfor user data)categoryin the POST body and resets the dropdown to the default after submissionFrontend (
frontend/style.css)#categorySelectto match the existing input field appearance.category-badge,.category-low,.category-medium,.category-highclasses with distinct colors: