diff --git a/conductor/tracks.md b/conductor/tracks.md index 6d69db6..71f0f24 100644 --- a/conductor/tracks.md +++ b/conductor/tracks.md @@ -6,3 +6,8 @@ This file tracks all major tracks for the project. Each track has its own detail - [x] **Track: Refactor the meal tracking system to decouple 'Journal Logs' from 'Cookbook Recipes'** *Link: [./tracks/meal_tracker_refactor_20250223/](./tracks/meal_tracker_refactor_20250223/)* + +--- + +- [ ] **Track: Add real-time search and alphabetical sorting to the Add Meal and Add Food modals on the tracker page.** +*Link: [./tracks/meal_food_search_20260310/](./tracks/meal_food_search_20260310/)* diff --git a/conductor/tracks/meal_food_search_20260310/index.md b/conductor/tracks/meal_food_search_20260310/index.md new file mode 100644 index 0000000..ecbd416 --- /dev/null +++ b/conductor/tracks/meal_food_search_20260310/index.md @@ -0,0 +1,5 @@ +# Track meal_food_search_20260310 Context + +- [Specification](./spec.md) +- [Implementation Plan](./plan.md) +- [Metadata](./metadata.json) \ No newline at end of file diff --git a/conductor/tracks/meal_food_search_20260310/metadata.json b/conductor/tracks/meal_food_search_20260310/metadata.json new file mode 100644 index 0000000..f540c4a --- /dev/null +++ b/conductor/tracks/meal_food_search_20260310/metadata.json @@ -0,0 +1,8 @@ +{ + "track_id": "meal_food_search_20260310", + "type": "feature", + "status": "new", + "created_at": "2026-03-10T12:00:00Z", + "updated_at": "2026-03-10T12:00:00Z", + "description": "Add real-time search and alphabetical sorting to the Add Meal and Add Food modals on the tracker page." +} \ No newline at end of file diff --git a/conductor/tracks/meal_food_search_20260310/plan.md b/conductor/tracks/meal_food_search_20260310/plan.md new file mode 100644 index 0000000..6eee09c --- /dev/null +++ b/conductor/tracks/meal_food_search_20260310/plan.md @@ -0,0 +1,32 @@ +# Implementation Plan: Meal/Food Search & Sorting (Track: meal_food_search_20260310) + +## Phase 1: Preparation and Testing +- [ ] Task: Create a new Playwright test file `tests/meal_food_search.spec.js` to verify searching and sorting in modals. +- [ ] Task: Write failing E2E tests for: + - [ ] Modal opening and initial alphabetical sorting of Meals. + - [ ] Real-time filtering in the "Add Meal" modal. + - [ ] Modal opening and initial alphabetical sorting of Foods. + - [ ] Real-time filtering (by name and brand) in the "Add Food" modal. +- [ ] Task: Run the tests and confirm they fail. +- [ ] Task: Conductor - User Manual Verification 'Phase 1: Preparation and Testing' (Protocol in workflow.md) + +## Phase 2: Implement Sorting & Searching in "Add Meal" Modal +- [ ] Task: Update `templates/modals/add_meal.html` to add a search input field above the meal list. +- [ ] Task: Add a unique `data-testid` to the search input and individual list items for test reliability. +- [ ] Task: Update the backend route `app/api/routes/tracker.py` to sort the `meals` list alphabetically before passing it to the template. +- [ ] Task: Implement client-side JavaScript in `templates/modals/add_meal.html` to filter the meal list in real-time as the user types. +- [ ] Task: Verify Phase 2 with E2E tests. +- [ ] Task: Conductor - User Manual Verification 'Phase 2: Implement Sorting & Searching in Add Meal Modal' (Protocol in workflow.md) + +## Phase 3: Implement Sorting & Searching in "Add Food" Modal +- [ ] Task: Update `templates/modals/add_single_food.html` (or the relevant "Add Food" modal) to add a search input field above the food list. +- [ ] Task: Add a unique `data-testid` to the search input and food list items. +- [ ] Task: Update the backend route `app/api/routes/tracker.py` to sort the `foods` list alphabetically before passing it to the template. +- [ ] Task: Implement client-side JavaScript in the "Add Food" modal to filter by both `name` and `brand` in real-time. +- [ ] Task: Verify Phase 3 with E2E tests. +- [ ] Task: Conductor - User Manual Verification 'Phase 3: Implement Sorting & Searching in Add Food Modal' (Protocol in workflow.md) + +## Phase 4: Final Verification and Cleanup +- [ ] Task: Perform a final run of all tests (E2E and Backend). +- [ ] Task: Ensure code coverage for any new logic (if applicable) is >80%. +- [ ] Task: Conductor - User Manual Verification 'Phase 4: Final Verification and Cleanup' (Protocol in workflow.md) \ No newline at end of file diff --git a/conductor/tracks/meal_food_search_20260310/spec.md b/conductor/tracks/meal_food_search_20260310/spec.md new file mode 100644 index 0000000..cd4c843 --- /dev/null +++ b/conductor/tracks/meal_food_search_20260310/spec.md @@ -0,0 +1,32 @@ +# Specification: Meal/Food Search & Sorting (Track: meal_food_search_20260310) + +## Overview +Enhance the user experience on the Tracker page by implementing real-time searching and alphabetical sorting for the "Add Meal" and "Add Food" modals. This will allow users to quickly locate specific items in their potentially large database of foods and meals. + +## Functional Requirements +1. **Alphabetical Sorting**: + - The list of available meals in the "Add Meal" modal must be sorted alphabetically (A-Z) by name. + - The list of available foods in the "Add Food" modal must be sorted alphabetically (A-Z) by name. +2. **Real-time Search Filter**: + - A search bar (text input) must be added above the lists in both "Add Meal" and "Add Food" modals. + - As the user types in the search bar, the list must filter in real-time. + - The filter should be case-insensitive. +3. **Search Scope**: + - For **Meals**: The search should match against the `name` field. + - For **Foods**: The search should match against both the `name` and `brand` fields. + +## Non-Functional Requirements +- **Performance**: Filtering should be near-instantaneous on the client-side for a smooth user experience. +- **Maintainability**: Use standard Bootstrap and Vanilla JavaScript patterns consistent with the existing codebase. + +## Acceptance Criteria +- [ ] Open the "Add Meal" modal on the Tracker page; meals are sorted A-Z. +- [ ] Type in the search bar in the "Add Meal" modal; the list filters to show only matching meals. +- [ ] Open the "Add Food" modal on the Tracker page; foods are sorted A-Z. +- [ ] Type a food name or brand in the search bar in the "Add Food" modal; the list filters correctly. +- [ ] Clearing the search bar restores the full (sorted) list. + +## Out of Scope +- Server-side searching (filtering will be done on the already-loaded client-side list). +- Advanced fuzzy matching (initially, simple substring matching is sufficient). +- Searching for other tabs like "Foods" or "Meals" (this track is specific to the Tracker page modals). \ No newline at end of file